Class: Norn::LocalConfigReader
- Inherits:
-
Object
- Object
- Norn::LocalConfigReader
- Defined in:
- lib/norn/local_config_reader.rb
Instance Attribute Summary collapse
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
Instance Method Summary collapse
-
#initialize(root_path = nil) ⇒ LocalConfigReader
constructor
A new instance of LocalConfigReader.
- #local_config_paths ⇒ Object
- #read ⇒ Object
Constructor Details
#initialize(root_path = nil) ⇒ LocalConfigReader
Returns a new instance of LocalConfigReader.
8 9 10 |
# File 'lib/norn/local_config_reader.rb', line 8 def initialize(root_path = nil) @root_path = root_path || Dir.pwd end |
Instance Attribute Details
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
6 7 8 |
# File 'lib/norn/local_config_reader.rb', line 6 def root_path @root_path end |
Instance Method Details
#local_config_paths ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/norn/local_config_reader.rb', line 12 def local_config_paths [ File.join(@root_path, ".norn.yml"), File.join(@root_path, ".norn.yaml"), File.join(@root_path, ".norn.json") ] end |
#read ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/norn/local_config_reader.rb', line 20 def read local_config_paths.each do |path| next unless File.exist?(path) begin if path.end_with?(".json") return parse_json(path) else return parse_yaml(path) end rescue => e warn "Norn Config Error: Failed to parse #{path} - #{e.}" end end {} end |