views:

76

answers:

2

Hello, I have a file that represents all components of a game. I want to load the file into cache on boot, then have the ability to call the attributes of the file from the controllers. How do I begin?

+1  A: 

Try out REXML, its an XML parsing library for Ruby. I think it comes with the standard version of Ruby, so you shouldn't even need to install a gem.

twolfe18
+2  A: 

I like http://cobravsmongoose.rubyforge.org for most simple XML handling:

CobraVsMongoose.xml_to_hash(File.open('path/to/xml').gets)

As for your specific case, I would add an initializer which requires cvm and sets the value above to a constant, which you could then access wherever you want...

# config/initializers/load_xml.rb
require 'cobravsmongoose'

MY_XML = CobraVsMongoose.xml_to_hash(File.open('path/to/xml').gets)
floyd