Module: FWToolkit::Config
Instance Attribute Summary
Attributes included from ConfigFile
#default_config
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from ConfigFile
#config, #configure, #load_config!, #load_config_hash!, #merge_config, #method_missing
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class FWToolkit::ConfigFile
Class Method Details
.base_file ⇒ Object
20
21
22
|
# File 'lib/fwtoolkit/config.rb', line 20
def self.base_file
File.join(File.dirname(__FILE__), 'config', '.fwtoolkitconfig.sample')
end
|
.base_path ⇒ Object
8
9
10
|
# File 'lib/fwtoolkit/config.rb', line 8
def self.base_path
ENV['CONFIG_PATH'] || ENV['HOME']
end
|
.config_file ⇒ Object
12
13
14
|
# File 'lib/fwtoolkit/config.rb', line 12
def self.config_file
File.join(base_path, '.fwtoolkitconfig')
end
|
.config_path ⇒ Object
28
29
30
|
# File 'lib/fwtoolkit/config.rb', line 28
def self.config_path
File.dirname(config_file)
end
|
.old_config_path ⇒ Object
24
25
26
|
# File 'lib/fwtoolkit/config.rb', line 24
def self.old_config_path
File.dirname(old_file)
end
|
.old_file ⇒ Object
16
17
18
|
# File 'lib/fwtoolkit/config.rb', line 16
def self.old_file
File.join(base_path, '.fwtoolkit', 'config')
end
|
Instance Method Details
#conf_item_missing(name) ⇒ Object
66
67
68
|
# File 'lib/fwtoolkit/config.rb', line 66
def conf_item_missing(name)
raise NoMethodError, "Please provide a valid '#{name}' by editing the conf file at path: #{config_file}"
end
|
#load! ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/fwtoolkit/config.rb', line 32
def load!
unless File.exist? config_file
puts "Config file not found"
unless File.exist? config_path
puts "Creating basic path"
FileUtils.mkpath config_path
end
if File.exist? old_file
puts "Moving old configuration file to new path"
FileUtils.copy_file old_file, config_file
FileUtils.remove_file old_file
FileUtils.remove_dir old_config_path
else
FileUtils.copy_file base_file, config_file
end
end
default_config = { :organization_name => 'Future Workshops',
:target_platform => '13.1',
:ci_server_url => 'https://app.bitrise.io/dashboard',
:artifacts_tmp_dir => '/tmp/fwtoolkit/artifacts' }
load_config! config_file
end
|
#validate_config ⇒ Object
60
61
62
63
64
|
# File 'lib/fwtoolkit/config.rb', line 60
def validate_config
unless @config.has_key?(:developer_name)
raise NameError, "Please configure fwtoolkit by editing the file at path: #{config_file}, and inform your name on developer_name"
end
end
|