Module: Flucti::Parameters

Extended by:
Parameters, Utilities
Included in:
Parameters
Defined in:
lib/flucti/parameters.rb

Constant Summary

Constants included from Utilities

Utilities::SUPPORT_EMAIL_ADDR

Constants included from Utilities::Miscellaneous

Utilities::Miscellaneous::BOGUS_ERROR_MESSAGES

Instance Method Summary collapse

Methods included from Utilities::Miscellaneous

#clean_name, #command, #error!, #sh, #try_save

Methods included from Utilities::TaskPacking

#import_pack

Methods included from Utilities::UserInterface

#confirm, #puts_list, #puts_long, #puts_subtitle, #puts_title, #qcommand, #quote, #terminal_width

Instance Method Details

#data_storeObject



18
19
20
# File 'lib/flucti/parameters.rb', line 18

def data_store
  @data_store ||= store_dir / 'parameters.yml'
end

#fetch(key) ⇒ Object



22
23
24
# File 'lib/flucti/parameters.rb', line 22

def fetch(key)
  cache[key.to_s]
end

#store(key, value) ⇒ Object



26
27
28
29
# File 'lib/flucti/parameters.rb', line 26

def store(key, value)
  cache[key.to_s] = value
  data_store.open("w") { |f| f << YAML.dump(cache) }
end

#store_dirObject



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/flucti/parameters.rb', line 6

def store_dir
  @store_dir ||= begin
    options = []
    options << Pathname(ENV['APPDATA']) / 'Flucti' if ENV['APPDATA']
    options << Pathname(ENV['HOME']) / '.flucti' if ENV['HOME']
    located = options.find { |dir| dir.directory? } || options.find { |dir| dir.dirname.directory? }
    located ||= Pathname(Dir.tmpdir) / 'flucti'
    located.mkpath
    located
  end
end