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/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
@@ -1,3 +0,0 @@
1
- Special thanks to Terje Tjervaag (https://github.com/terje) for giving up the gem name 'isbndb'!
2
-
3
- Special thanks to Lazlo (https://github.com/lazlo) for forwarding his project here!
@@ -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
@@ -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
@@ -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