Module: FWToolkit::Config

Extended by:
Config
Includes:
ConfigFile
Included in:
Config, Rake::CITask, Rake::TestTask, Rake::XcodeTask
Defined in:
lib/fwtoolkit/config.rb

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_fileObject



12
13
14
# File 'lib/fwtoolkit/config.rb', line 12

def self.base_file
  File.join(File.dirname(__FILE__), 'config', 'config.sample')
end

.config_fileObject



8
9
10
# File 'lib/fwtoolkit/config.rb', line 8

def self.config_file
  File.join(ENV['HOME'], '.fwtoolkit', 'config')
end

.config_pathObject



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

def self.config_path
  File.dirname(config_file)
end

Instance Method Details

#conf_item_missing(name) ⇒ Object

Raises:

  • (NoMethodError)


45
46
47
# File 'lib/fwtoolkit/config.rb', line 45

def conf_item_missing(name)
  raise NoMethodError, "Please provide a valid '#{name}' by editing the conf file at path: #{config_file}"
end

#load!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fwtoolkit/config.rb', line 20

def load!
  unless File.exists? config_file
    puts "Config file not found"
    unless File.exists? config_path
      puts "Creating basic path"
      FileUtils.mkpath config_path
    end
    FileUtils.copy_file base_file, config_file
  end

  default_config = {  :organization_name => 'Future Workshops',
                      :ruby_version => '2.6.3',
                      :target_platform => '13.1',
                      :ci_server_url => 'https://app.bitrise.io/dashboard',
                      :artifacts_tmp_dir => '/tmp/fwtoolkit/artifacts' }

  load_config! config_file
end

#validate_configObject



39
40
41
42
43
# File 'lib/fwtoolkit/config.rb', line 39

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