lisbn 0.2.2 → 0.2.3
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.
- checksums.yaml +4 -4
- data/data/RangeMessage.xml +1132 -164
- data/data/ranges.yml +1092 -112
- data/lib/lisbn/ranges.rb +1 -1
- data/lisbn.gemspec +1 -1
- data/spec/lisbn_spec.rb +9 -9
- data/tasks/{save_ranges_to_json.rake → save_ranges_to_yaml.rake} +2 -2
- metadata +4 -5
data/lib/lisbn/ranges.rb
CHANGED
@@ -8,7 +8,7 @@ class Lisbn < String
|
|
8
8
|
ranges = xml["ISBNRangeMessage"]["RegistrationGroups"]["Group"]
|
9
9
|
|
10
10
|
hash = Array(ranges).flatten.inject({}) do |memo, group|
|
11
|
-
prefix = group["Prefix"].gsub(/-/, '')
|
11
|
+
prefix = group["Prefix"].gsub(/-/, '').to_s
|
12
12
|
ranges = Array(group["Rules"]["Rule"]).flatten.map do |rule|
|
13
13
|
length = rule["Length"].to_i
|
14
14
|
next unless length > 0
|
data/lisbn.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
13
|
gem.name = "lisbn"
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
gem.version = "0.2.
|
15
|
+
gem.version = "0.2.3"
|
16
16
|
|
17
17
|
gem.add_dependency "nori", "~> 2.0"
|
18
18
|
gem.add_dependency "nokogiri"
|
data/spec/lisbn_spec.rb
CHANGED
@@ -11,47 +11,47 @@ describe "Lisbn" do
|
|
11
11
|
describe "#valid?" do
|
12
12
|
it "recognizes a valid ISBN10" do
|
13
13
|
isbn = Lisbn.new("0123456789")
|
14
|
-
isbn.valid?.should
|
14
|
+
isbn.valid?.should be true
|
15
15
|
end
|
16
16
|
|
17
17
|
it "recognizes a valid ISBN10 with X checksum" do
|
18
18
|
isbn = Lisbn.new("160459411X")
|
19
|
-
isbn.valid?.should
|
19
|
+
isbn.valid?.should be true
|
20
20
|
end
|
21
21
|
|
22
22
|
it "recognizes a valid ISBN10 with 0 checksum" do
|
23
23
|
isbn = Lisbn.new("0679405070")
|
24
|
-
isbn.valid?.should
|
24
|
+
isbn.valid?.should be true
|
25
25
|
end
|
26
26
|
|
27
27
|
it "recognizes an invalid ISBN10" do
|
28
28
|
isbn = Lisbn.new("0123546789")
|
29
|
-
isbn.valid?.should
|
29
|
+
isbn.valid?.should be false
|
30
30
|
end
|
31
31
|
|
32
32
|
it "recognizes a valid ISBN13" do
|
33
33
|
isbn = Lisbn.new("9780000000002")
|
34
|
-
isbn.valid?.should
|
34
|
+
isbn.valid?.should be true
|
35
35
|
end
|
36
36
|
|
37
37
|
it "recognizes a valid ISBN13 with 0 checksum" do
|
38
38
|
isbn = Lisbn.new("9780062870780")
|
39
|
-
isbn.valid?.should
|
39
|
+
isbn.valid?.should be true
|
40
40
|
end
|
41
41
|
|
42
42
|
it "recognizes an invalid ISBN13" do
|
43
43
|
isbn = Lisbn.new("9780000000003")
|
44
|
-
isbn.valid?.should
|
44
|
+
isbn.valid?.should be false
|
45
45
|
end
|
46
46
|
|
47
47
|
it "returns false for improperly-formatted ISBNs" do
|
48
48
|
isbn = Lisbn.new("97800000X0002")
|
49
|
-
isbn.valid?.should
|
49
|
+
isbn.valid?.should be false
|
50
50
|
end
|
51
51
|
|
52
52
|
it "regards anything not 10 or 13 digits as invalid" do
|
53
53
|
isbn = Lisbn.new("")
|
54
|
-
isbn.valid?.should
|
54
|
+
isbn.valid?.should be false
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lisbn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Ragalie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nori
|
@@ -76,7 +76,7 @@ files:
|
|
76
76
|
- spec/cache_method_spec.rb
|
77
77
|
- spec/lisbn_spec.rb
|
78
78
|
- spec/spec_helper.rb
|
79
|
-
- tasks/
|
79
|
+
- tasks/save_ranges_to_yaml.rake
|
80
80
|
homepage: https://github.com/ragalie/lisbn
|
81
81
|
licenses: []
|
82
82
|
metadata: {}
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
version: '0'
|
97
97
|
requirements: []
|
98
98
|
rubyforge_project:
|
99
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.6.14
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: Provides methods for converting between ISBN-10 and ISBN-13, checking validity
|
@@ -105,4 +105,3 @@ test_files:
|
|
105
105
|
- spec/cache_method_spec.rb
|
106
106
|
- spec/lisbn_spec.rb
|
107
107
|
- spec/spec_helper.rb
|
108
|
-
has_rdoc:
|