Class: Releasinator::ConfigHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/config_hash.rb

Instance Method Summary collapse

Constructor Details

#initialize(verbose, trace) ⇒ ConfigHash

Returns a new instance of ConfigHash.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/config_hash.rb', line 11

def initialize(verbose, trace)
  update({:releasinator_name => RELEASINATOR_NAME})
  update({:verbose => verbose})
  update({:trace => trace})

  require_file_name = "./.#{RELEASINATOR_NAME}.rb"
  begin 
    require require_file_name
  rescue LoadError
    is_git_already_clean = GitUtil.is_clean_git?
    puts "It looks like this is your first time using #{RELEASINATOR_NAME} on this project.".yellow
    puts "A default '#{CONFIG_FILE_NAME}' file has been created for you.".yellow
    out_file = File.new("#{CONFIG_FILE_NAME}", "w")
    out_file.write(DEFAULT_CONFIG)
    out_file.close
    require require_file_name
    
    # dpn't want to commit other files
    if is_git_already_clean
      puts "adding default #{CONFIG_FILE_NAME} to git".yellow
      CommandProcessor.command("git add #{CONFIG_FILE_NAME}")
      CommandProcessor.command("git commit -m \"#{RELEASINATOR_NAME}: add default config\"")
    end
  end

  configatron.lock!
  loaded_config_hash = configatron.to_h

  update(loaded_config_hash)

  puts "loaded config:" + self.to_s if verbose
end

Instance Method Details

#base_dirObject



49
50
51
52
# File 'lib/config_hash.rb', line 49

def base_dir
  return self[:base_docs_dir] if self.has_key?(:base_docs_dir)
  '.'
end

#doc_target_dirObject



54
55
56
57
# File 'lib/config_hash.rb', line 54

def doc_target_dir 
  return self[:doc_target_dir] if self.has_key?(:doc_target_dir)
  '.'
end

#use_git_flowObject



44
45
46
47
# File 'lib/config_hash.rb', line 44

def use_git_flow()
  return self[:use_git_flow] if self.has_key? :use_git_flow
  false
end