isbn 2.0.1 → 2.0.2
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 +2 -0
- data/VERSION +1 -1
- data/lib/isbn.rb +3 -0
- data/test/isbn_spec.rb +4 -0
- metadata +2 -2
data/Rakefile
CHANGED
@@ -8,6 +8,8 @@ begin
|
|
8
8
|
s.description = "library to transform ISBN\'s from new to used, between 10 and 13, etc..."
|
9
9
|
s.authors = ["Tim Kersey"]
|
10
10
|
end
|
11
|
+
|
12
|
+
Jeweler::GemcutterTasks
|
11
13
|
rescue LoadError
|
12
14
|
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
13
15
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.
|
1
|
+
2.0.2
|
data/lib/isbn.rb
CHANGED
@@ -2,6 +2,7 @@ module ISBN
|
|
2
2
|
extend self
|
3
3
|
|
4
4
|
def ten(isbn)
|
5
|
+
raise InvalidISBNError unless isbn.is_a? String
|
5
6
|
isbn = isbn.delete("-")
|
6
7
|
raise No10DigitISBNAvailable if isbn =~ /^979/
|
7
8
|
case isbn.size
|
@@ -17,6 +18,8 @@ module ISBN
|
|
17
18
|
end
|
18
19
|
|
19
20
|
def thirteen(isbn)
|
21
|
+
raise InvalidISBNError unless isbn.is_a? String
|
22
|
+
raise Invalid13DigitISBN unless isbn.size.between?(10,13)
|
20
23
|
isbn = isbn.delete("-")
|
21
24
|
isbn = isbn.rjust(13,"978")[/(.+)\w/,1] # adjust to 13 digit isbn and remove check digit
|
22
25
|
raise Invalid13DigitISBN unless isbn.size == 12 # after adjustments isbn should be 12 digits
|
data/test/isbn_spec.rb
CHANGED
@@ -20,6 +20,8 @@ describe ISBN do
|
|
20
20
|
end
|
21
21
|
proc { ISBN.ten("9790879392788") }.must_raise ISBN::No10DigitISBNAvailable
|
22
22
|
proc { ISBN.ten("074324382") }.must_raise ISBN::Invalid10DigitISBN
|
23
|
+
proc { ISBN.ten("") }.must_raise ISBN::Invalid10DigitISBN
|
24
|
+
proc { ISBN.ten(nil) }.must_raise ISBN::InvalidISBNError
|
23
25
|
end
|
24
26
|
|
25
27
|
it "should respond with a thirteen digit isbn" do
|
@@ -28,6 +30,8 @@ describe ISBN do
|
|
28
30
|
ISBN.thirteen(isbn[1]).must_equal isbn[1]
|
29
31
|
end
|
30
32
|
proc { ISBN.thirteen("97908793927888") }.must_raise ISBN::Invalid13DigitISBN
|
33
|
+
proc { ISBN.thirteen(nil) }.must_raise ISBN::InvalidISBNError
|
34
|
+
proc { ISBN.thirteen("") }.must_raise ISBN::Invalid13DigitISBN
|
31
35
|
end
|
32
36
|
|
33
37
|
it "should convert a NEW isbn into USED" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isbn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Kersey
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-20 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|