Class: Harvixture::Config

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

Class Method Summary collapse

Class Method Details

.filenameObject



30
31
32
# File 'lib/harvixture/config.rb', line 30

def filename
  File.join(home, '.harvixture_config.yml')
end

.output_dirObject



10
11
12
# File 'lib/harvixture/config.rb', line 10

def output_dir
  values['output_dir']
end

.rails_envObject



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

def rails_env
  values['rails_env']
end

.request_pathObject



7
8
9
# File 'lib/harvixture/config.rb', line 7

def request_path
  values['request_path']
end

.update(attributes = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/harvixture/config.rb', line 17

def update(attributes = {})
  new_values = {
    'output_dir' => attributes[:output_dir] || attributes['output_dir'] || output_dir,
    'rails_env' => attributes[:rails_env] || attributes['rails_env'] || rails_env,
    'request_path' => attributes[:request_path] || attributes['request_path'] || request_path,
    'user_id' => attributes[:user_id] || attributes['user_id'] || user_id,
  }
  File.open(filename, 'w+') {|f| f.puts YAML.dump(new_values)}
  Dir.glob(File.join(output_dir, '*.yml')).each {|f| File.delete(f) if File.exist?(f)}
  @values = nil
  values
end

.user_idObject



13
14
15
# File 'lib/harvixture/config.rb', line 13

def user_id
  values['user_id']
end