Module: Config

Defined in:
lib/canuby/config.rb

Class Method Summary collapse

Class Method Details

.loadObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/canuby/config.rb', line 24

def self.load
  # skip if run trough rake or bundler
  args = ArgParser.min(ARGV)
  if ENV['Testing'] != 'true' && File.exist?(args.yml_file)
    $options = OpenStruct.new(args.to_h.merge!(YAML.load_file(args.yml_file)))
  else
    default = { 'projects' => {
      'Googletest' => { 'url' => 'https://github.com/google/googletest', 'version' => '1.0.0', 'project_file' => 'googletest-distribution',
                        'output_dir' => 'googlemock/gtest', 'outputs' => ['gtest.lib', 'gtest_main.lib'] }, \
      'Dummy' => { 'url' => 'https://github.com/google/googletest', 'version' => '1.0.0', 'project_file' => 'googletest-distribution',
                   'output_dir' => 'googlemock/gtest', 'outputs' => ['gtest.lib'] }, \
      'Dummy2' => { 'url' => 'https://github.com/google/googletest', 'version' => '1.0.0', 'project_file' => 'googletest-distribution',
                    'output_dir' => 'googlemock/gtest', 'outputs' => ['gtest_main.lib'] }
    } }
    $options = OpenStruct.new(args.to_h.merge!(default))
  end
end

.writeObject



42
43
44
45
46
47
48
49
# File 'lib/canuby/config.rb', line 42

def self.write
  write_config = $options.to_h
  [:target, :yml_file].each do |key|
    write_config.delete(key)
  end

  File.write('canuby.yml', write_config.to_yaml)
end