titlepage 1.0.0 → 1.1.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/Rakefile +1 -1
- data/examples/titlepage.rb +2 -2
- data/lib/titlepage/client.rb +20 -9
- metadata +1 -1
data/Rakefile
CHANGED
data/examples/titlepage.rb
CHANGED
@@ -7,8 +7,8 @@ require File.dirname(__FILE__) + '/../lib/titlepage'
|
|
7
7
|
|
8
8
|
TitlePage::Client.open("username", "password") do |tp|
|
9
9
|
|
10
|
-
puts tp.
|
10
|
+
puts tp.first("0091835135").inspect
|
11
11
|
sleep 3
|
12
|
-
puts tp.
|
12
|
+
puts tp.all("1741146712").inspect
|
13
13
|
|
14
14
|
end
|
data/lib/titlepage/client.rb
CHANGED
@@ -41,19 +41,30 @@ module TitlePage
|
|
41
41
|
|
42
42
|
# Retrieve information on a specified ISBN. Can be an ISBN10 or ISBN13.
|
43
43
|
#
|
44
|
-
def find(isbn)
|
44
|
+
def find(type, isbn)
|
45
|
+
case type
|
46
|
+
when :first
|
47
|
+
first(isbn)
|
48
|
+
when :all
|
49
|
+
all(isbn)
|
50
|
+
else
|
51
|
+
raise ArgumentError, "invalid type #{type}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def all(isbn)
|
45
56
|
return NotLoggedInError, 'You must login to titlepage API before performing a search' unless @token
|
46
57
|
isbn = RBook::ISBN::convert_to_isbn13(isbn)
|
47
58
|
return nil if isbn.nil?
|
48
|
-
|
49
|
-
|
59
|
+
@driver.search_by_isbn13(@token, isbn)
|
60
|
+
end
|
50
61
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
62
|
+
def first(isbn)
|
63
|
+
all(isbn).first
|
64
|
+
end
|
65
|
+
|
66
|
+
def last(isbn)
|
67
|
+
all(isbn).last
|
57
68
|
end
|
58
69
|
|
59
70
|
# a convenience method to make single queries to title page a little cleaner.
|