google-search 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +8 -0
- data/Manifest +70 -0
- data/README.rdoc +95 -0
- data/Rakefile +16 -0
- data/examples/image.rb +21 -0
- data/examples/images.html +1 -0
- data/examples/web.rb +28 -0
- data/google-search.gemspec +33 -0
- data/lib/google-search.rb +29 -0
- data/lib/google-search/item.rb +10 -0
- data/lib/google-search/item/base.rb +78 -0
- data/lib/google-search/item/blog.rb +34 -0
- data/lib/google-search/item/book.rb +40 -0
- data/lib/google-search/item/image.rb +40 -0
- data/lib/google-search/item/local.rb +107 -0
- data/lib/google-search/item/news.rb +46 -0
- data/lib/google-search/item/patent.rb +40 -0
- data/lib/google-search/item/video.rb +46 -0
- data/lib/google-search/item/web.rb +22 -0
- data/lib/google-search/response.rb +92 -0
- data/lib/google-search/search.rb +11 -0
- data/lib/google-search/search/base.rb +212 -0
- data/lib/google-search/search/blog.rb +14 -0
- data/lib/google-search/search/book.rb +8 -0
- data/lib/google-search/search/image.rb +93 -0
- data/lib/google-search/search/local.rb +8 -0
- data/lib/google-search/search/mixins.rb +4 -0
- data/lib/google-search/search/mixins/filter.rb +26 -0
- data/lib/google-search/search/mixins/order_by.rb +36 -0
- data/lib/google-search/search/mixins/safety_level.rb +40 -0
- data/lib/google-search/search/news.rb +66 -0
- data/lib/google-search/search/patent.rb +37 -0
- data/lib/google-search/search/video.rb +15 -0
- data/lib/google-search/search/web.rb +15 -0
- data/lib/google-search/version.rb +6 -0
- data/spec/fixtures/400-response.json +1 -0
- data/spec/fixtures/blog-response.json +1 -0
- data/spec/fixtures/book-response.json +1 -0
- data/spec/fixtures/image-response.json +1 -0
- data/spec/fixtures/invalid-response.json +1 -0
- data/spec/fixtures/local-response.json +1 -0
- data/spec/fixtures/news-response.json +1 -0
- data/spec/fixtures/patent-response.json +1 -0
- data/spec/fixtures/video-response.json +1 -0
- data/spec/fixtures/web-2-response.json +1 -0
- data/spec/fixtures/web-response.json +1 -0
- data/spec/item_blog_spec.rb +26 -0
- data/spec/item_book_spec.rb +18 -0
- data/spec/item_image_spec.rb +21 -0
- data/spec/item_local_spec.rb +30 -0
- data/spec/item_news_spec.rb +19 -0
- data/spec/item_patent_spec.rb +19 -0
- data/spec/item_spec.rb +10 -0
- data/spec/item_video_spec.rb +20 -0
- data/spec/item_web_spec.rb +18 -0
- data/spec/response_spec.rb +63 -0
- data/spec/search_blog_spec.rb +0 -0
- data/spec/search_book_spec.rb +0 -0
- data/spec/search_image_spec.rb +71 -0
- data/spec/search_local_spec.rb +0 -0
- data/spec/search_news_spec.rb +33 -0
- data/spec/search_patent_spec.rb +27 -0
- data/spec/search_spec.rb +89 -0
- data/spec/search_video_spec.rb +42 -0
- data/spec/search_web_spec.rb +42 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +13 -0
- data/tasks/docs.rake +18 -0
- data/tasks/gemspec.rake +3 -0
- data/tasks/spec.rake +25 -0
- metadata +168 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe Google::Search::Video do
|
5
|
+
before :each do
|
6
|
+
@search = Google::Search::Video.new :query => 'foo'
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#get_uri" do
|
10
|
+
describe "order_by" do
|
11
|
+
it "should validate" do
|
12
|
+
@search.order_by = :date
|
13
|
+
lambda { @search.get_uri }.should_not raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should raise an error when invalid" do
|
17
|
+
@search.order_by = :foo
|
18
|
+
lambda { @search.get_uri }.should raise_error(Google::Search::Error, /order/)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "filter" do
|
23
|
+
it "should default to 1" do
|
24
|
+
@search.get_uri.should include('filter=1')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should consider anything positive as 1" do
|
28
|
+
@search.filter = true
|
29
|
+
@search.get_uri.should include('filter=1')
|
30
|
+
@search.filter = 123
|
31
|
+
@search.get_uri.should include('filter=1')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should consider anything negative as 0" do
|
35
|
+
@search.filter = false
|
36
|
+
@search.get_uri.should include('filter=0')
|
37
|
+
@search.filter = nil
|
38
|
+
@search.get_uri.should include('filter=0')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
|
2
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
3
|
+
|
4
|
+
describe Google::Search::Web do
|
5
|
+
before :each do
|
6
|
+
@search = Google::Search::Web.new :query => 'foo'
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#get_uri" do
|
10
|
+
describe "safety_level" do
|
11
|
+
it "should validate" do
|
12
|
+
@search.safety_level = :moderate
|
13
|
+
lambda { @search.get_uri }.should_not raise_error
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should raise an error when invalid" do
|
17
|
+
@search.safety_level = :foo
|
18
|
+
lambda { @search.get_uri }.should raise_error(Google::Search::Error, /safety/)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "filter" do
|
23
|
+
it "should default to 1" do
|
24
|
+
@search.get_uri.should include('filter=1')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should consider anything positive as 1" do
|
28
|
+
@search.filter = true
|
29
|
+
@search.get_uri.should include('filter=1')
|
30
|
+
@search.filter = 123
|
31
|
+
@search.get_uri.should include('filter=1')
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should consider anything negative as 0" do
|
35
|
+
@search.filter = false
|
36
|
+
@search.get_uri.should include('filter=0')
|
37
|
+
@search.filter = nil
|
38
|
+
@search.get_uri.should include('filter=0')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
$:.unshift File.dirname(__FILE__) + '/../lib'
|
3
|
+
require 'pp'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'google-search'
|
6
|
+
|
7
|
+
def fixture path
|
8
|
+
File.read File.dirname(__FILE__) + "/fixtures/#{path}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def json_fixture name
|
12
|
+
Google::Search.json_decode fixture("#{name}.json")
|
13
|
+
end
|
data/tasks/docs.rake
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
|
2
|
+
namespace :docs do
|
3
|
+
|
4
|
+
desc 'Build sdoc'
|
5
|
+
task :build do
|
6
|
+
sh "sdoc -d -N -i lib -x spec -x examples -x doc -x Manifest -x Rakefile"
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'Remove rdoc products'
|
10
|
+
task :remove => [:clobber_docs]
|
11
|
+
|
12
|
+
desc 'Build docs, and open in browser for viewing (specify BROWSER)'
|
13
|
+
task :open => ['docs:build'] do
|
14
|
+
browser = ENV["BROWSER"] || "safari"
|
15
|
+
sh "open -a #{browser} doc/index.html"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/tasks/gemspec.rake
ADDED
data/tasks/spec.rake
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
|
4
|
+
desc "Run all specifications"
|
5
|
+
Spec::Rake::SpecTask.new(:spec) do |t|
|
6
|
+
t.libs << "lib"
|
7
|
+
t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
namespace :spec do
|
11
|
+
|
12
|
+
desc "Run all specifications verbosely"
|
13
|
+
Spec::Rake::SpecTask.new(:verbose) do |t|
|
14
|
+
t.libs << "lib"
|
15
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Run specific specification verbosely (specify SPEC)"
|
19
|
+
Spec::Rake::SpecTask.new(:select) do |t|
|
20
|
+
t.libs << "lib"
|
21
|
+
t.spec_files = [ENV["SPEC"]]
|
22
|
+
t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google-search
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TJ Holowaychuk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-07-30 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: json
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: Google Search API
|
26
|
+
email: tj@vision-media.ca
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- lib/google-search/item/base.rb
|
33
|
+
- lib/google-search/item/blog.rb
|
34
|
+
- lib/google-search/item/book.rb
|
35
|
+
- lib/google-search/item/image.rb
|
36
|
+
- lib/google-search/item/local.rb
|
37
|
+
- lib/google-search/item/news.rb
|
38
|
+
- lib/google-search/item/patent.rb
|
39
|
+
- lib/google-search/item/video.rb
|
40
|
+
- lib/google-search/item/web.rb
|
41
|
+
- lib/google-search/item.rb
|
42
|
+
- lib/google-search/response.rb
|
43
|
+
- lib/google-search/search/base.rb
|
44
|
+
- lib/google-search/search/blog.rb
|
45
|
+
- lib/google-search/search/book.rb
|
46
|
+
- lib/google-search/search/image.rb
|
47
|
+
- lib/google-search/search/local.rb
|
48
|
+
- lib/google-search/search/mixins/filter.rb
|
49
|
+
- lib/google-search/search/mixins/order_by.rb
|
50
|
+
- lib/google-search/search/mixins/safety_level.rb
|
51
|
+
- lib/google-search/search/mixins.rb
|
52
|
+
- lib/google-search/search/news.rb
|
53
|
+
- lib/google-search/search/patent.rb
|
54
|
+
- lib/google-search/search/video.rb
|
55
|
+
- lib/google-search/search/web.rb
|
56
|
+
- lib/google-search/search.rb
|
57
|
+
- lib/google-search/version.rb
|
58
|
+
- lib/google-search.rb
|
59
|
+
- README.rdoc
|
60
|
+
- tasks/docs.rake
|
61
|
+
- tasks/gemspec.rake
|
62
|
+
- tasks/spec.rake
|
63
|
+
files:
|
64
|
+
- examples/image.rb
|
65
|
+
- examples/images.html
|
66
|
+
- examples/web.rb
|
67
|
+
- google-search.gemspec
|
68
|
+
- History.rdoc
|
69
|
+
- lib/google-search/item/base.rb
|
70
|
+
- lib/google-search/item/blog.rb
|
71
|
+
- lib/google-search/item/book.rb
|
72
|
+
- lib/google-search/item/image.rb
|
73
|
+
- lib/google-search/item/local.rb
|
74
|
+
- lib/google-search/item/news.rb
|
75
|
+
- lib/google-search/item/patent.rb
|
76
|
+
- lib/google-search/item/video.rb
|
77
|
+
- lib/google-search/item/web.rb
|
78
|
+
- lib/google-search/item.rb
|
79
|
+
- lib/google-search/response.rb
|
80
|
+
- lib/google-search/search/base.rb
|
81
|
+
- lib/google-search/search/blog.rb
|
82
|
+
- lib/google-search/search/book.rb
|
83
|
+
- lib/google-search/search/image.rb
|
84
|
+
- lib/google-search/search/local.rb
|
85
|
+
- lib/google-search/search/mixins/filter.rb
|
86
|
+
- lib/google-search/search/mixins/order_by.rb
|
87
|
+
- lib/google-search/search/mixins/safety_level.rb
|
88
|
+
- lib/google-search/search/mixins.rb
|
89
|
+
- lib/google-search/search/news.rb
|
90
|
+
- lib/google-search/search/patent.rb
|
91
|
+
- lib/google-search/search/video.rb
|
92
|
+
- lib/google-search/search/web.rb
|
93
|
+
- lib/google-search/search.rb
|
94
|
+
- lib/google-search/version.rb
|
95
|
+
- lib/google-search.rb
|
96
|
+
- Manifest
|
97
|
+
- Rakefile
|
98
|
+
- README.rdoc
|
99
|
+
- spec/fixtures/400-response.json
|
100
|
+
- spec/fixtures/blog-response.json
|
101
|
+
- spec/fixtures/book-response.json
|
102
|
+
- spec/fixtures/image-response.json
|
103
|
+
- spec/fixtures/invalid-response.json
|
104
|
+
- spec/fixtures/local-response.json
|
105
|
+
- spec/fixtures/news-response.json
|
106
|
+
- spec/fixtures/patent-response.json
|
107
|
+
- spec/fixtures/video-response.json
|
108
|
+
- spec/fixtures/web-2-response.json
|
109
|
+
- spec/fixtures/web-response.json
|
110
|
+
- spec/item_blog_spec.rb
|
111
|
+
- spec/item_book_spec.rb
|
112
|
+
- spec/item_image_spec.rb
|
113
|
+
- spec/item_local_spec.rb
|
114
|
+
- spec/item_news_spec.rb
|
115
|
+
- spec/item_patent_spec.rb
|
116
|
+
- spec/item_spec.rb
|
117
|
+
- spec/item_video_spec.rb
|
118
|
+
- spec/item_web_spec.rb
|
119
|
+
- spec/response_spec.rb
|
120
|
+
- spec/search_blog_spec.rb
|
121
|
+
- spec/search_book_spec.rb
|
122
|
+
- spec/search_image_spec.rb
|
123
|
+
- spec/search_local_spec.rb
|
124
|
+
- spec/search_news_spec.rb
|
125
|
+
- spec/search_patent_spec.rb
|
126
|
+
- spec/search_spec.rb
|
127
|
+
- spec/search_video_spec.rb
|
128
|
+
- spec/search_web_spec.rb
|
129
|
+
- spec/spec.opts
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
- tasks/docs.rake
|
132
|
+
- tasks/gemspec.rake
|
133
|
+
- tasks/spec.rake
|
134
|
+
has_rdoc: true
|
135
|
+
homepage: http://github.com/visionmedia/google-search
|
136
|
+
licenses: []
|
137
|
+
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options:
|
140
|
+
- --line-numbers
|
141
|
+
- --inline-source
|
142
|
+
- --title
|
143
|
+
- Google-search
|
144
|
+
- --main
|
145
|
+
- README.rdoc
|
146
|
+
require_paths:
|
147
|
+
- lib
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: "0"
|
153
|
+
version:
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: "1.2"
|
159
|
+
version:
|
160
|
+
requirements: []
|
161
|
+
|
162
|
+
rubyforge_project: google-search
|
163
|
+
rubygems_version: 1.3.5
|
164
|
+
signing_key:
|
165
|
+
specification_version: 3
|
166
|
+
summary: Google Search API
|
167
|
+
test_files: []
|
168
|
+
|