Sha256: de97767a6049fb13bba362a0c144c147d00be325c03ac6c7a539d04b8d61f901
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
module Lightning::Config def load_config @config = setup_config end def config @config ||= setup_config end def setup_config hash = read_config_file configure_commands_and_paths(hash) hash end def read_config_file(config_file=nil) default_config = {:shell=>'bash', :generated_file=>File.expand_path(File.join('~', '.lightning_completions'))} config_file ||= File.exists?('lightning.yml') ? 'lightning.yml' : File.expand_path(File.join("~",".lightning.yml")) hash = YAML::load(File.new(config_file)) default_config.merge(hash.symbolize_keys) end def config_command(name) config[:commands].find {|e| e['name'] == name} || {} end def commands_to_bolt_key(map_to_command, new_command) "#{map_to_command}-#{new_command}" end def configure_commands_and_paths(hash) hash[:paths] ||= {} hash[:commands].each do |e| #mapping a referenced path if e['paths'].is_a?(String) e['bolt_key'] = e['paths'].dup end #create a path entry + key if none exists if e['bolt_key'].nil? #extract command in case it has options after it e['map_to'] =~ /\s*(\w+)/ bolt_key = commands_to_bolt_key($1, e['name']) e['bolt_key'] = bolt_key hash[:paths][bolt_key] = e['paths'] || [] end end hash end def ignore_paths unless @ignore_paths @ignore_paths = [] @ignore_paths += config[:ignore_paths] if config[:ignore_paths] && !config[:ignore_paths].empty? end @ignore_paths end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cldwalker-lightning-0.1.2 | lib/lightning/config.rb |