class ECSBundler::Config
Constants
- FILE_NAME
- URL
Attributes
data[R]
Public Class Methods
new()
click to toggle source
# File lib/ecs_bundler/config.rb, line 11 def initialize @data = get_default_options end
Public Instance Methods
[](key)
click to toggle source
# File lib/ecs_bundler/config.rb, line 27 def [](key) @data[key] end
load(path = nil)
click to toggle source
# 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 = get_default_options.merge(::JSON.parse(File.read(path)).map { |k, v| [k.to_sym, v] }.to_h) if path rescue end
Private Instance Methods
get_default_options()
click to toggle source
# File lib/ecs_bundler/config.rb, line 33 def get_default_options { url: URL, project: '', apiKey: '', userName: '', userAgent: "#{ECSBundler.name}/#{VERSION}" } end