isbn10 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +3 -0
- data/{README.rdoc → README.markdown} +17 -17
- data/lib/isbn10.rb +1 -1
- data/spec/isbn10_spec.rb +25 -33
- metadata +68 -60
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bc5b3778cdc2f29b31f075ea1028cf9db651eb6f
|
4
|
+
data.tar.gz: c773398fc64557c2fad52663f7d215ed65451a99
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 387b4775633a3c57febc24545be3168029e1f799ccde9058639fdd505a61fb69f0f71c49b7fe4df02cf11f3ea8a5f2b75275df03f7034a7c6eeb7e1818beca83
|
7
|
+
data.tar.gz: e747671faf2fb21a72aa7c31661ae6430af0805fd55b5f4131619bfbac0ee8f49321f1a57ecccf45f14f6a62981c5a3d52464288a6197e49fd6083bad12f2220
|
data/CHANGELOG
CHANGED
@@ -5,32 +5,32 @@ Yes there are man other ISBN gems out there. I wanted one that has a similar API
|
|
5
5
|
my other identifier related gems (ean13, abn, san, upc, etc) to reduce the
|
6
6
|
number of APIs I have to remember.
|
7
7
|
|
8
|
-
|
8
|
+
# Installation
|
9
9
|
|
10
|
-
gem install isbn10
|
10
|
+
gem install isbn10
|
11
11
|
|
12
|
-
|
12
|
+
# Usage
|
13
13
|
|
14
|
-
|
15
|
-
|
14
|
+
ISBN10.new("0140449043").valid?
|
15
|
+
=> true
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
ISBN10.valid?("0140449043")
|
18
|
+
=> true
|
19
19
|
|
20
|
-
|
21
|
-
|
20
|
+
ISBN10.valid?("0140449042")
|
21
|
+
=> false
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
ISBN10.complete("014044904")
|
24
|
+
=> "0140449043"
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
ISBN10.new("0140449043").to_ean
|
27
|
+
=> "9780140449044"
|
28
28
|
|
29
|
-
|
29
|
+
# Further Reading
|
30
30
|
|
31
31
|
- http://en.wikipedia.org/wiki/International_Standard_Book_Number
|
32
32
|
|
33
|
-
|
33
|
+
# Contributing
|
34
34
|
|
35
|
-
Source code is publicly available @ http://github.com/yob/isbn10
|
36
|
-
|
35
|
+
Source code is publicly available @ http://github.com/yob/isbn10. Patches
|
36
|
+
welcome, preferably via a git repo I can pull from.
|
data/lib/isbn10.rb
CHANGED
data/spec/isbn10_spec.rb
CHANGED
@@ -1,52 +1,44 @@
|
|
1
|
-
$LOAD_PATH << File.dirname(__FILE__) + "/../lib"
|
2
|
-
|
3
|
-
require 'spec'
|
4
1
|
require 'isbn10'
|
5
2
|
|
6
3
|
describe ISBN10 do
|
7
4
|
it "should identify a valid ISBN10" do
|
8
|
-
ISBN10.new("0140449043").valid
|
9
|
-
ISBN10.new("0-140-44904-3").valid
|
10
|
-
ISBN10.new("043429067X").valid
|
11
|
-
ISBN10.new("043429067x").valid
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should identify a valid ISBN10" do
|
15
|
-
ISBN10.valid?("0140449043").should be_true
|
16
|
-
ISBN10.valid?("0-140-44904-3").should be_true
|
5
|
+
expect(ISBN10.new("0140449043").valid?).to be_truthy
|
6
|
+
expect(ISBN10.new("0-140-44904-3").valid?).to be_truthy
|
7
|
+
expect(ISBN10.new("043429067X").valid?).to be_truthy
|
8
|
+
expect(ISBN10.new("043429067x").valid?).to be_truthy
|
17
9
|
end
|
18
10
|
|
19
11
|
it "should identify an invalid ISBN10" do
|
20
|
-
ISBN10.valid?(nil).
|
21
|
-
ISBN10.valid?("0-1404-4904-2").
|
22
|
-
ISBN10.valid?("0140449042").
|
23
|
-
ISBN10.valid?("978184354916").
|
24
|
-
ISBN10.valid?(Array).
|
25
|
-
ISBN10.valid?(Array.new).
|
12
|
+
expect(ISBN10.valid?(nil)).to be_falsey
|
13
|
+
expect(ISBN10.valid?("0-1404-4904-2")).to be_falsey
|
14
|
+
expect(ISBN10.valid?("0140449042")).to be_falsey
|
15
|
+
expect(ISBN10.valid?("978184354916")).to be_falsey
|
16
|
+
expect(ISBN10.valid?(Array)).to be_falsey
|
17
|
+
expect(ISBN10.valid?(Array.new)).to be_falsey
|
26
18
|
end
|
27
19
|
|
28
20
|
it "should calculate a ISBN10 check digit correctly" do
|
29
|
-
ISBN10.complete("014044904").
|
21
|
+
expect(ISBN10.complete("014044904")).to eql("0140449043")
|
30
22
|
end
|
31
23
|
|
32
24
|
it "should convert to an EAN correctly" do
|
33
|
-
ISBN10.new("0140449042").to_ean.
|
34
|
-
ISBN10.new("0140449043").to_ean.
|
35
|
-
ISBN10.new("043429067X").to_ean.
|
36
|
-
ISBN10.new("043429067x").to_ean.
|
25
|
+
expect(ISBN10.new("0140449042").to_ean).to be_nil
|
26
|
+
expect(ISBN10.new("0140449043").to_ean).to eql("9780140449044")
|
27
|
+
expect(ISBN10.new("043429067X").to_ean).to eql("9780434290673")
|
28
|
+
expect(ISBN10.new("043429067x").to_ean).to eql("9780434290673")
|
37
29
|
end
|
38
30
|
|
39
31
|
it "should convert to a grouped ISBN10 correctly" do
|
40
|
-
ISBN10.new("0809141875").grouped.
|
41
|
-
ISBN10.new("0140361278").grouped.
|
42
|
-
ISBN10.new("0321350316").grouped.
|
43
|
-
ISBN10.new("0809141876").grouped.
|
44
|
-
ISBN10.new("0855615346").grouped.
|
45
|
-
ISBN10.new("094727748X").grouped.
|
46
|
-
ISBN10.new("0975601873").grouped.
|
47
|
-
ISBN10.new("1430219483").grouped.
|
48
|
-
ISBN10.new("1855548453").grouped.
|
49
|
-
ISBN10.new("1921640065").grouped.
|
32
|
+
expect(ISBN10.new("0809141875").grouped).to be_nil
|
33
|
+
expect(ISBN10.new("0140361278").grouped).to eql("0-14-036127-8")
|
34
|
+
expect(ISBN10.new("0321350316").grouped).to eql("0-321-35031-6")
|
35
|
+
expect(ISBN10.new("0809141876").grouped).to eql("0-8091-4187-6")
|
36
|
+
expect(ISBN10.new("0855615346").grouped).to eql("0-85561-534-6")
|
37
|
+
expect(ISBN10.new("094727748X").grouped).to eql("0-947277-48-X")
|
38
|
+
expect(ISBN10.new("0975601873").grouped).to eql("0-9756018-7-3")
|
39
|
+
expect(ISBN10.new("1430219483").grouped).to eql("1-4302-1948-3")
|
40
|
+
expect(ISBN10.new("1855548453").grouped).to eql("1-85554-845-3")
|
41
|
+
expect(ISBN10.new("1921640065").grouped).to eql("1-921640-06-5")
|
50
42
|
end
|
51
43
|
|
52
44
|
end
|
metadata
CHANGED
@@ -1,86 +1,94 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: isbn10
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 1.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- James Healy
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2017-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: ean13
|
23
|
-
|
24
|
-
|
25
|
-
none: false
|
26
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
27
17
|
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
33
20
|
type: :runtime
|
34
|
-
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
35
55
|
description: a (very) small library for working with ISBN10 codes
|
36
56
|
email: jimmy@deefa.com
|
37
57
|
executables: []
|
38
|
-
|
39
58
|
extensions: []
|
40
|
-
|
41
59
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
44
|
-
- lib/isbn10.rb
|
45
|
-
- MIT-LICENSE
|
46
|
-
- README.rdoc
|
60
|
+
files:
|
47
61
|
- CHANGELOG
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.markdown
|
64
|
+
- lib/isbn10.rb
|
48
65
|
- spec/isbn10_spec.rb
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
66
|
+
homepage: http://github.com/yob/isbn10
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
53
70
|
post_install_message:
|
54
|
-
rdoc_options:
|
55
|
-
- --title
|
71
|
+
rdoc_options:
|
72
|
+
- "--title"
|
56
73
|
- ISBN10
|
57
|
-
- --line-numbers
|
58
|
-
require_paths:
|
74
|
+
- "--line-numbers"
|
75
|
+
require_paths:
|
59
76
|
- lib
|
60
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
61
|
-
|
62
|
-
requirements:
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
63
79
|
- - ">="
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
version: "0"
|
69
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
-
none: false
|
71
|
-
requirements:
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.9.3
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
72
84
|
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
version: "0"
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
78
87
|
requirements: []
|
79
|
-
|
80
88
|
rubyforge_project:
|
81
|
-
rubygems_version:
|
89
|
+
rubygems_version: 2.6.11
|
82
90
|
signing_key:
|
83
|
-
specification_version:
|
91
|
+
specification_version: 4
|
84
92
|
summary: a (very) small library for working with ISBN10 codes
|
85
|
-
test_files:
|
93
|
+
test_files:
|
86
94
|
- spec/isbn10_spec.rb
|