google_books 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -4,4 +4,9 @@ pkg/*
4
4
  spec/fixtures/cassette_library/*.yml
5
5
  .idea/*
6
6
  .DS_Store
7
- .rbx
7
+ .rbx
8
+ Gemfile.lock
9
+ .rvmrc
10
+ .ruby-version
11
+ .ruby-gemset
12
+
@@ -43,4 +43,9 @@ v0.2.1
43
43
  * Removed call to blank? in the `normalize_publisher` method of the Book class
44
44
  * Other
45
45
  * Added specific versions for required gems
46
- * Fixed VCR cassette problem between Ruby 1.8.7 and 1.9.2 (Run the tests using 1.8.7 first and then 1.9.2 to reuse the same cassette)
46
+ * Fixed VCR cassette problem between Ruby 1.8.7 and 1.9.2 (Run the tests using 1.8.7 first and then 1.9.2 to reuse the same cassette)
47
+
48
+ v0.2.2
49
+ ------
50
+ * Other
51
+ * Dependencies are now >= vs. ~>
@@ -11,11 +11,11 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "http://github.com/visoft/google_books"
12
12
  s.summary = %q{A Ruby wrapper around the Google Books API}
13
13
  s.description = %q{A Ruby wrapper that allows you to query the Google Books API. This project was inspired by google-book, see the README for more information}
14
-
15
- s.add_dependency('httparty', '~> 0.8.1')
16
- s.add_dependency('hashie', '~> 1.1.0')
17
-
18
- s.add_development_dependency('rake', '~> 0.8.7')
14
+
15
+ s.add_dependency('httparty', '>= 0.8.1')
16
+ s.add_dependency('hashie', '>= 1.1.0')
17
+
18
+ s.add_development_dependency('rake', '>= 0.8.7')
19
19
  s.add_development_dependency('autotest', '~> 4.4.6')
20
20
  s.add_development_dependency('rspec', '~> 2.6.0')
21
21
  s.add_development_dependency('webmock', '~> 1.7.6')
@@ -5,12 +5,12 @@ module GoogleBooks
5
5
  :isbn, :isbn_10, :page_count, :categories,
6
6
  :description, :average_rating, :ratings_count,
7
7
  :covers, :preview_link, :info_link
8
-
8
+
9
9
  def initialize(item)
10
10
  return if item.nil?
11
11
  parse_item(item)
12
12
  end
13
-
13
+
14
14
  private
15
15
 
16
16
  def parse_item(item)
@@ -26,7 +26,7 @@ module GoogleBooks
26
26
  @isbn = get_isbn_for_book
27
27
  @isbn_10 = get_isbn_for_book(10)
28
28
  @page_count = @book.pageCount
29
- @categories = @book.categories
29
+ @categories = @book.categories || []
30
30
  @average_rating = @book.averageRating
31
31
  @ratings_count = @book.ratingsCount
32
32
  @covers = fixup_covers
@@ -38,10 +38,10 @@ module GoogleBooks
38
38
  return book.title if book.subtitle.nil?
39
39
  "#{book.title}: #{titlize(book.subtitle)}"
40
40
  end
41
-
41
+
42
42
  def normalize_publisher(name)
43
43
  return name if (name.nil? || name.empty?)
44
-
44
+
45
45
  name.
46
46
  gsub(/[ ,]+Inc.?$/i, ' Inc.').
47
47
  gsub(/[ ,]+Llc.?$/i, ' LLC.').
@@ -60,7 +60,7 @@ module GoogleBooks
60
60
  return nil if isbn.nil?
61
61
  isbn.identifier
62
62
  end
63
-
63
+
64
64
  def fixup_covers
65
65
  return {} if @book.imageLinks.nil?
66
66
  url = @book.imageLinks.first[1]
@@ -69,7 +69,7 @@ module GoogleBooks
69
69
  :small => cover_url(url, 1),
70
70
  :medium => cover_url(url, 2),
71
71
  :large => cover_url(url, 3),
72
- :extra_large => cover_url(url, 6)
72
+ :extra_large => cover_url(url, 6)
73
73
  }
74
74
  end
75
75
 
@@ -78,7 +78,7 @@ module GoogleBooks
78
78
  non_capitalized = %w{of etc and by the for on is at to but nor or a via}
79
79
  word.gsub(/\b[a-z]+/){ |w| non_capitalized.include?(w) ? w : w.capitalize }.sub(/^[a-z]/){|l| l.upcase }.sub(/\b[a-z][^\s]*?$/){|l| l.capitalize }
80
80
  end
81
-
81
+
82
82
  def cover_url(url, zoom)
83
83
  url.
84
84
  gsub(/zoom=\d/, "zoom=#{zoom}"). # Set the zoom level
@@ -1,3 +1,3 @@
1
1
  module GoogleBooks
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
@@ -4,99 +4,99 @@ module GoogleBooks
4
4
  module API
5
5
  describe Book do
6
6
  use_vcr_cassette 'google'
7
-
7
+
8
8
  subject { API.search('isbn:9781935182320').first }
9
-
9
+
10
10
  let(:item) do
11
11
  item = { 'volumeInfo' => {} }
12
12
  end
13
-
13
+
14
14
  it "should be able to handle a nil object passed" do
15
15
  lambda { Book.new(nil) }.should_not raise_error
16
16
  end
17
-
17
+
18
18
  it "should have a title" do
19
- subject.title.should eq 'JQuery in Action'
19
+ subject.title.should eq 'jQuery in action'
20
20
  end
21
-
21
+
22
22
  it "should contain a subtitle in the title if there is one" do
23
23
  book = API.search('isbn:9780596517748').first
24
24
  book.title.should eq 'JavaScript: The Good Parts'
25
25
  end
26
-
26
+
27
27
  it "should have an array of authors with the correct names" do
28
28
  subject.authors.length.should eq 2
29
29
  subject.authors[0].should eq "Bear Bibeault"
30
30
  subject.authors[1].should eq "Yehuda Katz"
31
31
  end
32
-
32
+
33
33
  describe "publisher" do
34
34
  it "should have a publisher" do
35
35
  subject.publisher.should_not be_nil
36
36
  subject.publisher.should include "Manning"
37
37
  end
38
-
38
+
39
39
  it "should standardize an Inc to Inc." do
40
40
  item['volumeInfo']['publisher'] = "Publisher Inc"
41
41
  book = Book.new(item)
42
42
  book.publisher.should eq "Publisher Inc."
43
43
  end
44
-
44
+
45
45
  it "should standardize an Llc to LLC." do
46
46
  item['volumeInfo']['publisher'] = "Publisher Llc"
47
47
  book = Book.new(item)
48
48
  book.publisher.should eq "Publisher LLC."
49
49
  end
50
-
50
+
51
51
  it "should standardize an Ltd to Ltd." do
52
52
  item['volumeInfo']['publisher'] = "Publisher Ltd"
53
53
  book = Book.new(item)
54
54
  book.publisher.should eq "Publisher Ltd."
55
55
  end
56
-
56
+
57
57
  it "should replace Intl with International anywhere in the name" do
58
58
  item['volumeInfo']['publisher'] = "Publisher Intl Clearing House"
59
59
  book = Book.new(item)
60
60
  book.publisher.should eq "Publisher International Clearing House"
61
61
  end
62
-
62
+
63
63
  it "should replace Pr with Press anywhere in the name" do
64
64
  item['volumeInfo']['publisher'] = "Publisher Pr House"
65
65
  book = Book.new(item)
66
66
  book.publisher.should eq "Publisher Press House"
67
67
  end
68
-
68
+
69
69
  it "should replace Pub with Publishers anywhere in the name" do
70
70
  item['volumeInfo']['publisher'] = "Publisher Pub, Inc"
71
71
  book = Book.new(item)
72
72
  book.publisher.should eq "Publisher Publishers Inc."
73
73
  end
74
-
74
+
75
75
  it "should replace Pubns with Publications anywhere in the name" do
76
76
  item['volumeInfo']['publisher'] = "Publisher Pubns Inc"
77
77
  book = Book.new(item)
78
78
  book.publisher.should eq "Publisher Publications Inc."
79
79
  end
80
-
80
+
81
81
  it "should replace Pub Group with Publishing Group anywhere in the name" do
82
82
  item['volumeInfo']['publisher'] = "Publisher Pub Group Inc"
83
83
  book = Book.new(item)
84
84
  book.publisher.should eq "Publisher Publishing Group Inc."
85
85
  end
86
-
86
+
87
87
  it "should replace Univ with University anywhere in the name" do
88
88
  item['volumeInfo']['publisher'] = "Publisher Univ Pr"
89
89
  book = Book.new(item)
90
90
  book.publisher.should eq "Publisher University Press"
91
91
  end
92
-
92
+
93
93
  it "should handle strings with apostrophes" do
94
94
  item['volumeInfo']['publisher'] = "O'Reilly Media, Inc."
95
95
  book = Book.new(item)
96
96
  book.publisher.should eq "O'Reilly Media Inc."
97
97
  end
98
98
  end
99
-
99
+
100
100
  describe "published_date" do
101
101
  it "should have a published date in sting format" do
102
102
  subject.published_date.should eq "2010-06-30"
@@ -107,42 +107,49 @@ module GoogleBooks
107
107
  book.published_date.should eq "2009"
108
108
  end
109
109
 
110
- it "should handle a published date that is only a month and a year" do
111
- book = API.search('isbn:9780954344405').first
112
- book.published_date.should eq "2003-01"
113
- end
110
+ # NOTE: This test was removed because this book no longer has just a month and year in Google's DB
111
+ # It returns 2003-01-01. They may have added the first day of the month as a default for these dates
112
+ # The spec is here for history, and in case a two digit date arises
113
+ # it "should handle a published date that is only a month and a year" do
114
+ # book = API.search('isbn:9780954344405').first
115
+ # book.published_date.should eq "2003-01"
116
+ # end
114
117
  end
115
-
118
+
116
119
  it "should have description (which may be blank)" do
117
120
  subject.description.should_not be_nil
118
121
  end
119
-
122
+
120
123
  it "should have an ISBN (13)" do
121
124
  subject.isbn.should eq '9781935182320'
122
125
  end
123
-
126
+
124
127
  it "should have an ISBN 10" do
125
128
  subject.isbn_10.should eq '1935182323'
126
129
  end
127
-
130
+
128
131
  it "should have a page count" do
129
132
  subject.page_count.should be_a Fixnum
130
- subject.page_count.should eq 475
133
+ subject.page_count.should eq 452
131
134
  end
132
-
133
- it "should have categories" do
135
+
136
+ it "should have categories even if there aren't any" do
134
137
  subject.categories.should be_an Array
135
- subject.categories.first.should eq "Computers"
136
138
  end
137
-
139
+
140
+ it "should fill in categories" do
141
+ book = API.search('isbn:9780596517748').first
142
+ book.categories.first.should eq "Computers"
143
+ end
144
+
138
145
  it "should have an average rating" do
139
146
  subject.average_rating.should be_a Float
140
147
  end
141
-
148
+
142
149
  it "should have an ratings count" do
143
150
  subject.ratings_count.should be_a Fixnum
144
151
  end
145
-
152
+
146
153
  describe "covers" do
147
154
  it "should contain a covers hash" do
148
155
  subject.covers.should be_a Hash
@@ -150,7 +157,7 @@ module GoogleBooks
150
157
  subject.covers.keys.should include :small
151
158
  subject.covers.keys.should include :medium
152
159
  subject.covers.keys.should include :large
153
- subject.covers.keys.should include :extra_large
160
+ subject.covers.keys.should include :extra_large
154
161
  end
155
162
 
156
163
  it "should not have curls on the cover urls" do
@@ -169,11 +176,11 @@ module GoogleBooks
169
176
  subject.covers[:extra_large].should include 'zoom=6'
170
177
  end
171
178
  end
172
-
179
+
173
180
  it "should contains a preview link" do
174
181
  subject.preview_link.should_not be_nil
175
182
  end
176
-
183
+
177
184
  it "should contains an info link" do
178
185
  subject.info_link.should_not be_nil
179
186
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_books
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,44 +9,59 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-18 00:00:00.000000000Z
12
+ date: 2013-07-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &70335070032720 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: 0.8.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70335070032720
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.1
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: hashie
27
- requirement: &70335070032220 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
- - - ~>
35
+ - - ! '>='
31
36
  - !ruby/object:Gem::Version
32
37
  version: 1.1.0
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70335070032220
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.1.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rake
38
- requirement: &70335070031760 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
- - - ~>
51
+ - - ! '>='
42
52
  - !ruby/object:Gem::Version
43
53
  version: 0.8.7
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70335070031760
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.8.7
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: autotest
49
- requirement: &70335070031300 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 4.4.6
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70335070031300
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 4.4.6
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: rspec
60
- requirement: &70335070030840 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: 2.6.0
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70335070030840
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 2.6.0
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: webmock
71
- requirement: &70335070030380 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: 1.7.6
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *70335070030380
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: 1.7.6
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: vcr
82
- requirement: &70335070029920 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ~>
@@ -87,7 +117,12 @@ dependencies:
87
117
  version: 1.11.3
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *70335070029920
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.11.3
91
126
  description: A Ruby wrapper that allows you to query the Google Books API. This project
92
127
  was inspired by google-book, see the README for more information
93
128
  email:
@@ -98,10 +133,8 @@ extra_rdoc_files: []
98
133
  files:
99
134
  - .gitignore
100
135
  - .rspec
101
- - .rvmrc
102
136
  - CHANGELOG.md
103
137
  - Gemfile
104
- - Gemfile.lock
105
138
  - LICENSE
106
139
  - README.md
107
140
  - Rakefile
@@ -130,15 +163,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
163
  - - ! '>='
131
164
  - !ruby/object:Gem::Version
132
165
  version: '0'
166
+ segments:
167
+ - 0
168
+ hash: -899561922856148199
133
169
  required_rubygems_version: !ruby/object:Gem::Requirement
134
170
  none: false
135
171
  requirements:
136
172
  - - ! '>='
137
173
  - !ruby/object:Gem::Version
138
174
  version: '0'
175
+ segments:
176
+ - 0
177
+ hash: -899561922856148199
139
178
  requirements: []
140
179
  rubyforge_project:
141
- rubygems_version: 1.8.6
180
+ rubygems_version: 1.8.25
142
181
  signing_key:
143
182
  specification_version: 3
144
183
  summary: A Ruby wrapper around the Google Books API
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm --create use 1.9.2@google_books
@@ -1,70 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- google_books (0.2.0)
5
- hashie (~> 1.1.0)
6
- httparty (~> 0.8.1)
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- ZenTest (4.6.2)
12
- addressable (2.2.6)
13
- archive-tar-minitar (0.5.2)
14
- autotest (4.4.6)
15
- ZenTest (>= 4.4.1)
16
- columnize (0.3.4)
17
- crack (0.3.1)
18
- diff-lcs (1.1.3)
19
- hashie (1.1.0)
20
- httparty (0.8.1)
21
- multi_json
22
- multi_xml
23
- linecache (0.46)
24
- rbx-require-relative (> 0.0.4)
25
- linecache19 (0.5.12)
26
- ruby_core_source (>= 0.1.4)
27
- multi_json (1.0.3)
28
- multi_xml (0.4.1)
29
- rake (0.8.7)
30
- rbx-require-relative (0.0.5)
31
- rspec (2.6.0)
32
- rspec-core (~> 2.6.0)
33
- rspec-expectations (~> 2.6.0)
34
- rspec-mocks (~> 2.6.0)
35
- rspec-core (2.6.4)
36
- rspec-expectations (2.6.0)
37
- diff-lcs (~> 1.1.2)
38
- rspec-mocks (2.6.0)
39
- ruby-debug (0.10.4)
40
- columnize (>= 0.1)
41
- ruby-debug-base (~> 0.10.4.0)
42
- ruby-debug-base (0.10.4)
43
- linecache (>= 0.3)
44
- ruby-debug-base19 (0.11.25)
45
- columnize (>= 0.3.1)
46
- linecache19 (>= 0.5.11)
47
- ruby_core_source (>= 0.1.4)
48
- ruby-debug19 (0.11.6)
49
- columnize (>= 0.3.1)
50
- linecache19 (>= 0.5.11)
51
- ruby-debug-base19 (>= 0.11.19)
52
- ruby_core_source (0.1.5)
53
- archive-tar-minitar (>= 0.5.2)
54
- vcr (1.11.3)
55
- webmock (1.7.6)
56
- addressable (~> 2.2, > 2.2.5)
57
- crack (>= 0.1.7)
58
-
59
- PLATFORMS
60
- ruby
61
-
62
- DEPENDENCIES
63
- autotest (~> 4.4.6)
64
- google_books!
65
- rake (~> 0.8.7)
66
- rspec (~> 2.6.0)
67
- ruby-debug
68
- ruby-debug19
69
- vcr (~> 1.11.3)
70
- webmock (~> 1.7.6)