Sha256: 33c7b4c54d8f0cdc85259501375edf4955801eae4cf72c5b5d72a922d50549de

Contents?: true

Size: 786 Bytes

Versions: 1

Compression:

Stored size: 786 Bytes

Contents

# A bolt, referenced by a key, is the basic unit needed to access a lightning command's functionality.
class Lightning
  class Bolt
    attr_reader :key
    def initialize(bolt_key)
      @key = bolt_key
    end
    
    def completions
      path_map.keys
    end
    
    def path_map
      @path_map ||= Lightning::PathMap.new(self.paths)
    end
    
    def resolve_completion(basename)
      basename = basename.join(" ") if basename.is_a?(Array)
      basename.gsub!(/\s*#{TEST_FLAG}\s*/,'')
      #TODO
      # if (regex = Lightning.config_command(Lightning.current_command)['completion_regex'])
      #   basename = basename[/#{regex}/]
      # end
      path_map[basename] || ''
    end
    
    def paths
      @paths ||= Lightning.config[:paths][key] || []
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cldwalker-lightning-0.1.2 lib/lightning/bolt.rb