Class: Yade::Common::Config::DomainConfig

Inherits:
Settingslogic
  • Object
show all
Defined in:
lib/yade/common/config/domain_config.rb

Constant Summary collapse

@@yade_home =
File.join(File.expand_path('~'), '.yade')
@@config_path =
File.join(@@yade_home, 'yade-domain-config.yml')

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.config_pathObject

Returns the value of attribute config_path.



15
16
17
# File 'lib/yade/common/config/domain_config.rb', line 15

def config_path
  @config_path
end

.yade_homeObject

Returns the value of attribute yade_home.



15
16
17
# File 'lib/yade/common/config/domain_config.rb', line 15

def yade_home
  @yade_home
end

Class Method Details

.[](key) ⇒ Object



45
46
47
48
49
50
# File 'lib/yade/common/config/domain_config.rb', line 45

def self.[](key)
  return @@yade_home if key == :yade_home
  return @@config_path if key == :config_path

  super
end

.load!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/yade/common/config/domain_config.rb', line 18

def self.load!
  if no_config_file?
    $stderr.puts <<-HELP
******** You haven't set up your Yade settings file. **********
Please do the following:
1. Create the yade base directory and download the yade-domain-config.yml example:
mkdir -p ~/.yade
cd ~/.yade
curl --header 'PRIVATE-TOKEN: <your token>' \
   'http://gitlab.dzbw.de/client/v4/projects/366/repository/files/yade-domain-config%2Eyml%2Eexample/raw?ref=master' \
   -o yade-domain-config.yml
2. Have a look at the settings in that file and change it according to your needs.
    HELP
    Process.exit(1)
  end

  super

end

.no_config_file?Boolean

no config

Returns:

  • (Boolean)


39
40
41
# File 'lib/yade/common/config/domain_config.rb', line 39

def self.no_config_file?
  !File.exists?(@source)
end

.write!Object



52
53
54
55
56
57
58
59
60
# File 'lib/yade/common/config/domain_config.rb', line 52

def self.write!
  d = YAML.load_file(@@config_path)

  d['yade_bootstrap_repo_url'] = self.yade_bootstrap_repo_url
  d['yade_bootstrap_repo_branch'] = self.yade_bootstrap_repo_branch
  d['yade_bootstrap_puppet_modules'] = self.yade_bootstrap_puppet_modules

  File.open(@@config_path, 'w') { |f| f.write d.to_yaml }
end