Class: UserChoices::XmlConfigFileSource
- Inherits:
-
FileSource
- Object
- Hash
- AbstractSource
- FileSource
- UserChoices::XmlConfigFileSource
- Defined in:
- lib/user-choices/sources.rb
Overview
Use an XML file as a source of choices. The XML file is parsed with XmlSimple('ForceArray' => false). That means that single elements like <home>Mars</home> are read as the value "Mars", whereas <home>Mars</home><home>Venus</home> is read as ["Mars", "Venus"].
Instance Attribute Summary
Attributes inherited from AbstractSource
Instance Method Summary collapse
- #format_specific_exception?(ex) ⇒ Boolean
- #format_specific_message(ex) ⇒ Object
-
#format_specific_reading ⇒ Object
Treat filename as the configuration file.
Methods inherited from FileSource
#fill, #from_complete_path, #from_file, #read_into_hash, #source
Methods inherited from AbstractSource
#adjust, #apply, #each_conversion, #fill, #initialize, #source
Constructor Details
This class inherits a constructor from UserChoices::AbstractSource
Instance Method Details
#format_specific_exception?(ex) ⇒ Boolean
217 218 219 |
# File 'lib/user-choices/sources.rb', line 217 def format_specific_exception?(ex) ex.is_a?(REXML::ParseException) end |
#format_specific_message(ex) ⇒ Object
221 222 223 |
# File 'lib/user-choices/sources.rb', line 221 def (ex) ex.continued_exception end |
#format_specific_reading ⇒ Object
Treat filename as the configuration file. filename is expected to be in the home directory. The home directory is found in the same way Rubygems finds it. (First look in environment variables $HOME, $USERPROFILE, $HOMEDRIVE:$HOMEPATH, file expansion of "~" and finally the root.)
213 214 215 |
# File 'lib/user-choices/sources.rb', line 213 def format_specific_reading XmlSimple.xml_in(@path, 'ForceArray' => false) end |