titlepage 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require 'rake/testtask'
6
6
  require "rake/gempackagetask"
7
7
  require 'spec/rake/spectask'
8
8
 
9
- PKG_VERSION = "1.0.0"
9
+ PKG_VERSION = "1.1.0"
10
10
  PKG_NAME = "titlepage"
11
11
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
12
12
  RUBYFORGE_PROJECT = 'rbook'
@@ -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.find("0091835135").inspect
10
+ puts tp.first("0091835135").inspect
11
11
  sleep 3
12
- puts tp.find("1741146712").inspect
12
+ puts tp.all("1741146712").inspect
13
13
 
14
14
  end
@@ -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
- begin
49
- results = @driver.search_by_isbn13(@token, isbn)
59
+ @driver.search_by_isbn13(@token, isbn)
60
+ end
50
61
 
51
- if results.size == 0
52
- return nil
53
- else
54
- return results.first
55
- end
56
- end
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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: titlepage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Healy