lookup 0.2.2 → 0.3.0
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/Rakefile +20 -1
- data/lib/lookup.rb +15 -12
- data/spec/lookup_spec.rb +8 -0
- data/spec/regressions_spec.rb +8 -0
- data/spec/spec_helper.rb +7 -1
- metadata +4 -2
data/Rakefile
CHANGED
@@ -27,4 +27,23 @@ Jeweler::Tasks.new do |s|
|
|
27
27
|
s.autorequire = "lookup"
|
28
28
|
s.files = %w(LICENSE README.md Rakefile TODO) + Dir.glob("{lib,spec,bin,doc}/**/*")
|
29
29
|
end
|
30
|
-
Jeweler::GemcutterTasks.new
|
30
|
+
Jeweler::GemcutterTasks.new
|
31
|
+
|
32
|
+
begin
|
33
|
+
require 'spec'
|
34
|
+
rescue LoadError
|
35
|
+
require 'rubygems'
|
36
|
+
require 'spec'
|
37
|
+
end
|
38
|
+
|
39
|
+
require 'spec/rake/spectask'
|
40
|
+
desc 'Default: run unit tests.'
|
41
|
+
task :default => :spec
|
42
|
+
|
43
|
+
desc "Run the specs under spec"
|
44
|
+
Spec::Rake::SpecTask.new do |t|
|
45
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
46
|
+
t.libs = %w(lib spec)
|
47
|
+
t.spec_opts << "-c"
|
48
|
+
t.ruby_opts << "-rubygems"
|
49
|
+
end
|
data/lib/lookup.rb
CHANGED
@@ -81,19 +81,22 @@ class APILookup
|
|
81
81
|
end
|
82
82
|
|
83
83
|
def smart_rails_constant_substitutions(name)
|
84
|
-
parts=name.split("::").map { |x| x.split(":")}.flatten
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
84
|
+
parts = name.split("::").map { |x| x.split(":")}.flatten
|
85
|
+
if parts.first
|
86
|
+
rep = case parts.first.downcase
|
87
|
+
# so it falls back on fuzzy and matches AR as well as ActiveResource
|
88
|
+
when "ar" then "ActiveRecord"
|
89
|
+
when "ares" then "ActiveResource"
|
90
|
+
when "am" then "ActionMailer"
|
91
|
+
when "as" then "ActiveSupport"
|
92
|
+
when "ac" then "ActionController"
|
93
|
+
when "av" then "ActionView"
|
94
|
+
else
|
95
|
+
parts.first
|
96
|
+
end
|
97
|
+
return ([rep] + parts[1..-1]).join("::")
|
95
98
|
end
|
96
|
-
|
99
|
+
name
|
97
100
|
end
|
98
101
|
|
99
102
|
# Find an entry.
|
data/spec/lookup_spec.rb
CHANGED
@@ -41,4 +41,12 @@ describe "Lookup" do
|
|
41
41
|
APILookup.search("ar::base#new").should eql([find_entry("ActiveRecord::Base", "new")])
|
42
42
|
end
|
43
43
|
|
44
|
+
it "should be able to find it if a hash-symbol is specified" do
|
45
|
+
APILookup.search("#today?").should eql([
|
46
|
+
find_entry("ActiveSupport::CoreExtensions::Date::Calculations", "today?"),
|
47
|
+
find_entry("ActiveSupport::TimeWithZone", "today?"),
|
48
|
+
find_entry("ActiveSupport::CoreExtensions::Time::Calculations", "today?")
|
49
|
+
])
|
50
|
+
end
|
51
|
+
|
44
52
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Bigg
|
@@ -9,7 +9,7 @@ autorequire: lookup
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-12-28 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- lib/methods
|
46
46
|
- lib/models.rb
|
47
47
|
- spec/lookup_spec.rb
|
48
|
+
- spec/regressions_spec.rb
|
48
49
|
- spec/spec_helper.rb
|
49
50
|
has_rdoc: true
|
50
51
|
homepage: http://gitpilot.com
|
@@ -76,4 +77,5 @@ specification_version: 3
|
|
76
77
|
summary: A gem that provides a lazy man's ri
|
77
78
|
test_files:
|
78
79
|
- spec/lookup_spec.rb
|
80
|
+
- spec/regressions_spec.rb
|
79
81
|
- spec/spec_helper.rb
|