bookworm 0.1.0 → 0.1.1
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/bookworm.gemspec +3 -3
- data/lib/bookworm.rb +8 -2
- data/test/bookworm_test.rb +1 -0
- metadata +4 -4
data/bookworm.gemspec
CHANGED
@@ -3,12 +3,12 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "bookworm"
|
6
|
-
s.version = "0.1.
|
6
|
+
s.version = "0.1.1"
|
7
7
|
s.authors = ["Tyler Johnston"]
|
8
8
|
s.email = ["tylerjohnst@gmail.com"]
|
9
9
|
s.homepage = "http://github.com/tylerjohnst/bookworm"
|
10
|
-
s.summary = %q{ISBN manipulation, conversion, and inspection for Ruby.}
|
11
|
-
s.description = %q{Convert from 13 digit to 10 digit, from new to used, and back again. Detect used and new
|
10
|
+
s.summary = %q{ISBN/EAN manipulation, conversion, and inspection for Ruby.}
|
11
|
+
s.description = %q{Convert from 13 digit EAN to 10 digit ISBN, from new to used, and back again. Detect used and new addendum in ISBN strings.}
|
12
12
|
|
13
13
|
s.rubyforge_project = "bookworm"
|
14
14
|
|
data/lib/bookworm.rb
CHANGED
@@ -60,7 +60,8 @@ class Bookworm
|
|
60
60
|
digit = identifier[index].to_i
|
61
61
|
sum += index.even? ? digit : digit * 3
|
62
62
|
end
|
63
|
-
(10 - sum % 10)
|
63
|
+
checksum = (10 - sum % 10)
|
64
|
+
checksum == 10 ? '0' : checksum.to_s
|
64
65
|
end
|
65
66
|
|
66
67
|
def ten_check_digit(identifier)
|
@@ -69,7 +70,12 @@ class Bookworm
|
|
69
70
|
sum += (10 - index) * identifier[index].to_i
|
70
71
|
end
|
71
72
|
checksum = 11 - sum % 11
|
72
|
-
|
73
|
+
|
74
|
+
case checksum
|
75
|
+
when 10 then "X"
|
76
|
+
when 11 then "0"
|
77
|
+
else checksum.to_s
|
78
|
+
end
|
73
79
|
end
|
74
80
|
|
75
81
|
def is_valid?
|
data/test/bookworm_test.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: bookworm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tyler Johnston
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-16 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake
|
@@ -23,7 +23,7 @@ dependencies:
|
|
23
23
|
version: "0"
|
24
24
|
type: :development
|
25
25
|
version_requirements: *id001
|
26
|
-
description: Convert from 13 digit to 10 digit, from new to used, and back again. Detect used and new
|
26
|
+
description: Convert from 13 digit EAN to 10 digit ISBN, from new to used, and back again. Detect used and new addendum in ISBN strings.
|
27
27
|
email:
|
28
28
|
- tylerjohnst@gmail.com
|
29
29
|
executables: []
|
@@ -67,6 +67,6 @@ rubyforge_project: bookworm
|
|
67
67
|
rubygems_version: 1.8.11
|
68
68
|
signing_key:
|
69
69
|
specification_version: 3
|
70
|
-
summary: ISBN manipulation, conversion, and inspection for Ruby.
|
70
|
+
summary: ISBN/EAN manipulation, conversion, and inspection for Ruby.
|
71
71
|
test_files:
|
72
72
|
- test/bookworm_test.rb
|