Class: Configuration

Inherits:
Object
  • Object
show all
Includes:
Meta
Defined in:
lib/configuration.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Meta

#create_method

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



9
10
11
12
13
14
15
16
17
# File 'lib/configuration.rb', line 9

def initialize()
  create_config if false == File.exists?(Configuration.config_path)

  YAML.load_file(Configuration.config_path).each do |key, value|
    create_method(key) {
      value
    }
  end
end

Class Method Details

.config_pathObject



35
36
37
# File 'lib/configuration.rb', line 35

def config_path()
  File.dirname(__FILE__) + '/config.yml'
end


39
40
41
42
43
44
45
46
47
# File 'lib/configuration.rb', line 39

def print()
  if !File.exists?(config_path)
    puts "jira-cards has not been configured yet"
    exit 1
  end
  YAML.load_file(Configuration.config_path).each do |key, value|
    puts "#{key}: #{value}"
  end
end

.reset!(path) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/configuration.rb', line 21

def reset!(path)
  if path != ""
    if !File.exists?(path)
      puts "Config file #{path} does not exist"
      exit 1
    end
    File.delete(config_path) if File.exists?(config_path)
    File.copy(path, config_path)
  else
    File.delete(config_path) if File.exists?(config_path)
    Configuration.new
  end
end