Class: Push2heroku::ConfigLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/push2heroku/config_loader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ ConfigLoader

Returns a new instance of ConfigLoader.



6
7
8
9
# File 'lib/push2heroku/config_loader.rb', line 6

def initialize(filename)
  @filename = filename
  @hash = load_config
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



4
5
6
# File 'lib/push2heroku/config_loader.rb', line 4

def filename
  @filename
end

#hashObject (readonly)

Returns the value of attribute hash.



4
5
6
# File 'lib/push2heroku/config_loader.rb', line 4

def hash
  @hash
end

Instance Method Details

#named_branchesObject



18
19
20
# File 'lib/push2heroku/config_loader.rb', line 18

def named_branches
  hash.keys - ['common']
end

#settings(branch_name) ⇒ Object



11
12
13
14
15
16
# File 'lib/push2heroku/config_loader.rb', line 11

def settings(branch_name)
  common_hash = hash['common'] || {}
  env_hash = hash[branch_name.to_s] || {}
  final_hash = common_hash.deep_merge(env_hash)
  Hashr.new(final_hash)
end