Class: Minjector::Config

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

Class Method Summary collapse

Class Method Details

.exists?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/minjector/config.rb', line 26

def exists?
  File.exist?(file)
end

.fileObject



8
9
10
# File 'lib/minjector/config.rb', line 8

def file
  File.expand_path(File.join("~", ".minjector", "config"))
end

.readObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/minjector/config.rb', line 12

def read
  config = {}

  File.open(file, "r") do |f|
    config = YAML.load(f)
  end

  config[:buckets].each do |bucket|
    bucket[:path] = File.expand_path(bucket[:path])
  end

  config
end

.write(config) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/minjector/config.rb', line 30

def write(config)
  unless exists?
    FileUtils.mkdir_p(File.dirname(file))
  end

  File.open(file, "w") do |f|
    return YAML.dump(config, f)
  end
end