lookup 1.0.0.beta2 → 1.0.0.beta3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/bin/lookup +39 -18
- data/lib/lookup.rb +18 -3
- data/lib/models.rb +0 -1
- data/lookup.gemspec +1 -1
- data/spec/regressions_spec.rb +4 -0
- data/spec/spec_helper.rb +1 -0
- metadata +19 -20
- data/lib/lookup/version.rb +0 -3
data/Gemfile
CHANGED
data/bin/lookup
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#!/usr/bin/ruby
|
1
|
+
#!/usr/bin/env ruby
|
2
2
|
require 'optparse'
|
3
|
+
require 'pathname'
|
3
4
|
|
4
5
|
# How many methods / constants to return.
|
5
6
|
THRESHOLD = 5
|
@@ -7,7 +8,7 @@ MAC = !!/darwin/.match(RUBY_PLATFORM)
|
|
7
8
|
WINDOWS = !!/win/.match(RUBY_PLATFORM) if not MAC
|
8
9
|
|
9
10
|
def clear_database
|
10
|
-
file =
|
11
|
+
file = Pathname.new(ENV["HOME"]) + ".lookup/lookup.sqlite3"
|
11
12
|
FileUtils.rm(file) if File.exists?(file)
|
12
13
|
end
|
13
14
|
|
@@ -45,9 +46,27 @@ def display_results(results, search_string)
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
49
|
+
local_lib=File.join(File.dirname(__FILE__), "../lib/lookup")
|
50
|
+
if File.exists?(local_lib + ".rb")
|
51
|
+
require local_lib
|
52
|
+
else
|
53
|
+
require 'rubygems'
|
54
|
+
require 'lookup'
|
55
|
+
end
|
56
|
+
|
48
57
|
OPTIONS = {}
|
58
|
+
output = nil
|
49
59
|
op=OptionParser.new do |opts|
|
50
|
-
opts.banner =
|
60
|
+
opts.banner = %Q{
|
61
|
+
Usage: lookup <api> <constant|method> [method] [OPTIONS]
|
62
|
+
APIs are:
|
63
|
+
v3.0.0 - Rails 3.0.0
|
64
|
+
v2.3.8 - Rails 2.3.8
|
65
|
+
1.9 - Ruby 1.9
|
66
|
+
1.8 - Ruby 1.8
|
67
|
+
|
68
|
+
Example: lookup v3.0.0 ActiveRecord::Base new
|
69
|
+
}
|
51
70
|
|
52
71
|
opts.on("-c", "--clear", "Clear database") do
|
53
72
|
OPTIONS[:clear] = true
|
@@ -56,25 +75,27 @@ op=OptionParser.new do |opts|
|
|
56
75
|
opts.on("-t", "--text", "Text only") do
|
57
76
|
OPTIONS[:text] = true
|
58
77
|
end
|
78
|
+
|
79
|
+
opts.on("-v", "--version", "Version of lookup") do
|
80
|
+
output = Lookup::VERSION
|
81
|
+
end
|
59
82
|
end
|
60
83
|
op.parse!
|
61
84
|
|
62
85
|
clear_database if OPTIONS[:clear]
|
86
|
+
unless output
|
87
|
+
begin
|
88
|
+
search_string=ARGV[0..-1].join(" ")
|
89
|
+
if search_string.strip.empty?
|
90
|
+
puts op.help
|
63
91
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
92
|
+
else
|
93
|
+
results=Lookup.search(search_string)
|
94
|
+
display_results(results, search_string)
|
95
|
+
end
|
96
|
+
rescue Lookup::APINotFound => e
|
97
|
+
puts e.message
|
98
|
+
end
|
68
99
|
else
|
69
|
-
|
70
|
-
require 'lookup'
|
100
|
+
puts output
|
71
101
|
end
|
72
|
-
|
73
|
-
search_string=ARGV[0..-1].join(" ")
|
74
|
-
if search_string.strip.empty?
|
75
|
-
puts op.help
|
76
|
-
puts
|
77
|
-
else
|
78
|
-
results=Lookup.search(search_string)
|
79
|
-
display_results(results, search_string)
|
80
|
-
end
|
data/lib/lookup.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
2
|
require 'net/http'
|
4
3
|
|
5
|
-
|
4
|
+
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
5
|
+
require 'bundler'
|
6
|
+
ENV['BUNDLE_GEMFILE'] = gemfile
|
6
7
|
Bundler.require(:default)
|
7
|
-
require 'active_record'
|
8
8
|
|
9
9
|
module Lookup
|
10
|
+
VERSION = "1.0.0.beta3"
|
11
|
+
APIS = []
|
12
|
+
|
13
|
+
class APINotFound < StandardError; end
|
10
14
|
|
11
15
|
class << self
|
12
16
|
def update!
|
@@ -23,6 +27,7 @@ module Lookup
|
|
23
27
|
def update_api!(name, url)
|
24
28
|
puts "Updating API for #{name}..."
|
25
29
|
api = Api.find_or_create_by_name_and_url(name, url)
|
30
|
+
APIS << api
|
26
31
|
api.update_methods!
|
27
32
|
api.update_classes!
|
28
33
|
puts "DONE (with #{name})!"
|
@@ -110,6 +115,16 @@ module Lookup
|
|
110
115
|
"Rails v#{$1}"
|
111
116
|
end
|
112
117
|
|
118
|
+
raise Lookup::APINotFound, %Q{You must specify a valid API as the first keyword. Included APIs:
|
119
|
+
v2.3.8 - Rails 2.3.8
|
120
|
+
v3.0.0 - Rails 3.0.0
|
121
|
+
1.9 - Ruby 1.9
|
122
|
+
1.8 - Ruby 1.8
|
123
|
+
|
124
|
+
Example usage: lookup v2.3.8 ActiveRecord::Base
|
125
|
+
} if options[:api].blank?
|
126
|
+
|
127
|
+
|
113
128
|
options[:api] = Api.find_by_name!(options[:api]) unless options[:api].is_a?(Api)
|
114
129
|
|
115
130
|
msg = msg.gsub(/^(.*?)\s/, "") if options[:api]
|
data/lib/models.rb
CHANGED
data/lookup.gemspec
CHANGED
data/spec/regressions_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lookup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: -
|
4
|
+
hash: -1848230053
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
9
|
- 0
|
10
|
-
-
|
11
|
-
version: 1.0.0.
|
10
|
+
- beta3
|
11
|
+
version: 1.0.0.beta3
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Ryan Bigg
|
@@ -16,13 +16,14 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-09-
|
19
|
+
date: 2010-09-11 00:00:00 +10:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: bundler
|
24
|
+
type: :development
|
24
25
|
prerelease: false
|
25
|
-
|
26
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
26
27
|
none: false
|
27
28
|
requirements:
|
28
29
|
- - ">="
|
@@ -33,12 +34,12 @@ dependencies:
|
|
33
34
|
- 0
|
34
35
|
- 0
|
35
36
|
version: 1.0.0
|
36
|
-
|
37
|
-
version_requirements: *id001
|
37
|
+
requirement: *id001
|
38
38
|
- !ruby/object:Gem::Dependency
|
39
39
|
name: sqlite3-ruby
|
40
|
+
type: :runtime
|
40
41
|
prerelease: false
|
41
|
-
|
42
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
42
43
|
none: false
|
43
44
|
requirements:
|
44
45
|
- - ">="
|
@@ -49,12 +50,12 @@ dependencies:
|
|
49
50
|
- 2
|
50
51
|
- 5
|
51
52
|
version: 1.2.5
|
52
|
-
|
53
|
-
version_requirements: *id002
|
53
|
+
requirement: *id002
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
55
|
name: nokogiri
|
56
|
+
type: :runtime
|
56
57
|
prerelease: false
|
57
|
-
|
58
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
58
59
|
none: false
|
59
60
|
requirements:
|
60
61
|
- - ">="
|
@@ -63,12 +64,12 @@ dependencies:
|
|
63
64
|
segments:
|
64
65
|
- 0
|
65
66
|
version: "0"
|
66
|
-
|
67
|
-
version_requirements: *id003
|
67
|
+
requirement: *id003
|
68
68
|
- !ruby/object:Gem::Dependency
|
69
69
|
name: activerecord
|
70
|
+
type: :runtime
|
70
71
|
prerelease: false
|
71
|
-
|
72
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
72
73
|
none: false
|
73
74
|
requirements:
|
74
75
|
- - ">="
|
@@ -79,12 +80,12 @@ dependencies:
|
|
79
80
|
- 3
|
80
81
|
- 8
|
81
82
|
version: 2.3.8
|
82
|
-
|
83
|
-
version_requirements: *id004
|
83
|
+
requirement: *id004
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: webmock
|
86
|
+
type: :runtime
|
86
87
|
prerelease: false
|
87
|
-
|
88
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
88
89
|
none: false
|
89
90
|
requirements:
|
90
91
|
- - ">="
|
@@ -93,8 +94,7 @@ dependencies:
|
|
93
94
|
segments:
|
94
95
|
- 0
|
95
96
|
version: "0"
|
96
|
-
|
97
|
-
version_requirements: *id005
|
97
|
+
requirement: *id005
|
98
98
|
description: A gem that provides a lazy man's ri
|
99
99
|
email:
|
100
100
|
- radarlistener@gmail.com
|
@@ -115,7 +115,6 @@ files:
|
|
115
115
|
- install.rb
|
116
116
|
- lib/lookup.rb
|
117
117
|
- lib/lookup.sqlite3
|
118
|
-
- lib/lookup/version.rb
|
119
118
|
- lib/models.rb
|
120
119
|
- lookup.gemspec
|
121
120
|
- spec/.lookup/lookup.sqlite3
|
data/lib/lookup/version.rb
DELETED