# File lib/lingo/config.rb, line 33 def initialize(*args) @cli, @opts = CLI.new, {} @cli.execute(*args) @cli.options.each { |key, val| @opts[key.to_s] = val } load_config('language', :lang) load_config('config') Array(self['meeting/attendees']).each { |a| r = a['text_reader'] || a['textreader'] or next # DEPRECATE textreader f = @cli.files if i = r['files'] r['files'] = i.strip == '$(files)' ? f : i.split(SEP_RE) elsif !f.empty? r['files'] = f end break } end
# File lib/lingo/config.rb, line 57 def [](key) key_to_nodes(key).inject(@opts) { |hash, node| hash[node] } end
# File lib/lingo/config.rb, line 61 def []=(key, val) nodes = key_to_nodes(key); node = nodes.pop (self[nodes_to_key(nodes)] ||= {})[node] = val end
# File lib/lingo/config.rb, line 78 def quit(*args) @cli.send(:quit, *args) end
# File lib/lingo/config.rb, line 74 def stderr @cli.stderr end
# File lib/lingo/config.rb, line 66 def stdin @cli.stdin end
# File lib/lingo/config.rb, line 70 def stdout @cli.stdout end
# File lib/lingo/config.rb, line 84 def key_to_nodes(key) key.downcase.split('/') end
# File lib/lingo/config.rb, line 92 def load_config(key, type = key.to_sym) file = Lingo.find(type, @opts[key], &method(:quit)) @opts.update(File.open(file, encoding: ENC, &YAML.method(:load))) end
# File lib/lingo/config.rb, line 88 def nodes_to_key(nodes) nodes.join('/') end