Class: TTYCoke::Config
Instance Method Summary collapse
- #file ⇒ Object
- #find_program(prgm) ⇒ Object
-
#initialize(config_file = ENV['HOME'] + "/.ttycokerc") ⇒ Config
constructor
A new instance of Config.
Methods included from Log
#log_check_child_exit_status, #log_debug, #log_error, #log_rescue
Constructor Details
#initialize(config_file = ENV['HOME'] + "/.ttycokerc") ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/ttycoke/config.rb', line 8 def initialize(config_file=ENV['HOME'] + "/.ttycokerc") log_rescue(self, __method__, caller, TTYCoke::Errors::YamlSyntaxError) { @files = { init: config_file, tty_coke: File.dirname(__FILE__) + '/../../config/config.yaml' } raw_yaml = YAML::load(File.open(File.(file))) paths = raw_yaml.fetch('import') importer = File.dirname(file) @config = TTYCoke::Import.import(raw_yaml, paths, {}, importer) } end |
Instance Method Details
#file ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/ttycoke/config.rb', line 29 def file log_rescue(self, __method__, caller) { if FileTest.exist?(@files.fetch(:init)) @files.fetch(:init) else @files.fetch(:tty_coke) end } end |
#find_program(prgm) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/ttycoke/config.rb', line 21 def find_program prgm if @config.keys.include?(prgm) @config.fetch(prgm) else false end end |