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 collapse
- DUPLICATE_DELIMITER =
'//'
Instance Attribute Summary collapse
-
#alias_map ⇒ Hash
readonly
Maps aliases to full paths.
-
#map ⇒ Hash
Maps file basenames to full paths.
Class Method Summary collapse
-
.ignore_paths ⇒ Array
Regular expression paths to ignore.
-
.ignore_paths=(val) ⇒ Object
Sets ignore_paths.
Instance Method Summary collapse
-
#[](completion) ⇒ String
Fetches full path of file or alias.
-
#initialize(*globs) ⇒ CompletionMap
constructor
A new instance of CompletionMap.
-
#keys ⇒ Array
List of unique basenames and aliases.
Constructor Details
#initialize(*globs) ⇒ CompletionMap
Returns 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
#alias_map ⇒ Hash (readonly)
Returns Maps aliases to full paths.
18 19 20 |
# File 'lib/lightning/completion_map.rb', line 18 def alias_map @alias_map end |
#map ⇒ Hash
Returns Maps file basenames to full paths.
16 17 18 |
# File 'lib/lightning/completion_map.rb', line 16 def map @map end |
Class Method Details
.ignore_paths ⇒ Array
Returns 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 |
.ignore_paths=(val) ⇒ Object
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
#[](completion) ⇒ String
Returns 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 |
#keys ⇒ Array
Returns 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 |