google-book 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/google.gemspec CHANGED
@@ -14,9 +14,10 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = 'google-book'
16
16
 
17
- s.add_dependency('bookland', ['~> 1.0.0'])
18
- s.add_dependency('httparty', ['~> 0.7.4'])
19
- s.add_development_dependency('rspec', ['~> 2.5.0'])
17
+ s.add_dependency('bookland', '~> 1.0.0')
18
+ s.add_dependency('httparty', '~> 0.7.4')
19
+ s.add_development_dependency('rspec', '~> 2.5.0')
20
+ s.add_development_dependency('ruby-debug19', '~> 0.11.6')
20
21
  s.add_development_dependency('vcr', '~> 1.7.0')
21
22
  s.add_development_dependency('webmock', '~> 1.6.2')
22
23
 
@@ -6,6 +6,8 @@ module Google
6
6
  end
7
7
 
8
8
  def to_books
9
+ return [] if total_results == 0
10
+
9
11
  [@feed['entry']].flatten.map do |hash|
10
12
  book = Struct.new(
11
13
  Cover.new(hash['link'][0]['href']),
@@ -27,9 +27,12 @@ module Google
27
27
  def formatted_publisher
28
28
  publisher.
29
29
  gsub(/[ ,]+Inc.?$/, '').
30
+ gsub(/[ ,]+Llc.?$/i, '').
31
+ gsub(/[ ,]+Ltd.?$/, '').
30
32
  gsub(/Intl( |$)/) { "International#{$1}" }.
31
33
  gsub(/Pr( |$)/) { "Press#{$1}" }.
32
34
  gsub(/ Pub$/, ' Publishers').
35
+ gsub(/ Pubns$/, ' Publications').
33
36
  gsub('Pub Group', 'Publishing Group').
34
37
  gsub(/Univ( |$)/) { "University#{$1}" }
35
38
  end
@@ -1,5 +1,5 @@
1
1
  module Google
2
2
  module Book
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
@@ -5,22 +5,25 @@ module Google
5
5
  describe Response do
6
6
  use_vcr_cassette 'google'
7
7
 
8
- let(:response) do
9
- Request.find('deleuze')
10
- end
11
-
12
8
  it "should set total results" do
9
+ response = Request.find('deleuze')
13
10
  response.total_results.should > 0
14
11
  end
15
12
 
16
13
  it "should return books" do
14
+ response = Request.find('deleuze')
17
15
  books = response.to_books
16
+
18
17
  books.first.should be_a Struct
19
18
  end
20
19
 
21
20
  it "should handle single matches" do
22
21
  Request.find('9780826490780').to_books.first.should be_a Struct
23
22
  end
23
+
24
+ it "should handle an empty query" do
25
+ Request.find('').to_books.should be_empty
26
+ end
24
27
  end
25
28
  end
26
29
  end
@@ -36,7 +36,7 @@ module Google
36
36
  end
37
37
 
38
38
  describe "#formatted_publisher" do
39
- it "should drop Inc at the end of the word" do
39
+ it "should drop Inc at the end of the name" do
40
40
  book.publisher = 'Publisher Inc'
41
41
  book.formatted_publisher.should eql 'Publisher'
42
42
 
@@ -44,6 +44,19 @@ module Google
44
44
  book.formatted_publisher.should eql 'Random House'
45
45
  end
46
46
 
47
+ it "should drop Llc at the end of the name" do
48
+ book.publisher = 'Publisher Llc'
49
+ book.formatted_publisher.should eql 'Publisher'
50
+
51
+ book.publisher = 'Publisher LLC'
52
+ book.formatted_publisher.should eql 'Publisher'
53
+ end
54
+
55
+ it "should drop Ltd at the end of the name" do
56
+ book.publisher = 'Publisher Ltd'
57
+ book.formatted_publisher.should eql 'Publisher'
58
+ end
59
+
47
60
  it "should format Intl" do
48
61
  book.publisher = 'Continuum Intl'
49
62
  book.formatted_publisher.should eql 'Continuum International'
@@ -54,22 +67,27 @@ module Google
54
67
  book.formatted_publisher.should eql 'Polity Press'
55
68
  end
56
69
 
57
- it "should format Pub" do
70
+ it "should format Pub at the end of the name" do
58
71
  book.publisher = 'Rowman & Littlefield Pub'
59
72
  book.formatted_publisher.should eql 'Rowman & Littlefield Publishers'
60
73
  end
61
74
 
75
+ it "should format Pubns at the end of the name" do
76
+ book.publisher = 'Publisher Pubns'
77
+ book.formatted_publisher.should eql 'Publisher Publications'
78
+ end
79
+
62
80
  it "should format Pub Group" do
63
81
  book.publisher = 'Continuum International Pub Group'
64
82
  book.formatted_publisher.should eql 'Continuum International Publishing Group'
65
83
  end
66
84
 
67
- it "should format Univ in the middle of the word" do
85
+ it "should format Univ in the middle of the name" do
68
86
  book.publisher = 'Columbia Univ Press'
69
87
  book.formatted_publisher.should eql 'Columbia University Press'
70
88
  end
71
89
 
72
- it "should format Univ at the end of the word" do
90
+ it "should format Univ at the end of the name" do
73
91
  book.publisher = 'Columbia Univ'
74
92
  book.formatted_publisher.should eql 'Columbia University'
75
93
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: google-book
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paper Cavalier
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-05 00:00:00 +00:00
13
+ date: 2011-03-06 00:00:00 +00:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -47,27 +47,38 @@ dependencies:
47
47
  type: :development
48
48
  version_requirements: *id003
49
49
  - !ruby/object:Gem::Dependency
50
- name: vcr
50
+ name: ruby-debug19
51
51
  prerelease: false
52
52
  requirement: &id004 !ruby/object:Gem::Requirement
53
53
  none: false
54
54
  requirements:
55
55
  - - ~>
56
56
  - !ruby/object:Gem::Version
57
- version: 1.7.0
57
+ version: 0.11.6
58
58
  type: :development
59
59
  version_requirements: *id004
60
60
  - !ruby/object:Gem::Dependency
61
- name: webmock
61
+ name: vcr
62
62
  prerelease: false
63
63
  requirement: &id005 !ruby/object:Gem::Requirement
64
64
  none: false
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 1.6.2
68
+ version: 1.7.0
69
69
  type: :development
70
70
  version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: webmock
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: 1.6.2
80
+ type: :development
81
+ version_requirements: *id006
71
82
  description: Google Book is a Ruby wrapper to the Google Book Search Data API.
72
83
  email:
73
84
  - code@papercavalier.com