Class: Cocoadex::CompletionHelper
- Inherits:
-
Object
- Object
- Cocoadex::CompletionHelper
- Defined in:
- lib/cocoadex/tools/completion_helper.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
Class Method Summary collapse
-
.clear_tags ⇒ Object
Clear all tags in file.
-
.generate_tags! ⇒ Object
Build a tags file from existing kewords.
-
.tags ⇒ Object
Tags loaded from file.
-
.tags_path ⇒ Object
Tags file location.
Instance Method Summary collapse
-
#initialize(command) ⇒ CompletionHelper
constructor
A new instance of CompletionHelper.
- #matches ⇒ Object
- #scope_matches ⇒ Object
Constructor Details
#initialize(command) ⇒ CompletionHelper
Returns a new instance of CompletionHelper.
6 7 8 |
# File 'lib/cocoadex/tools/completion_helper.rb', line 6 def initialize(command) @command = command end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
4 5 6 |
# File 'lib/cocoadex/tools/completion_helper.rb', line 4 def command @command end |
Class Method Details
.clear_tags ⇒ Object
Clear all tags in file
43 44 45 |
# File 'lib/cocoadex/tools/completion_helper.rb', line 43 def self. Serializer.write_text(, "") end |
.generate_tags! ⇒ Object
Build a tags file from existing kewords
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/cocoadex/tools/completion_helper.rb', line 48 def self. logger.info "Generating tags file..." datastore = Tokenizer.tokens.sort_by {|k| k.term } text = datastore.map {|k| k.term }.join("\n") + "\n" # Parse class elements and store tags for scope delimiters datastore.select {|k| k.type == :class }.each_slice(50).to_a.each do |batch| Tokenizer.untokenize(batch).each do |klass| logger.debug("Tagging #{klass.name} properties") text << tagify( klass.name, (klass.properties+klass.methods.to_a), Keyword::CLASS_PROP_DELIM) text << tagify( klass.name, klass.class_methods, Keyword::CLASS_METHOD_DELIM) text << tagify( klass.name, klass.instance_methods, Keyword::INST_METHOD_DELIM) end end Serializer.write_text(, text.strip) end |
.tags ⇒ Object
Tags loaded from file
32 33 34 35 36 37 38 39 40 |
# File 'lib/cocoadex/tools/completion_helper.rb', line 32 def self. @tags ||= begin if File.exists?() IO.read(, :mode => 'rb').split("\n") else [] end end end |
.tags_path ⇒ Object
Tags file location
27 28 29 |
# File 'lib/cocoadex/tools/completion_helper.rb', line 27 def self. Cocoadex.config_file("tags") end |
Instance Method Details
#matches ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/cocoadex/tools/completion_helper.rb', line 10 def matches scope = Keyword.get_scope(command) CompletionHelper..select do |tag| tag[0, command.length] == command && Keyword.get_scope(tag) == scope end end |
#scope_matches ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/cocoadex/tools/completion_helper.rb', line 18 def scope_matches scope = Keyword.get_scope(command) CompletionHelper..select do |tag| Keyword.get_scope(tag) == scope end end |