isbndb 1.5.5 → 2.0.0
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 +19 -0
- data/.rspec +1 -0
- data/.rvmrc +48 -0
- data/.travis.yml +6 -0
- data/Gemfile +2 -14
- data/Gemfile.lock +41 -21
- data/README.markdown +118 -102
- data/Rakefile +6 -46
- data/config/isbndb.example.yml +3 -0
- data/isbndb.gemspec +19 -73
- data/lib/core_extensions/nil.rb +5 -0
- data/lib/core_extensions/string.rb +49 -0
- data/lib/isbndb.rb +9 -113
- data/lib/isbndb/access_key_set.rb +31 -20
- data/lib/isbndb/exceptions.rb +1 -2
- data/lib/isbndb/query.rb +78 -0
- data/lib/isbndb/result.rb +38 -39
- data/lib/isbndb/result_set.rb +32 -33
- data/spec/responses/access_key_error.xml +5 -0
- data/spec/responses/authors_seth.xml +46 -0
- data/spec/responses/books_hello.xml +76 -0
- data/spec/responses/categories_fiction.xml +46 -0
- data/spec/responses/keystats.xml +6 -0
- data/spec/responses/publishers_francis.xml +46 -0
- data/spec/responses/search.xml +76 -0
- data/spec/responses/subjects_ruby.xml +36 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/helpers.rb +8 -0
- data/spec/units/access_key_set_spec.rb +98 -0
- data/spec/units/nil_spec.rb +9 -0
- data/spec/units/query_spec.rb +179 -0
- data/spec/units/result_set_spec.rb +89 -0
- data/spec/units/result_spec.rb +105 -0
- data/spec/units/string_spec.rb +118 -0
- metadata +110 -81
- data/.document +0 -5
- data/ACKNOWLEDGEMENTS +0 -3
- data/LICENSE.txt +0 -20
- data/VERSION +0 -1
- data/test/helper.rb +0 -23
- data/test/test_isbndb.rb +0 -77
data/.document
DELETED
data/ACKNOWLEDGEMENTS
DELETED
data/LICENSE.txt
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2011 Seth Vargo
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.5.5
|
data/test/helper.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
# Set up gems listed in the Gemfile.
|
3
|
-
gemfile = File.expand_path('../../Gemfile', __FILE__)
|
4
|
-
begin
|
5
|
-
ENV['BUNDLE_GEMFILE'] = gemfile
|
6
|
-
require 'bundler'
|
7
|
-
Bundler.setup
|
8
|
-
rescue Bundler::GemNotFound => e
|
9
|
-
STDERR.puts e.message
|
10
|
-
STDERR.puts "Try running `bundle install`."
|
11
|
-
exit!
|
12
|
-
end if File.exist?(gemfile)
|
13
|
-
|
14
|
-
|
15
|
-
require 'test/unit'
|
16
|
-
require 'shoulda'
|
17
|
-
|
18
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
19
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
20
|
-
require 'isbndb'
|
21
|
-
|
22
|
-
class Test::Unit::TestCase
|
23
|
-
end
|
data/test/test_isbndb.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
class TestISBNdb < Test::Unit::TestCase
|
4
|
-
context "ISBNdb" do
|
5
|
-
setup do
|
6
|
-
@query = ISBNdb::Query.new('KXWFXJIK')
|
7
|
-
end
|
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 'fail nicely on a bad ISBN' do
|
20
|
-
@book = @query.find_book_by_isbn('9780141033013').first
|
21
|
-
assert_nil @book
|
22
|
-
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
|
77
|
-
end
|