Class: Promote::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/promote/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.


3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/promote/config.rb', line 3

def initialize(options = {})
  options.each do |k, v|
  	self.send("#{k}=", v) if self.respond_to?(k)
  end
  self.repo_root ||= Dir.pwd
  self.cookbook_directory ||= File.join(repo_root, "cookbooks")
  self.environment_directory ||= File.join(repo_root, "environments")
  self.data_bag_directory ||= File.join(repo_root, "data_bags")
  self.role_directory ||= File.join(repo_root, "roles")
  self.temp_directory ||= "/tmp/promote"
  self.bags ||= ['secrets_*']
end

Instance Attribute Details

#bagsObject

Returns the value of attribute bags


42
43
44
# File 'lib/promote/config.rb', line 42

def bags
  @bags
end

#chef_server_urlObject

Returns the value of attribute chef_server_url


41
42
43
# File 'lib/promote/config.rb', line 41

def chef_server_url
  @chef_server_url
end

#client_keyObject

Returns the value of attribute client_key


40
41
42
# File 'lib/promote/config.rb', line 40

def client_key
  @client_key
end

#cookbook_directoryObject

Returns the value of attribute cookbook_directory


34
35
36
# File 'lib/promote/config.rb', line 34

def cookbook_directory
  @cookbook_directory
end

#data_bag_directoryObject

Returns the value of attribute data_bag_directory


36
37
38
# File 'lib/promote/config.rb', line 36

def data_bag_directory
  @data_bag_directory
end

#environment_directoryObject

Returns the value of attribute environment_directory


35
36
37
# File 'lib/promote/config.rb', line 35

def environment_directory
  @environment_directory
end

#node_nameObject

Returns the value of attribute node_name


39
40
41
# File 'lib/promote/config.rb', line 39

def node_name
  @node_name
end

#repo_rootObject

Returns the value of attribute repo_root


33
34
35
# File 'lib/promote/config.rb', line 33

def repo_root
  @repo_root
end

#role_directoryObject

Returns the value of attribute role_directory


37
38
39
# File 'lib/promote/config.rb', line 37

def role_directory
  @role_directory
end

#temp_directoryObject

Returns the value of attribute temp_directory


38
39
40
# File 'lib/promote/config.rb', line 38

def temp_directory
  @temp_directory
end

Instance Method Details

#reset_temp_dirObject


16
17
18
19
# File 'lib/promote/config.rb', line 16

def reset_temp_dir
  FileUtils.rm_rf(temp_directory) if Dir.exist?(temp_directory)
  Dir.mkdir(temp_directory)
end

#to_hashObject


21
22
23
24
25
26
27
# File 'lib/promote/config.rb', line 21

def to_hash
  hash = {}
  instance_variables.each do |key|
    hash[key[1..-1].to_sym] = instance_variable_get key
  end
  hash
end

#to_sObject


29
30
31
# File 'lib/promote/config.rb', line 29

def to_s
  to_hash.to_s
end