Class: ECSBundler::Config
- Inherits:
-
Object
- Object
- ECSBundler::Config
- Defined in:
- lib/ecs_bundler/config.rb
Constant Summary collapse
- FILE_NAME =
'/.ecsrc.json'.freeze
- URL =
'https://ecs-app.eacg.de'.freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load(path = nil) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
11 12 13 |
# File 'lib/ecs_bundler/config.rb', line 11 def initialize @data = end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
9 10 11 |
# File 'lib/ecs_bundler/config.rb', line 9 def data @data end |
Instance Method Details
#[](key) ⇒ Object
27 28 29 |
# File 'lib/ecs_bundler/config.rb', line 27 def [](key) @data[key] end |
#load(path = nil) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ecs_bundler/config.rb', line 15 def load(path = nil) path = [path, Dir.pwd, ENV['HOME']].flatten.compact.map do |path| if File.directory?(path) && File.exist?("#{path}#{FILE_NAME}") "#{path}#{FILE_NAME}" elsif File.file?(path) && File.exist?(path) path end end.compact.first @data = .merge(::JSON.parse(File.read(path)).map { |k, v| [k.to_sym, v] }.to_h) if path rescue end |