isbndb 1.5.4 → 1.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,12 +2,14 @@ source "http://rubygems.org"
2
2
 
3
3
  gem 'activesupport'
4
4
  gem 'i18n'
5
+ gem 'rake'
6
+ gem 'rdoc'
5
7
  gem 'libxml-ruby', '>= 1.1.4'
6
8
 
7
9
  # Include everything needed to run rake, tests, features, etc.
8
10
  group :development do
9
- gem "shoulda", ">= 0"
10
- gem "bundler"
11
- gem "jeweler"
12
- gem "rcov", ">= 0"
11
+ gem 'shoulda', '>= 0'
12
+ gem 'bundler'
13
+ gem 'jeweler'
14
+ gem 'rcov', '>= 0'
13
15
  end
@@ -1,16 +1,17 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- activesupport (3.0.5)
4
+ activesupport (3.0.9)
5
5
  git (1.2.5)
6
- i18n (0.5.0)
7
- jeweler (1.5.2)
8
- bundler (~> 1.0.0)
6
+ i18n (0.6.0)
7
+ jeweler (1.6.2)
8
+ bundler (~> 1.0)
9
9
  git (>= 1.2.5)
10
10
  rake
11
- libxml-ruby (1.1.4)
12
- rake (0.8.7)
11
+ libxml-ruby (2.0.6)
12
+ rake (0.9.2)
13
13
  rcov (0.9.9)
14
+ rdoc (3.6.1)
14
15
  shoulda (2.11.3)
15
16
 
16
17
  PLATFORMS
@@ -22,5 +23,7 @@ DEPENDENCIES
22
23
  i18n
23
24
  jeweler
24
25
  libxml-ruby (>= 1.1.4)
26
+ rake
25
27
  rcov
28
+ rdoc
26
29
  shoulda
@@ -170,6 +170,10 @@ Here is a real-life example of how to use Ruby ISBNdb. Imagine a Rails applicati
170
170
  <p><strong>authors</strong>: <%= book.authors_text %></p>
171
171
  </div>
172
172
  <% end %>
173
+
174
+ Testing
175
+ -------
176
+ [![Build Status](http://travis-ci.org/sethvargo/isbndb.png)](http://travis-ci.org/sethvargo/isbndb)
173
177
 
174
178
  Know Bugs and Limitations
175
179
  -------------------------
data/Rakefile CHANGED
@@ -38,8 +38,8 @@ end
38
38
 
39
39
  task :default => :test
40
40
 
41
- require 'rake/rdoctask'
42
- Rake::RDocTask.new do |rdoc|
41
+ require 'rdoc/task'
42
+ RDoc::Task.new do |rdoc|
43
43
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
44
 
45
45
  rdoc.rdoc_dir = 'rdoc'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.5.4
1
+ 1.5.5
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{isbndb}
8
- s.version = "1.5.4"
8
+ s.version = "1.5.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Seth Vargo"]
12
- s.date = %q{2011-04-21}
11
+ s.authors = [%q{Seth Vargo}]
12
+ s.date = %q{2011-06-23}
13
13
  s.description = %q{Ruby ISBNdb is a amazingly fast and accurate gem that reads ISBNdb.com's XML API and gives you incredible flexibilty with the results! The gem uses libxml-ruby, the fastest XML parser for Ruby, so you get blazing fast results every time. Additionally, the newest version of the gem also features caching, so developers minimize API-key usage.}
14
14
  s.email = %q{seth.vargo@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -35,14 +35,10 @@ Gem::Specification.new do |s|
35
35
  "test/test_isbndb.rb"
36
36
  ]
37
37
  s.homepage = %q{https://github.com/sethvargo/isbndb}
38
- s.licenses = ["MIT"]
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = %q{1.7.2}
38
+ s.licenses = [%q{MIT}]
39
+ s.require_paths = [%q{lib}]
40
+ s.rubygems_version = %q{1.8.5}
41
41
  s.summary = %q{This gem provides an easy solution for connecting to ISBNdb.com's API}
42
- s.test_files = [
43
- "test/helper.rb",
44
- "test/test_isbndb.rb"
45
- ]
46
42
 
47
43
  if s.respond_to? :specification_version then
48
44
  s.specification_version = 3
@@ -50,6 +46,8 @@ Gem::Specification.new do |s|
50
46
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
47
  s.add_runtime_dependency(%q<activesupport>, [">= 0"])
52
48
  s.add_runtime_dependency(%q<i18n>, [">= 0"])
49
+ s.add_runtime_dependency(%q<rake>, [">= 0"])
50
+ s.add_runtime_dependency(%q<rdoc>, [">= 0"])
53
51
  s.add_runtime_dependency(%q<libxml-ruby>, [">= 1.1.4"])
54
52
  s.add_development_dependency(%q<shoulda>, [">= 0"])
55
53
  s.add_development_dependency(%q<bundler>, [">= 0"])
@@ -58,6 +56,8 @@ Gem::Specification.new do |s|
58
56
  else
59
57
  s.add_dependency(%q<activesupport>, [">= 0"])
60
58
  s.add_dependency(%q<i18n>, [">= 0"])
59
+ s.add_dependency(%q<rake>, [">= 0"])
60
+ s.add_dependency(%q<rdoc>, [">= 0"])
61
61
  s.add_dependency(%q<libxml-ruby>, [">= 1.1.4"])
62
62
  s.add_dependency(%q<shoulda>, [">= 0"])
63
63
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -67,6 +67,8 @@ Gem::Specification.new do |s|
67
67
  else
68
68
  s.add_dependency(%q<activesupport>, [">= 0"])
69
69
  s.add_dependency(%q<i18n>, [">= 0"])
70
+ s.add_dependency(%q<rake>, [">= 0"])
71
+ s.add_dependency(%q<rdoc>, [">= 0"])
70
72
  s.add_dependency(%q<libxml-ruby>, [">= 1.1.4"])
71
73
  s.add_dependency(%q<shoulda>, [">= 0"])
72
74
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -73,7 +73,10 @@ module ISBNdb
73
73
  # each child. This method works because the API always returns #{@collection}List followed by a subset
74
74
  # of #{@collection}Data. These results are all pushed into the @results array for accessing.
75
75
  def build_results
76
- @xml.find("#{@collection}List/#{@collection}Data").collect { |node| (@results ||= []) << Result.new(node) }
76
+ @results = []
77
+ list = @xml.find("#{@collection}List/#{@collection}Data")
78
+ return [nil] if list.empty?
79
+ list.collect { |node| @results << Result.new(node) }
77
80
  end
78
81
 
79
82
  # This helper method is mainly designed for use with the go_to_page(page) method. It parses the XML
@@ -6,66 +6,72 @@ class TestISBNdb < Test::Unit::TestCase
6
6
  @query = ISBNdb::Query.new('KXWFXJIK')
7
7
  end
8
8
 
9
- # should "fetch a book by ISBN" do
10
- # @book = @query.find_book_by_isbn('1934356549').first
11
- # assert_equal '1934356549', @book.isbn
12
- # end
13
- #
14
- # should "fetch a book by ISBN13" do
15
- # @book = @query.find_book_by_isbn('9781934356548').first
16
- # assert_equal '9781934356548', @book.isbn13
17
- # end
18
- #
19
- # should 'fetch books by title' do
20
- # @books = @query.find_books_by_title('ruby')
21
- # @books.each do |book|
22
- # assert (book.title || "").downcase.include?('ruby') || (book.title_long || "").downcase.include?('ruby'), "#{book.title} did not contain 'ruby'"
23
- # end
24
- # end
25
- #
26
- # should 'get next_page and prev_page' do
27
- # @books = @query.find_books_by_title('ruby')
28
- # next_page = @books.next_page
29
- # assert_equal @books.first.title, next_page.prev_page.first.title, 'Failed to get next_page'
30
- # end
31
- #
32
- # should 'get keystats' do
33
- # assert @query.keystats.is_a?(Hash), "#{@query.keystats} was not a Hash"
34
- # assert @query.keystats[:requests] >= @query.keystats[:granted], "Number of requests (#{@query.keystats[:requests]}) was not greater than number of granted requests (#{@query.keystats[:granted]})"
35
- # assert @query.keystats[:requests] > 0 && @query.keystats[:requests] < 500, 'Requests were not between 0 and 500'
36
- # end
37
- #
38
- # should 'test access_key_set' do
39
- # @query = ISBNdb::Query.new(['API-KEY-1', 'API-KEY-2', 'API-KEY-3'])
40
- # @access_key_set = @query.access_key_set
41
- # assert_equal 'API-KEY-1', @access_key_set.current_key
42
- # assert_equal 'API-KEY-2', @access_key_set.next_key
43
- # @access_key_set.next_key!
44
- # assert_equal 'API-KEY-1', @access_key_set.prev_key
45
- # @access_key_set.use_key('A-NEW-KEY')
46
- # assert_equal 'A-NEW-KEY', @access_key_set.current_key
47
- # @access_key_set.use_key('API-KEY-3')
48
- # assert_equal 'API-KEY-3', @access_key_set.current_key
49
- # end
50
- #
51
- # should 'raise exception for an invalid access key' do
52
- # @invalid = ISBNdb::Query.new(['abc123foobar', '123anotherinvalidkey'])
53
- # assert_raise ISBNdb::AccessKeyError, "#{@invalid} did not raise AccessKeyError" do
54
- # @invalid.find_book_by_isbn('1934356549')
55
- # end
56
- # end
57
- #
58
- # should 'raise exception for an invalid uri' do
59
- # assert_raise ISBNdb::InvalidURIError, "@query.find_invalid_by_unknown did not raise InvalidURIError" do
60
- # @query.find_invalid_by_unknown('foobar')
61
- # end
62
- # end
9
+ should "fetch a book by ISBN" do
10
+ @book = @query.find_book_by_isbn('1934356549').first
11
+ assert_equal '1934356549', @book.isbn
12
+ end
13
+
14
+ should "fetch a book by ISBN13" do
15
+ @book = @query.find_book_by_isbn('9781934356548').first
16
+ assert_equal '9781934356548', @book.isbn13
17
+ end
63
18
 
64
- should 'make sub-result sets' do
65
- @books = @query.find(:collection => 'books', :where => { :title => 'vargo' }, :results => 'prices')
66
- @books.each do |book|
67
- #puts book
68
- end
19
+ should 'fail nicely on a bad ISBN' do
20
+ @book = @query.find_book_by_isbn('9780141033013').first
21
+ assert_nil @book
69
22
  end
70
- end
23
+
24
+ should 'fetch books by title' do
25
+ @books = @query.find_books_by_title('ruby')
26
+ @books.each do |book|
27
+ assert (book.title || "").downcase.include?('ruby') || (book.title_long || "").downcase.include?('ruby'), "#{book.title} did not contain 'ruby'"
28
+ end
29
+ end
30
+
31
+ should 'get next_page and prev_page' do
32
+ @books = @query.find_books_by_title('ruby')
33
+ next_page = @books.next_page
34
+ assert_equal @books.first.title, next_page.prev_page.first.title, 'Failed to get next_page'
35
+ end
36
+
37
+ should 'get keystats' do
38
+ assert @query.keystats.is_a?(Hash), "#{@query.keystats} was not a Hash"
39
+ assert @query.keystats[:requests].to_i >= @query.keystats[:granted].to_i, "Number of requests (#{@query.keystats[:requests]}) was not greater than number of granted requests (#{@query.keystats[:granted]})"
40
+ assert @query.keystats[:requests].to_i > 0 && @query.keystats[:requests].to_i < 500, 'Requests were not between 0 and 500'
41
+ end
42
+
43
+ should 'test access_key_set' do
44
+ @query = ISBNdb::Query.new(['API-KEY-1', 'API-KEY-2', 'API-KEY-3'])
45
+ @access_key_set = @query.access_key_set
46
+ assert_equal 'API-KEY-1', @access_key_set.current_key
47
+ assert_equal 'API-KEY-2', @access_key_set.next_key
48
+ @access_key_set.next_key!
49
+ assert_equal 'API-KEY-1', @access_key_set.prev_key
50
+ @access_key_set.use_key('A-NEW-KEY')
51
+ assert_equal 'A-NEW-KEY', @access_key_set.current_key
52
+ @access_key_set.use_key('API-KEY-3')
53
+ assert_equal 'API-KEY-3', @access_key_set.current_key
54
+ end
55
+
56
+ should 'raise exception for an invalid access key' do
57
+ @invalid = ISBNdb::Query.new(['abc123foobar', '123anotherinvalidkey'])
58
+ assert_raise ISBNdb::AccessKeyError, "#{@invalid} did not raise AccessKeyError" do
59
+ @invalid.find_book_by_isbn('1934356549')
60
+ end
61
+ end
62
+
63
+ should 'raise exception for an invalid uri' do
64
+ assert_raise ISBNdb::InvalidURIError, "@query.find_invalid_by_unknown did not raise InvalidURIError" do
65
+ @query.find_invalid_by_unknown('foobar')
66
+ end
67
+ end
68
+
69
+ # This isn't done yet...
70
+ should 'make sub-result sets' do
71
+ @books = @query.find(:collection => 'books', :where => { :title => 'vargo' }, :results => 'prices')
72
+ @books.each do |book|
73
+ #puts book
74
+ end
75
+ end
76
+ end
71
77
  end
metadata CHANGED
@@ -1,104 +1,127 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: isbndb
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.5
4
5
  prerelease:
5
- version: 1.5.4
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Seth Vargo
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-04-21 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-06-23 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: activesupport
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2154230480 !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2154230480
25
+ - !ruby/object:Gem::Dependency
27
26
  name: i18n
28
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &2154229980 !ruby/object:Gem::Requirement
29
28
  none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *2154229980
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &2154229200 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2154229200
47
+ - !ruby/object:Gem::Dependency
48
+ name: rdoc
49
+ requirement: &2154228380 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *2154228380
58
+ - !ruby/object:Gem::Dependency
38
59
  name: libxml-ruby
39
- requirement: &id003 !ruby/object:Gem::Requirement
60
+ requirement: &2154227540 !ruby/object:Gem::Requirement
40
61
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
44
65
  version: 1.1.4
45
66
  type: :runtime
46
67
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *2154227540
69
+ - !ruby/object:Gem::Dependency
49
70
  name: shoulda
50
- requirement: &id004 !ruby/object:Gem::Requirement
71
+ requirement: &2154226720 !ruby/object:Gem::Requirement
51
72
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
56
77
  type: :development
57
78
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *2154226720
80
+ - !ruby/object:Gem::Dependency
60
81
  name: bundler
61
- requirement: &id005 !ruby/object:Gem::Requirement
82
+ requirement: &2154226020 !ruby/object:Gem::Requirement
62
83
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
67
88
  type: :development
68
89
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *2154226020
91
+ - !ruby/object:Gem::Dependency
71
92
  name: jeweler
72
- requirement: &id006 !ruby/object:Gem::Requirement
93
+ requirement: &2154225440 !ruby/object:Gem::Requirement
73
94
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
78
99
  type: :development
79
100
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
101
+ version_requirements: *2154225440
102
+ - !ruby/object:Gem::Dependency
82
103
  name: rcov
83
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ requirement: &2154224760 !ruby/object:Gem::Requirement
84
105
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
89
110
  type: :development
90
111
  prerelease: false
91
- version_requirements: *id007
92
- description: Ruby ISBNdb is a amazingly fast and accurate gem that reads ISBNdb.com's XML API and gives you incredible flexibilty with the results! The gem uses libxml-ruby, the fastest XML parser for Ruby, so you get blazing fast results every time. Additionally, the newest version of the gem also features caching, so developers minimize API-key usage.
112
+ version_requirements: *2154224760
113
+ description: Ruby ISBNdb is a amazingly fast and accurate gem that reads ISBNdb.com's
114
+ XML API and gives you incredible flexibilty with the results! The gem uses libxml-ruby,
115
+ the fastest XML parser for Ruby, so you get blazing fast results every time. Additionally,
116
+ the newest version of the gem also features caching, so developers minimize API-key
117
+ usage.
93
118
  email: seth.vargo@gmail.com
94
119
  executables: []
95
-
96
120
  extensions: []
97
-
98
- extra_rdoc_files:
121
+ extra_rdoc_files:
99
122
  - LICENSE.txt
100
123
  - README.markdown
101
- files:
124
+ files:
102
125
  - .document
103
126
  - ACKNOWLEDGEMENTS
104
127
  - Gemfile
@@ -116,35 +139,31 @@ files:
116
139
  - test/helper.rb
117
140
  - test/test_isbndb.rb
118
141
  homepage: https://github.com/sethvargo/isbndb
119
- licenses:
142
+ licenses:
120
143
  - MIT
121
144
  post_install_message:
122
145
  rdoc_options: []
123
-
124
- require_paths:
146
+ require_paths:
125
147
  - lib
126
- required_ruby_version: !ruby/object:Gem::Requirement
148
+ required_ruby_version: !ruby/object:Gem::Requirement
127
149
  none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 4519594731805575555
132
- segments:
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ segments:
133
155
  - 0
134
- version: "0"
135
- required_rubygems_version: !ruby/object:Gem::Requirement
156
+ hash: 3725550696331158843
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
158
  none: false
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- version: "0"
159
+ requirements:
160
+ - - ! '>='
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
141
163
  requirements: []
142
-
143
164
  rubyforge_project:
144
- rubygems_version: 1.7.2
165
+ rubygems_version: 1.8.5
145
166
  signing_key:
146
167
  specification_version: 3
147
168
  summary: This gem provides an easy solution for connecting to ISBNdb.com's API
148
- test_files:
149
- - test/helper.rb
150
- - test/test_isbndb.rb
169
+ test_files: []