Module: Dotpack::Config

Defined in:
lib/dotpack/config.rb

Constant Summary collapse

BASE_DIR =
Dir.home + '/.dotpack'
FLAVORS_PATH =
BASE_DIR + '/flavors'

Class Method Summary collapse

Class Method Details

.flavor(f) ⇒ Object



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

def self.flavor(f)
  cache_flavors
  @flavors[f]
end

.flavorsObject



28
29
30
31
# File 'lib/dotpack/config.rb', line 28

def self.flavors
  cache_flavors
  @flavors.clone
end

.remove_flavor(f) ⇒ Object



23
24
25
26
# File 'lib/dotpack/config.rb', line 23

def self.remove_flavor(f)
  cache_flavors
  @flavors.delete f
end

.saveObject



33
34
35
# File 'lib/dotpack/config.rb', line 33

def self.save
  save_flavors
end

.save_flavorsObject



37
38
39
40
41
42
# File 'lib/dotpack/config.rb', line 37

def self.save_flavors
  return unless @flavors_cached
  File.open(FLAVORS_PATH, 'w') do |file|
    file.puts JSON.unparse(@flavors)
  end
end

.set_flavor(f, value = '') ⇒ Object



17
18
19
20
21
# File 'lib/dotpack/config.rb', line 17

def self.set_flavor(f, value='')
  value = '' if value.nil?
  cache_flavors
  @flavors[f] = value
end