Class: RGitFlow::Config

Inherits:
Object show all
Defined in:
lib/rgitflow/config.rb

Constant Summary collapse

CONFIG_DIR =
Dir.pwd
CONFIG_FILE =
File.expand_path(CONFIG_DIR, '.rgitflow')
DEFAULT_OPTIONS =
{
    :master => 'master',
    :develop => 'develop',
    :feature => 'feature',
    :hotfix => 'hotfix',
    :release => 'release',
    :tag => 'v%s'
}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/rgitflow/config.rb', line 4

def options
  @options
end

Class Method Details

.loadObject



20
21
22
23
24
# File 'lib/rgitflow/config.rb', line 20

def self.load
  self.options = SymbolHash.new false
  options.update DEFAULT_OPTIONS
  options.update read_config_file
end

.read_config_fileObject



32
33
34
35
36
37
38
39
# File 'lib/rgitflow/config.rb', line 32

def self.read_config_file
  if File.file?(CONFIG_FILE)
    require 'yaml'
    YAML.load_file(CONFIG_FILE)
  else
    {}
  end
end

.saveObject



26
27
28
29
30
# File 'lib/rgitflow/config.rb', line 26

def self.save
  require 'yaml'
  Dir.mkdir(CONFIG_DIR) unless File.directory?(CONFIG_DIR)
  File.open(CONFIG_FILE, 'w') {|f| f.write(YAML.dump(options)) }
end