Class: Lightning::CompletionMap
- Inherits:
-
Object
- Object
- Lightning::CompletionMap
- Defined in:
- lib/lightning/completion_map.rb
Overview
Maps completions (file basenames) and aliases to their full paths given a Bolt object’s globs.
Constant Summary
- DUPLICATE_DELIMITER =
'//'
Instance Attribute Summary
- - (Hash) alias_map readonly Maps aliases to full paths.
- - (Hash) map Maps file basenames to full paths.
Class Method Summary
- + (Array) ignore_paths Regular expression paths to ignore.
- + (Object) ignore_paths=(val) Sets ignore_paths.
Instance Method Summary
- - (String) [](completion) Fetches full path of file or alias.
- - (CompletionMap) initialize(*globs) constructor A new instance of CompletionMap.
- - (Array) keys List of unique basenames and aliases.
Constructor Details
- (CompletionMap) initialize(*globs)
A new instance of CompletionMap
20 21 22 23 24 25 |
# File 'lib/lightning/completion_map.rb', line 20 def initialize(*globs) = globs[-1].is_a?(Hash) ? globs.pop : {} globs.flatten! @map = create_globbed_map(globs) @alias_map = [:aliases] || {} end |
Instance Attribute Details
- (Hash) alias_map (readonly)
Maps aliases to full paths
18 19 20 |
# File 'lib/lightning/completion_map.rb', line 18 def alias_map @alias_map end |
- (Hash) map
Maps file basenames to full paths
16 17 18 |
# File 'lib/lightning/completion_map.rb', line 16 def map @map end |
Class Method Details
+ (Array) ignore_paths
Regular expression paths to ignore. By default paths ending in . or .. are ignored.
6 7 8 |
# File 'lib/lightning/completion_map.rb', line 6 def self.ignore_paths @ignore_paths ||= (Lightning.config[:ignore_paths] || []) + %w{\.\.?$} end |
+ (Object) ignore_paths=(val)
Sets ignore_paths
11 12 13 |
# File 'lib/lightning/completion_map.rb', line 11 def self.ignore_paths=(val) @ignore_paths = val end |
Instance Method Details
- (String) [](completion)
Fetches full path of file or alias
28 29 30 |
# File 'lib/lightning/completion_map.rb', line 28 def [](completion) @map[completion] || @alias_map[completion] end |
- (Array) keys
List of unique basenames and aliases
33 34 35 |
# File 'lib/lightning/completion_map.rb', line 33 def keys (@map.keys + @alias_map.keys).uniq end |