Class: UserChoices::FileSource
- Inherits:
-
AbstractSource
- Object
- Hash
- AbstractSource
- UserChoices::FileSource
- Defined in:
- lib/user-choices/sources.rb
Overview
:nodoc:
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from AbstractSource
Instance Method Summary collapse
-
#fill ⇒ Object
:nodoc:.
- #from_complete_path(path) ⇒ Object
- #from_file(filename) ⇒ Object
-
#read_into_hash ⇒ Object
:nodoc:.
-
#source ⇒ Object
:nodoc:.
Methods inherited from AbstractSource
#adjust, #apply, #each_conversion, #initialize
Constructor Details
This class inherits a constructor from UserChoices::AbstractSource
Instance Method Details
#fill ⇒ Object
:nodoc:
168 169 170 171 172 |
# File 'lib/user-choices/sources.rb', line 168 def fill # :nodoc: @external_names.each do | symbol, external_name | self[symbol] = @contents_as_hash[external_name] end end |
#from_complete_path(path) ⇒ Object
158 159 160 161 162 163 164 165 166 |
# File 'lib/user-choices/sources.rb', line 158 def from_complete_path(path) @path = path @contents_as_hash = self.read_into_hash @contents_as_hash.each do | external_name, value | sym = external_name.to_inputable_sym @external_names[sym] = external_name end self end |
#from_file(filename) ⇒ Object
154 155 156 |
# File 'lib/user-choices/sources.rb', line 154 def from_file(filename) from_complete_path(File.join(S4tUtils.find_home, filename)) end |
#read_into_hash ⇒ Object
:nodoc:
178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/user-choices/sources.rb', line 178 def read_into_hash # :nodoc: return {} unless File.exist?(@path) begin format_specific_reading rescue Exception => ex if format_specific_exception?(ex) msg = "Badly formatted #{source}: " + (ex) ex = ex.class.new(msg) end raise ex end end |
#source ⇒ Object
:nodoc:
174 175 176 |
# File 'lib/user-choices/sources.rb', line 174 def source # :nodoc: "configuration file #{@path}" end |