lookup 1.1.1 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -2
- data/Gemfile.lock +29 -34
- data/bin/lookup +2 -3
- data/config/lookup +6 -6
- data/lib/lookup.rb +8 -6
- data/lib/lookup/version.rb +1 -1
- data/lookup.gemspec +2 -1
- data/spec/.lookup/lookup.sqlite3 +0 -0
- data/spec/config +6 -6
- data/spec/lookup_spec.rb +1 -1
- data/spec/regressions_spec.rb +4 -1
- data/spec/spec_helper.rb +2 -2
- metadata +26 -49
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,57 +1,52 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
lookup (1.1.
|
4
|
+
lookup (1.1.2)
|
5
5
|
activerecord (>= 2.3.8)
|
6
6
|
nokogiri
|
7
7
|
sqlite3-ruby (>= 1.2.5)
|
8
|
-
webmock
|
9
8
|
|
10
9
|
GEM
|
11
10
|
remote: http://rubygems.org/
|
12
11
|
specs:
|
13
|
-
activemodel (3.0.
|
14
|
-
activesupport (= 3.0.
|
12
|
+
activemodel (3.0.7)
|
13
|
+
activesupport (= 3.0.7)
|
15
14
|
builder (~> 2.1.2)
|
16
|
-
i18n (~> 0.
|
17
|
-
activerecord (3.0.
|
18
|
-
activemodel (= 3.0.
|
19
|
-
activesupport (= 3.0.
|
20
|
-
arel (~>
|
15
|
+
i18n (~> 0.5.0)
|
16
|
+
activerecord (3.0.7)
|
17
|
+
activemodel (= 3.0.7)
|
18
|
+
activesupport (= 3.0.7)
|
19
|
+
arel (~> 2.0.2)
|
21
20
|
tzinfo (~> 0.3.23)
|
22
|
-
activesupport (3.0.
|
23
|
-
addressable (2.2.
|
24
|
-
arel (
|
25
|
-
activesupport (~> 3.0.0)
|
21
|
+
activesupport (3.0.7)
|
22
|
+
addressable (2.2.6)
|
23
|
+
arel (2.0.10)
|
26
24
|
builder (2.1.2)
|
27
25
|
crack (0.1.8)
|
28
26
|
diff-lcs (1.1.2)
|
29
|
-
i18n (0.
|
30
|
-
nokogiri (1.4.
|
31
|
-
rspec (2.
|
32
|
-
rspec-core (
|
33
|
-
rspec-expectations (
|
34
|
-
rspec-mocks (
|
35
|
-
rspec-core (2.
|
36
|
-
rspec-expectations (2.
|
37
|
-
diff-lcs (
|
38
|
-
rspec-mocks (2.
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
tzinfo (0.3.
|
43
|
-
webmock (1.
|
44
|
-
addressable (
|
27
|
+
i18n (0.5.0)
|
28
|
+
nokogiri (1.4.4)
|
29
|
+
rspec (2.6.0)
|
30
|
+
rspec-core (~> 2.6.0)
|
31
|
+
rspec-expectations (~> 2.6.0)
|
32
|
+
rspec-mocks (~> 2.6.0)
|
33
|
+
rspec-core (2.6.2)
|
34
|
+
rspec-expectations (2.6.0)
|
35
|
+
diff-lcs (~> 1.1.2)
|
36
|
+
rspec-mocks (2.6.0)
|
37
|
+
sqlite3 (1.3.3)
|
38
|
+
sqlite3-ruby (1.3.3)
|
39
|
+
sqlite3 (>= 1.3.3)
|
40
|
+
tzinfo (0.3.27)
|
41
|
+
webmock (1.6.4)
|
42
|
+
addressable (> 2.2.5, ~> 2.2)
|
45
43
|
crack (>= 0.1.7)
|
46
44
|
|
47
45
|
PLATFORMS
|
48
46
|
ruby
|
49
47
|
|
50
48
|
DEPENDENCIES
|
51
|
-
activerecord (>= 2.3.8)
|
52
49
|
bundler (>= 1.0.0)
|
53
50
|
lookup!
|
54
|
-
|
55
|
-
|
56
|
-
sqlite3-ruby (>= 1.2.5)
|
57
|
-
webmock
|
51
|
+
rspec (~> 2.1)
|
52
|
+
webmock (~> 1.6)
|
data/bin/lookup
CHANGED
@@ -46,9 +46,8 @@ def display_results(results, search_string)
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
local_lib=Pathname.new(File.expand_path(
|
50
|
-
|
51
|
-
require local_lib
|
49
|
+
if (local_lib = Pathname.new(File.expand_path('../../lib/lookup.rb', __FILE__))).file?
|
50
|
+
require local_lib.to_s
|
52
51
|
else
|
53
52
|
require 'rubygems'
|
54
53
|
require 'lookup'
|
data/config/lookup
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
apis:
|
2
2
|
faker:
|
3
3
|
name: Faker
|
4
|
-
url: "http://faker.rubyforge.org/rdoc
|
4
|
+
url: "http://faker.rubyforge.org/rdoc"
|
5
5
|
|
6
|
-
v3.0
|
7
|
-
name: Rails v3.0
|
6
|
+
v3.0:
|
7
|
+
name: Rails v3.0
|
8
8
|
url: "http://api.rubyonrails.org"
|
9
9
|
|
10
|
-
v2.3
|
11
|
-
name: Rails v2.3
|
12
|
-
url: "http://api.rubyonrails.org/v2.3.
|
10
|
+
v2.3:
|
11
|
+
name: Rails v2.3
|
12
|
+
url: "http://api.rubyonrails.org/v2.3.10"
|
13
13
|
|
14
14
|
1.8:
|
15
15
|
name: Ruby 1.8
|
data/lib/lookup.rb
CHANGED
@@ -19,7 +19,7 @@ end
|
|
19
19
|
module Lookup
|
20
20
|
APIS = []
|
21
21
|
|
22
|
-
class APINotFound <
|
22
|
+
class APINotFound < Exception; end
|
23
23
|
|
24
24
|
class << self
|
25
25
|
|
@@ -134,13 +134,13 @@ module Lookup
|
|
134
134
|
end
|
135
135
|
|
136
136
|
def search(msg, options={})
|
137
|
-
|
137
|
+
first_word = msg.split.first
|
138
|
+
options[:api] ||= first_word if apis.keys.include?(first_word)
|
138
139
|
api_check = lambda { |options| (!apis.keys.map(&:to_s).include?(options[:api]) && !options[:api].is_a?(Api)) }
|
139
140
|
# to_s because yaml interprets "1.8" as a literal 1.8
|
140
141
|
# And because I'm super, super lazy
|
141
|
-
if
|
142
|
+
if api_check.call(options)
|
142
143
|
# Attempt a current Ruby lookup
|
143
|
-
@attempted_ruby = true
|
144
144
|
api = case RUBY_VERSION
|
145
145
|
when /^1.8/
|
146
146
|
"1.8"
|
@@ -150,7 +150,9 @@ module Lookup
|
|
150
150
|
search(msg, options.merge!(:api => api)) if api
|
151
151
|
end
|
152
152
|
|
153
|
-
options[:api] = Api.find_by_name!(apis[options[:api]]["name"])
|
153
|
+
options[:api] = Api.find_by_name!(apis[options[:api]]["name"]) if (options[:api] && apis[options[:api]].try(:[], "name")) && !options[:api].is_a?(Api)
|
154
|
+
|
155
|
+
raise Lookup::APINotFound, "Could not determine what API the lookup is for" unless options[:api]
|
154
156
|
|
155
157
|
# We want to retain message.
|
156
158
|
msg = msg.gsub(/^(.*?)\s/, "")
|
@@ -193,4 +195,4 @@ module Lookup
|
|
193
195
|
end
|
194
196
|
end
|
195
197
|
|
196
|
-
require 'lookup/models'
|
198
|
+
require File.expand_path('../lookup/models', __FILE__)
|
data/lib/lookup/version.rb
CHANGED
data/lookup.gemspec
CHANGED
@@ -14,11 +14,12 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.required_rubygems_version = ">= 1.3.6"
|
15
15
|
|
16
16
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
17
|
+
s.add_development_dependency "rspec", "~> 2.1"
|
18
|
+
s.add_development_dependency "webmock", "~> 1.6"
|
17
19
|
|
18
20
|
s.add_dependency(%q<sqlite3-ruby>, [">= 1.2.5"])
|
19
21
|
s.add_dependency(%q<nokogiri>, [">= 0"])
|
20
22
|
s.add_dependency(%q<activerecord>, [">= 2.3.8"])
|
21
|
-
s.add_dependency(%q<webmock>, [">= 0"])
|
22
23
|
|
23
24
|
s.files = `git ls-files`.split("\n")
|
24
25
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
data/spec/.lookup/lookup.sqlite3
CHANGED
Binary file
|
data/spec/config
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
apis:
|
2
2
|
faker:
|
3
3
|
name: Faker
|
4
|
-
url: "http://faker.rubyforge.org/rdoc
|
4
|
+
url: "http://faker.rubyforge.org/rdoc"
|
5
5
|
|
6
|
-
v3.0
|
7
|
-
name: Rails v3.0
|
6
|
+
v3.0:
|
7
|
+
name: Rails v3.0
|
8
8
|
url: "http://api.rubyonrails.org"
|
9
9
|
|
10
|
-
v2.3
|
11
|
-
name: Rails v2.3
|
12
|
-
url: "http://api.rubyonrails.org/v2.3.
|
10
|
+
v2.3:
|
11
|
+
name: Rails v2.3
|
12
|
+
url: "http://api.rubyonrails.org/v2.3.10"
|
13
13
|
|
14
14
|
1.8:
|
15
15
|
name: Ruby 1.8
|
data/spec/lookup_spec.rb
CHANGED
data/spec/regressions_spec.rb
CHANGED
@@ -12,5 +12,8 @@ describe "testing for regressions" do
|
|
12
12
|
it "must have a valid URL" do
|
13
13
|
Lookup.search("1.9 Array#shuffle").first.url.scan("http").size.should eql(1)
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
|
+
it "must have an API specified for constant + method" do
|
17
|
+
lambda { Lookup.search("String#=~") }.should raise_error(Lookup::APINotFound)
|
18
|
+
end
|
16
19
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,7 +4,7 @@ ENV['HOME'] = File.dirname(__FILE__)
|
|
4
4
|
require 'rubygems'
|
5
5
|
require 'bundler'
|
6
6
|
|
7
|
-
Bundler.require(:default, :
|
7
|
+
Bundler.require(:default, :development)
|
8
8
|
|
9
9
|
def here
|
10
10
|
Pathname.new(File.dirname(__FILE__))
|
@@ -22,7 +22,7 @@ def classes(api)
|
|
22
22
|
File.read(apis + api + "classes.html")
|
23
23
|
end
|
24
24
|
|
25
|
-
include WebMock
|
25
|
+
include WebMock::API
|
26
26
|
|
27
27
|
WebMock.disable_net_connect!
|
28
28
|
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 1.1.1
|
4
|
+
prerelease:
|
5
|
+
version: 1.1.3
|
11
6
|
platform: ruby
|
12
7
|
authors: []
|
13
8
|
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
13
|
+
date: 2011-05-25 00:00:00 +10:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,74 +21,64 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 23
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 0
|
33
|
-
- 0
|
34
24
|
version: 1.0.0
|
35
25
|
type: :development
|
36
26
|
version_requirements: *id001
|
37
27
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
28
|
+
name: rspec
|
39
29
|
prerelease: false
|
40
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
31
|
none: false
|
42
32
|
requirements:
|
43
|
-
- -
|
33
|
+
- - ~>
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
- 1
|
48
|
-
- 2
|
49
|
-
- 5
|
50
|
-
version: 1.2.5
|
51
|
-
type: :runtime
|
35
|
+
version: "2.1"
|
36
|
+
type: :development
|
52
37
|
version_requirements: *id002
|
53
38
|
- !ruby/object:Gem::Dependency
|
54
|
-
name:
|
39
|
+
name: webmock
|
55
40
|
prerelease: false
|
56
41
|
requirement: &id003 !ruby/object:Gem::Requirement
|
57
42
|
none: false
|
58
43
|
requirements:
|
59
|
-
- -
|
44
|
+
- - ~>
|
60
45
|
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
- 0
|
64
|
-
version: "0"
|
65
|
-
type: :runtime
|
46
|
+
version: "1.6"
|
47
|
+
type: :development
|
66
48
|
version_requirements: *id003
|
67
49
|
- !ruby/object:Gem::Dependency
|
68
|
-
name:
|
50
|
+
name: sqlite3-ruby
|
69
51
|
prerelease: false
|
70
52
|
requirement: &id004 !ruby/object:Gem::Requirement
|
71
53
|
none: false
|
72
54
|
requirements:
|
73
55
|
- - ">="
|
74
56
|
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 2
|
78
|
-
- 3
|
79
|
-
- 8
|
80
|
-
version: 2.3.8
|
57
|
+
version: 1.2.5
|
81
58
|
type: :runtime
|
82
59
|
version_requirements: *id004
|
83
60
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
61
|
+
name: nokogiri
|
85
62
|
prerelease: false
|
86
63
|
requirement: &id005 !ruby/object:Gem::Requirement
|
87
64
|
none: false
|
88
65
|
requirements:
|
89
66
|
- - ">="
|
90
67
|
- !ruby/object:Gem::Version
|
91
|
-
hash: 3
|
92
|
-
segments:
|
93
|
-
- 0
|
94
68
|
version: "0"
|
95
69
|
type: :runtime
|
96
70
|
version_requirements: *id005
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: activerecord
|
73
|
+
prerelease: false
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 2.3.8
|
80
|
+
type: :runtime
|
81
|
+
version_requirements: *id006
|
97
82
|
description: Lazy man's RI
|
98
83
|
email: []
|
99
84
|
|
@@ -149,25 +134,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
149
134
|
requirements:
|
150
135
|
- - ">="
|
151
136
|
- !ruby/object:Gem::Version
|
152
|
-
hash: 3
|
153
|
-
segments:
|
154
|
-
- 0
|
155
137
|
version: "0"
|
156
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
139
|
none: false
|
158
140
|
requirements:
|
159
141
|
- - ">="
|
160
142
|
- !ruby/object:Gem::Version
|
161
|
-
hash: 23
|
162
|
-
segments:
|
163
|
-
- 1
|
164
|
-
- 3
|
165
|
-
- 6
|
166
143
|
version: 1.3.6
|
167
144
|
requirements: []
|
168
145
|
|
169
146
|
rubyforge_project:
|
170
|
-
rubygems_version: 1.
|
147
|
+
rubygems_version: 1.6.2
|
171
148
|
signing_key:
|
172
149
|
specification_version: 3
|
173
150
|
summary: Lazy man's RI
|