Class: Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_release/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



8
9
10
# File 'lib/gem_release/configuration.rb', line 8

def initialize
  load_options!
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/gem_release/configuration.rb', line 6

def options
  @options
end

Instance Method Details

#[](key) ⇒ Object



30
31
32
# File 'lib/gem_release/configuration.rb', line 30

def [](key)
  options[key]
end

#[]=(key, val) ⇒ Object



26
27
28
# File 'lib/gem_release/configuration.rb', line 26

def []=(key,val)
  options[key] = val
end

#conf_pathObject



22
23
24
# File 'lib/gem_release/configuration.rb', line 22

def conf_path
  File.expand_path(Dir.glob('**/.gemrelease').first.to_s)
end

#load_options!Object



12
13
14
15
16
17
18
19
20
# File 'lib/gem_release/configuration.rb', line 12

def load_options!
  @options = Hash.new { |hash, key| hash[key] = {} }
  if File.exist?(conf_path.to_s) && !File.directory?(conf_path.to_s)
    config_hash = YAML.load(File.read(conf_path))
    if config_hash
      @options.merge!(config_hash.deep_symbolize_keys!)
    end
  end
end