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 CHANGED
@@ -1,8 +1,7 @@
1
1
  source :gemcutter
2
2
 
3
3
  group :test do
4
- gem 'rspec', '~> 2.0.0.beta.20'
5
- gem 'webmock'
4
+
6
5
  end
7
6
 
8
7
  # Specify your gem's dependencies in lookup.gemspec
@@ -1,57 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lookup (1.1.0)
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.0)
14
- activesupport (= 3.0.0)
12
+ activemodel (3.0.7)
13
+ activesupport (= 3.0.7)
15
14
  builder (~> 2.1.2)
16
- i18n (~> 0.4.1)
17
- activerecord (3.0.0)
18
- activemodel (= 3.0.0)
19
- activesupport (= 3.0.0)
20
- arel (~> 1.0.0)
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.0)
23
- addressable (2.2.1)
24
- arel (1.0.1)
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.4.1)
30
- nokogiri (1.4.3.1)
31
- rspec (2.0.0.beta.22)
32
- rspec-core (= 2.0.0.beta.22)
33
- rspec-expectations (= 2.0.0.beta.22)
34
- rspec-mocks (= 2.0.0.beta.22)
35
- rspec-core (2.0.0.beta.22)
36
- rspec-expectations (2.0.0.beta.22)
37
- diff-lcs (>= 1.1.2)
38
- rspec-mocks (2.0.0.beta.22)
39
- rspec-core (= 2.0.0.beta.22)
40
- rspec-expectations (= 2.0.0.beta.22)
41
- sqlite3-ruby (1.3.1)
42
- tzinfo (0.3.23)
43
- webmock (1.3.5)
44
- addressable (>= 2.1.1)
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
- nokogiri
55
- rspec (~> 2.0.0.beta.20)
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(File.dirname(__FILE__))) + "../lib/lookup.rb"
50
- if File.exists?(local_lib)
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'
@@ -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.0:
7
- name: Rails v3.0.0
6
+ v3.0:
7
+ name: Rails v3.0
8
8
  url: "http://api.rubyonrails.org"
9
9
 
10
- v2.3.8:
11
- name: Rails v2.3.8
12
- url: "http://api.rubyonrails.org/v2.3.8"
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
@@ -19,7 +19,7 @@ end
19
19
  module Lookup
20
20
  APIS = []
21
21
 
22
- class APINotFound < StandardError; end
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
- options[:api] ||= msg.split.first
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 !@attempted_ruby && api_check.call(options)
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"]) unless options[:api].is_a?(Api)
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__)
@@ -1,3 +1,3 @@
1
1
  module Lookup
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.3"
3
3
  end
@@ -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
Binary file
@@ -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.0:
7
- name: Rails v3.0.0
6
+ v3.0:
7
+ name: Rails v3.0
8
8
  url: "http://api.rubyonrails.org"
9
9
 
10
- v2.3.8:
11
- name: Rails v2.3.8
12
- url: "http://api.rubyonrails.org/v2.3.8"
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
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
3
  describe "Lookup" do
4
4
  before(:all) do
5
- Lookup.update!
5
+ # Lookup.update!
6
6
  end
7
7
 
8
8
  def find_api(name)
@@ -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
@@ -4,7 +4,7 @@ ENV['HOME'] = File.dirname(__FILE__)
4
4
  require 'rubygems'
5
5
  require 'bundler'
6
6
 
7
- Bundler.require(:default, :test)
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
- hash: 17
5
- prerelease: false
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: 2010-10-02 00:00:00 +10:00
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: sqlite3-ruby
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
- hash: 21
46
- segments:
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: nokogiri
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
- hash: 3
62
- segments:
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: activerecord
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
- hash: 19
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: webmock
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.3.7
147
+ rubygems_version: 1.6.2
171
148
  signing_key:
172
149
  specification_version: 3
173
150
  summary: Lazy man's RI