googlebooks 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/.DS_Store +0 -0
- data/.gitignore +1 -0
- data/README.md +16 -1
- data/googlebooks.gemspec +3 -1
- data/lib/.DS_Store +0 -0
- data/lib/googlebooks.rb +1 -0
- data/lib/version.rb +1 -1
- data/spec/.DS_Store +0 -0
- data/spec/googlebooks/.DS_Store +0 -0
- data/spec/googlebooks/book/item_spec.rb +20 -19
- data/spec/googlebooks/book/response_spec.rb +3 -3
- data/spec/googlebooks/googlebooks_spec.rb +15 -14
- metadata +97 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e23c0a340abeb5925dbb2942f00c3972aa767e96
|
4
|
+
data.tar.gz: 0efc45830013af8c69e04a537567657bbddb4e63
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d5609f90e3eb3983b117878eff07081768835eafb0ce3c0dfca4ef372906b9ac60b6fd29c01d5719b9c15c1032dca7cca6f2bd6fda7f92f958b82575d97f9af
|
7
|
+
data.tar.gz: 992b09c5c91e07162a1f48e189799c4437278b0808109ca8089644968bc100e55c0951d99267671fd2de09f7e4850c8d45f645206cd5d00618638aacb22d6b1d
|
data/.DS_Store
ADDED
Binary file
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -15,7 +15,7 @@ Using GoogleBooks is simple. There's just one class, `GoogleBooks`, and one meth
|
|
15
15
|
books = GoogleBooks.search('The Great Gatsby')
|
16
16
|
first_book = books.first
|
17
17
|
|
18
|
-
first_book.
|
18
|
+
first_book.authors #=> 'F. Scott Fitzgerald'
|
19
19
|
first_book.isbn #=> '9781443411080'
|
20
20
|
first_book.image_link(:zoom => 6) #=> 'http://bks2.books.google.com/books?id=...'
|
21
21
|
|
@@ -45,6 +45,21 @@ By default, results are returned in order of relevance. However, results also be
|
|
45
45
|
GoogleBooks.search('The Great Gatsby', {:order_by => `ANYTHING ELSE`})
|
46
46
|
#=> both return results in order of relevance
|
47
47
|
|
48
|
+
Filtering
|
49
|
+
-----------
|
50
|
+
|
51
|
+
You can use the filter parameter to restrict the returned results further by setting it the to one of the following values:
|
52
|
+
|
53
|
+
* `partial` *Returns results where at least parts of the text are previewable.*
|
54
|
+
* `full` *Only returns results where all of the text is viewable.*
|
55
|
+
* `free-ebooks` *Only returns results that are free Google eBooks.*
|
56
|
+
* `paid-ebooks` *Only returns results that are Google eBooks with a price.*
|
57
|
+
* `ebooks` *Only returns results that are Google eBooks, paid or free. Examples of non-eBooks would be publisher content that is available in limited preview and not for sale, or magazines.*
|
58
|
+
|
59
|
+
Examples:
|
60
|
+
|
61
|
+
GoogleBooks.search('ruby', :filter => 'free-ebooks')
|
62
|
+
|
48
63
|
Geolocation
|
49
64
|
-----------
|
50
65
|
|
data/googlebooks.gemspec
CHANGED
@@ -17,7 +17,9 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_dependency('httparty')
|
18
18
|
s.add_development_dependency('rspec')
|
19
19
|
s.add_development_dependency('webmock')
|
20
|
-
|
20
|
+
s.add_development_dependency('rspec-its')
|
21
|
+
s.add_development_dependency('rake')
|
22
|
+
|
21
23
|
s.files = `git ls-files`.split("\n")
|
22
24
|
#s.files = Dir["{lib}/**/*", "googlebooks.gemspec", "Gemfile", "Rakefile"]
|
23
25
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/googlebooks.rb
CHANGED
@@ -32,6 +32,7 @@ module GoogleBooks
|
|
32
32
|
self.parameters = { 'q' => query }
|
33
33
|
options[:page] ||= 1
|
34
34
|
options[:count] ||= 5
|
35
|
+
parameters['filter'] = options[:filter] if options[:filter]
|
35
36
|
parameters['startIndex'] = options[:count] * (options[:page] - 1)
|
36
37
|
parameters['maxResults'] = options[:count]
|
37
38
|
parameters['key'] = options[:api_key] if options[:api_key]
|
data/lib/version.rb
CHANGED
data/spec/.DS_Store
ADDED
Binary file
|
Binary file
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'rspec/its'
|
2
3
|
|
3
4
|
module GoogleBooks
|
4
5
|
class Item
|
@@ -7,50 +8,50 @@ module GoogleBooks
|
|
7
8
|
example = GoogleBooks.search('isbn:9780062132345').first
|
8
9
|
|
9
10
|
it "should append a subtitle to the title if it exists" do
|
10
|
-
example.title.
|
11
|
+
expect(example.title).to eq "Freakonomics: A Rogue Economist Explores the Hidden Side of Everything"
|
11
12
|
end
|
12
13
|
|
13
14
|
it "should return an array of all titles" do
|
14
|
-
example.titles_array.
|
15
|
+
expect(example.titles_array).to include(*["Freakonomics", "A Rogue Economist Explores the Hidden Side of Everything"])
|
15
16
|
end
|
16
17
|
|
17
18
|
it "should return a string authors delineated by a comma" do
|
18
|
-
example.authors.
|
19
|
+
expect(example.authors).to eq "Steven D. Levitt, Stephen J. Dubner"
|
19
20
|
end
|
20
21
|
|
21
22
|
it "should return an array of author names" do
|
22
|
-
example.authors_array.
|
23
|
+
expect(example.authors_array).to include(*["Steven D. Levitt", "Stephen J. Dubner"])
|
23
24
|
end
|
24
25
|
|
25
26
|
it "should have an isbn that is 13 digits" do
|
26
|
-
example.isbn.
|
27
|
-
example.isbn.
|
28
|
-
example.isbn.to_s.length.
|
27
|
+
expect(example.isbn).not_to eq nil
|
28
|
+
expect(example.isbn).to eq '9780062132345'
|
29
|
+
expect(example.isbn.to_s.length).to eq 13
|
29
30
|
end
|
30
31
|
|
31
32
|
it "should convert to a 10 digit isbn" do
|
32
|
-
example.isbn_10.
|
33
|
+
expect(example.isbn_10).to eq '0062132342'
|
33
34
|
end
|
34
35
|
|
35
36
|
it "should make a 13 digit isbn duplicated from the default isbn" do
|
36
|
-
example.isbn_13.
|
37
|
-
example.isbn_13.
|
37
|
+
expect(example.isbn_13).to eq '9780062132345'
|
38
|
+
expect(example.isbn_13).to eq example.isbn
|
38
39
|
end
|
39
40
|
|
40
41
|
describe "image_link" do
|
41
42
|
it "should have all zoom varieties and show 1 as a default" do
|
42
|
-
example.image_link.
|
43
|
-
example.image_link(:zoom => 2).
|
44
|
-
example.image_link(:zoom => 3).
|
45
|
-
example.image_link(:zoom => 4).
|
46
|
-
example.image_link(:zoom => 5).
|
47
|
-
example.image_link(:zoom => 6).
|
48
|
-
example.image_link(:zoom => 7).
|
43
|
+
expect(example.image_link).to include "zoom=1"
|
44
|
+
expect(example.image_link(:zoom => 2)).to include "zoom=2"
|
45
|
+
expect(example.image_link(:zoom => 3)).to include "zoom=3"
|
46
|
+
expect(example.image_link(:zoom => 4)).to include "zoom=4"
|
47
|
+
expect(example.image_link(:zoom => 5)).to include "zoom=5"
|
48
|
+
expect(example.image_link(:zoom => 6)).to include "zoom=6"
|
49
|
+
expect(example.image_link(:zoom => 7)).to include "zoom=7"
|
49
50
|
end
|
50
51
|
|
51
52
|
it "should default to 'edge=none' and curl when dictated" do
|
52
|
-
example.image_link.
|
53
|
-
example.image_link(:curl => true).
|
53
|
+
expect(example.image_link).to include "edge=none"
|
54
|
+
expect(example.image_link(:curl => true)).to include "edge=curl"
|
54
55
|
end
|
55
56
|
|
56
57
|
context "when google_book_item has no isbn_10 but one OTHER industry identifiers" do
|
@@ -6,15 +6,15 @@ module GoogleBooks
|
|
6
6
|
response = GoogleBooks.search('the great gatsby')
|
7
7
|
|
8
8
|
it "should set total results" do
|
9
|
-
response.total_items.
|
9
|
+
expect(response.total_items).to be > 0
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should return entries" do
|
13
|
-
response.first.
|
13
|
+
expect(response.first).to be_an Item
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should handle an empty query" do
|
17
|
-
GoogleBooks.search('').to_a.
|
17
|
+
expect(GoogleBooks.search('').to_a).to be_empty
|
18
18
|
end
|
19
19
|
end
|
20
20
|
end
|
@@ -4,53 +4,54 @@ describe GoogleBooks do
|
|
4
4
|
describe "#search" do
|
5
5
|
it "should escape spaces" do
|
6
6
|
GoogleBooks.search('the great gatsby')
|
7
|
-
GoogleBooks.send(:query).
|
7
|
+
expect(GoogleBooks.send(:query)).to include 'q=the+great+gatsby'
|
8
8
|
end
|
9
9
|
|
10
10
|
describe 'startIndex' do
|
11
11
|
it "should default to 0 if no page is specified" do
|
12
12
|
GoogleBooks.search('the great gatsby')
|
13
|
-
GoogleBooks.send(:query).
|
13
|
+
expect(GoogleBooks.send(:query)).to include 'startIndex=0'
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should calculate based on default count of 5 if no count is given" do
|
17
17
|
GoogleBooks.search("the great gatsby", :page => 4)
|
18
|
-
GoogleBooks.send(:query).
|
18
|
+
expect(GoogleBooks.send(:query)).to include 'startIndex=15'
|
19
19
|
end
|
20
20
|
|
21
21
|
it "should set based on page number and count" do
|
22
22
|
GoogleBooks.search('the great gatsby', {:page => 3, :count => 12})
|
23
|
-
GoogleBooks.send(:query).
|
23
|
+
expect(GoogleBooks.send(:query)).to include 'startIndex=24'
|
24
24
|
end
|
25
25
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should set the number of results per page" do
|
29
29
|
GoogleBooks.search('the great gatsby', :count => 20)
|
30
|
-
GoogleBooks.send(:query).
|
30
|
+
expect(GoogleBooks.send(:query)).to include 'maxResults=20'
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should set the country" do
|
34
34
|
GoogleBooks.search('the great gatsby', :country => "ca")
|
35
|
-
GoogleBooks.send(:query).
|
35
|
+
expect(GoogleBooks.send(:query)).to include 'country=ca'
|
36
36
|
end
|
37
37
|
|
38
38
|
it "should join parameters" do
|
39
|
-
GoogleBooks.search('the great gatsby', :count => 20, :page => 2, :country => "ca")
|
40
|
-
GoogleBooks.send(:query).
|
41
|
-
GoogleBooks.send(:query).
|
42
|
-
GoogleBooks.send(:query).
|
43
|
-
GoogleBooks.send(:query).
|
44
|
-
GoogleBooks.send(:query)
|
39
|
+
GoogleBooks.search('the great gatsby', :filter => "free-ebooks", :count => 20, :page => 2, :country => "ca")
|
40
|
+
expect(GoogleBooks.send(:query)).to include 'startIndex=2'
|
41
|
+
expect(GoogleBooks.send(:query)).to include 'maxResults=20'
|
42
|
+
expect(GoogleBooks.send(:query)).to include 'q=the+great+gatsby'
|
43
|
+
expect(GoogleBooks.send(:query)).to include 'country=ca'
|
44
|
+
expect(GoogleBooks.send(:query)).to include 'filter=free-ebooks'
|
45
|
+
expect(GoogleBooks.send(:query).count('&')).to eq 4
|
45
46
|
end
|
46
47
|
|
47
48
|
it "should return the proper number results based on the count passed in" do
|
48
49
|
results = GoogleBooks.search('F. Scott Fitzgerald', :count => 20)
|
49
|
-
results.count.
|
50
|
+
expect(results.count).to eq 20
|
50
51
|
end
|
51
52
|
|
52
53
|
it "should return a response" do
|
53
|
-
GoogleBooks.search('the great gatsby').
|
54
|
+
expect(GoogleBooks.search('the great gatsby')).to be_a GoogleBooks::Response
|
54
55
|
end
|
55
56
|
end
|
56
57
|
end
|
metadata
CHANGED
@@ -1,91 +1,140 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: googlebooks
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Zean Tsoi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-07-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
15
14
|
name: httparty
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
|
-
version_requirements: *id001
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: rspec
|
27
21
|
prerelease: false
|
28
|
-
|
29
|
-
requirements:
|
30
|
-
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
31
34
|
type: :development
|
32
|
-
|
33
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
34
42
|
name: webmock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-its
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
35
63
|
prerelease: false
|
36
|
-
|
37
|
-
requirements:
|
38
|
-
-
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
39
76
|
type: :development
|
40
|
-
|
41
|
-
|
42
|
-
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: GoogleBooks is a lightweight Ruby wrapper that queries the Google API
|
84
|
+
to search for publications in the Google Books repository. It is inspired by the
|
85
|
+
google-book gem which relies on the deprecated Google GData Books API, but is updated
|
86
|
+
to hook into the current Google API.
|
87
|
+
email:
|
43
88
|
- zean.tsoi@gmail.com
|
44
89
|
executables: []
|
45
|
-
|
46
90
|
extensions: []
|
47
|
-
|
48
91
|
extra_rdoc_files: []
|
49
|
-
|
50
|
-
|
51
|
-
- .gitignore
|
92
|
+
files:
|
93
|
+
- ".DS_Store"
|
94
|
+
- ".gitignore"
|
95
|
+
- ".travis.yml"
|
52
96
|
- Gemfile
|
53
97
|
- LICENSE
|
54
98
|
- README.md
|
55
99
|
- Rakefile
|
56
100
|
- googlebooks.gemspec
|
101
|
+
- lib/.DS_Store
|
57
102
|
- lib/book/item.rb
|
58
103
|
- lib/book/response.rb
|
59
104
|
- lib/googlebooks.rb
|
60
105
|
- lib/version.rb
|
106
|
+
- spec/.DS_Store
|
107
|
+
- spec/googlebooks/.DS_Store
|
61
108
|
- spec/googlebooks/book/item_spec.rb
|
62
109
|
- spec/googlebooks/book/response_spec.rb
|
63
110
|
- spec/googlebooks/googlebooks_spec.rb
|
64
111
|
- spec/spec_helper.rb
|
65
112
|
homepage: https://github.com/zeantsoi/googlebooks
|
66
113
|
licenses: []
|
67
|
-
|
68
114
|
metadata: {}
|
69
|
-
|
70
115
|
post_install_message:
|
71
116
|
rdoc_options: []
|
72
|
-
|
73
|
-
require_paths:
|
117
|
+
require_paths:
|
74
118
|
- lib
|
75
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
-
requirements:
|
77
|
-
-
|
78
|
-
|
79
|
-
|
80
|
-
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
81
129
|
requirements: []
|
82
|
-
|
83
130
|
rubyforge_project: googlebooks
|
84
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.2.2
|
85
132
|
signing_key:
|
86
133
|
specification_version: 4
|
87
|
-
summary: GoogleBooks is a lightweight Ruby wrapper that queries the Google API to
|
88
|
-
|
134
|
+
summary: GoogleBooks is a lightweight Ruby wrapper that queries the Google API to
|
135
|
+
search for publications in the Google Books repository.
|
136
|
+
test_files:
|
137
|
+
- spec/googlebooks/.DS_Store
|
89
138
|
- spec/googlebooks/book/item_spec.rb
|
90
139
|
- spec/googlebooks/book/response_spec.rb
|
91
140
|
- spec/googlebooks/googlebooks_spec.rb
|