Class: AppConfig

Inherits:
Settingslogic
  • Object
show all
Defined in:
lib/yadecli/config/app_config.rb

Constant Summary collapse

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

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.composer_homeObject

Returns the value of attribute composer_home.



15
16
17
# File 'lib/yadecli/config/app_config.rb', line 15

def composer_home
  @composer_home
end

.config_pathObject

Returns the value of attribute config_path.



15
16
17
# File 'lib/yadecli/config/app_config.rb', line 15

def config_path
  @config_path
end

.yade_homeObject

Returns the value of attribute yade_home.



15
16
17
# File 'lib/yadecli/config/app_config.rb', line 15

def yade_home
  @yade_home
end

Class Method Details

.[](key) ⇒ Object



45
46
47
48
49
50
# File 'lib/yadecli/config/app_config.rb', line 45

def self.[](key)
  return @@yade_home if key == :yade_home
  return @@config_path if key == :config_path
  return @@composer_home if key == :composer_home
  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/yadecli/config/app_config.rb', line 18

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

.no_config_file?Boolean

no config

Returns:

  • (Boolean)


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

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

.write!Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/yadecli/config/app_config.rb', line 52

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

  d['url'] = self.url
  d['auth_url'] = self.auth_url
  d['username'] = self.username
  d['password'] = self.password
  d['access_token'] = self.access_token
  d['refresh_token'] = self.refresh_token
  d['expiration_time'] = self.expiration_time
  d['git_api_url'] = self.git_api_url
  d['git_username'] = self.git_username
  d['git_password'] = self.git_password
  d['git_token'] = self.git_token

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