radar-lookup 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  * `lookup ActiveRecord::Base#destro` (returns three methods, uses methods beginning with "destroy")
8
8
  * `lookup ActiveRecord::Base#d` (tells you to be more specific, because it can't open 35 tabs at once)
9
9
  * `lookup ActiveRecord::Base` (returns a single consant)
10
- * `lookup Acv::Base` (returns six constants, because it does a fuzzy match)
10
+ * `lookup av::Base` ("av" maps to ActionView, so returns ActionView::Base constant)
11
11
 
12
12
  ## Options
13
13
 
data/Rakefile CHANGED
@@ -29,11 +29,6 @@ spec = Gem::Specification.new do |s|
29
29
 
30
30
  s.require_path = 'lib'
31
31
  s.autorequire = GEM
32
- (Dir.entries("doc") - ['..', '.']).each do |file|
33
- FileUtils.rm("doc/#{file}")
34
- end
35
- Dir.delete("doc")
36
- Dir.mkdir("doc")
37
32
  s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,spec,bin,doc}/**/*")
38
33
  end
39
34
 
data/lib/lookup.rb CHANGED
@@ -100,15 +100,20 @@ class APILookup
100
100
  # If the constant argument is passed, look it up within the scope of the constant.
101
101
  def find_method(name, constant=nil)
102
102
  methods = []
103
+ # Full match
103
104
  methods = Entry.find_all_by_name(name.to_s)
105
+ # Start match
104
106
  methods = Entry.all(:conditions => ["name LIKE ?", name.to_s + "%"]) if methods.empty?
105
- methods = Entry.find_by_sql("select * from entries where name LIKE '%#{name.split("").join("%")}%'") if methods.empty?
107
+ # Wildcard substitution
108
+ methods = Entry.find_by_sql("select * from entries where name LIKE '#{name.to_s.gsub("*", "%")}'") if methods.empty?
109
+ # Fuzzy match
110
+ methods = Entry.find_by_sql("select * from entries where name LIKE '%#{name.to_s.split("").join("%")}%'") if methods.empty?
106
111
 
107
112
  # Weight the results, last result is the first one we want shown first
108
113
  methods = methods.sort_by(&:weighting)
109
114
 
110
115
  if constant
111
- constants = find_constant(constant, name)
116
+ constants = find_constant(constant)
112
117
  methods = methods.select { |m| constants.include?(m.constant) }
113
118
  end
114
119
  methods
@@ -118,7 +123,7 @@ class APILookup
118
123
  msg = msg.split(" ")[0..-1].flatten.map { |a| a.split("#") }.flatten!
119
124
 
120
125
  # It's a constant! Oh... and there's nothing else in the string!
121
- first=smart_rails_constant_substitutions(msg.first)
126
+ first = smart_rails_constant_substitutions(msg.first)
122
127
  if /^[A-Z]/.match(first) && msg.size == 1
123
128
  find_constant(first)
124
129
  # It's a method!
data/lib/models.rb CHANGED
@@ -12,7 +12,7 @@ class APILookup
12
12
  puts "to store it's lookup database."
13
13
  raise MissingHome, "HOME must be set to know where to store our local db."
14
14
  end
15
-
15
+
16
16
  LookupBase.establish_connection(:adapter => "sqlite3",
17
17
  :database => File.join(ENV["HOME"],".lookup", "lookup.sqlite3"))
18
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radar-lookup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
@@ -31,11 +31,9 @@ files:
31
31
  - lib/config.rb
32
32
  - lib/lookup.rb
33
33
  - lib/models.rb
34
- - spec/lookup_spec.rb
35
- - spec/spec_helper.rb
36
34
  - bin/lookup
37
35
  has_rdoc: true
38
- homepage: http://gitpilot.com
36
+ homepage: http://frozenplague.net
39
37
  post_install_message:
40
38
  rdoc_options: []
41
39
 
data/spec/lookup_spec.rb DELETED
@@ -1,32 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
-
3
- describe "Lookup" do
4
- before do
5
- # So it outputs text for us.
6
- OPTIONS.merge!({ :text => true })
7
- end
8
-
9
- it "should be able to find a constant" do
10
- Lookup.do("ActiveRecord::Base")
11
- end
12
-
13
- it "should be able to find a constant and a method (using hash symbol)" do
14
- Lookup.do("ActiveRecord::Base#new")
15
- end
16
-
17
- it "should be able to find a constant and a method (using space)" do
18
- Lookup.do("ActiveRecord::Base new")
19
- end
20
-
21
- it "should be able to do a fuzzy match on the method" do
22
- Lookup.do("ActiveRecord::Base#destry")
23
- end
24
-
25
- it "should prompt the user to be more specific" do
26
- Lookup.do("be")
27
- end
28
-
29
- it "should be able to do a fuzzy match on the constant and method" do
30
- Lookup.do("AR::B#destroy")
31
- end
32
- end
data/spec/spec_helper.rb DELETED
@@ -1,3 +0,0 @@
1
- $TESTING=true
2
- $:.push File.join(File.dirname(__FILE__), '..', 'lib')
3
- require 'lookup'