isbn 2.0.9 → 2.0.10
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 +7 -0
- data/LICENSE +20 -0
- data/Rakefile +6 -7
- data/VERSION +1 -0
- data/isbn.gemspec +3 -3
- data/lib/isbn.rb +1 -3
- data/test/isbn_spec.rb +9 -0
- metadata +12 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d530f192ddd236c70bd7b27b0313367692f31873
|
4
|
+
data.tar.gz: 24fc8d2238f0d0a1d66d355928499553f0be3f25
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0d3bb5e674f99e880ad41c4bb39821fe761fd33321867528963fbbdaba084a2ae6e24ab6fffe074e2c72d3405b627014ea3692daebc0941f5c02d6b2575c8a33
|
7
|
+
data.tar.gz: 97f7b76332c69e9c25e3f600164349e327e4f95d8a015b16a1baf2a8d1336c9240e25207d407cd9c0bf54b56d6a878e5d5dfc5dc87497ebc4e2d0a200e8451a7
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) {{{year}}} {{{fullname}}}
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
$:.unshift("lib") unless $:.include?("lib")
|
2
|
-
|
2
|
+
version = open("VERSION").read.strip
|
3
3
|
|
4
4
|
desc "Build, Install and Cleanup gem"
|
5
5
|
task :install do
|
6
6
|
`gem build isbn.gemspec`
|
7
|
-
`gem install isbn-#{
|
8
|
-
`rm isbn-#{
|
7
|
+
`gem install isbn-#{version}.gem`
|
8
|
+
`rm isbn-#{version}.gem`
|
9
9
|
end
|
10
10
|
|
11
11
|
task :default => :test
|
@@ -18,9 +18,8 @@ Rake::TestTask.new(:test) do |test|
|
|
18
18
|
end
|
19
19
|
|
20
20
|
desc "publish to rubygems.org"
|
21
|
-
task :publish
|
21
|
+
task :publish do
|
22
22
|
`gem build isbn.gemspec`
|
23
|
-
`gem
|
24
|
-
`
|
25
|
-
`rm isbn-#{ISBN::VERSION}.gem`
|
23
|
+
`gem push isbn-#{version}.gem`
|
24
|
+
`rm isbn-#{version}.gem`
|
26
25
|
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.10
|
data/isbn.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
$:.unshift("lib") unless $:.include?("lib")
|
4
|
-
|
4
|
+
version = open("VERSION").read.strip
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "isbn"
|
8
|
-
s.version =
|
8
|
+
s.version = version
|
9
9
|
s.date = Time.now.strftime('%Y-%m-%d')
|
10
10
|
s.summary = %Q{a simple library of functions on ISBN\'s}
|
11
11
|
s.homepage = "http://github.com/entangledstate/isbn"
|
@@ -21,4 +21,4 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.description = <<desc
|
22
22
|
library to transform ISBN\'s from new to used, between 10 and 13, etc...
|
23
23
|
desc
|
24
|
-
end
|
24
|
+
end
|
data/lib/isbn.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
module ISBN
|
2
2
|
extend self
|
3
3
|
|
4
|
-
VERSION = "2.0.9"
|
5
|
-
|
6
4
|
def ten(isbn)
|
7
5
|
raise InvalidISBNError unless isbn.is_a? String
|
8
6
|
isbn = isbn.delete("-")
|
@@ -22,8 +20,8 @@ module ISBN
|
|
22
20
|
|
23
21
|
def thirteen(isbn)
|
24
22
|
raise InvalidISBNError unless isbn.is_a? String
|
25
|
-
raise Invalid13DigitISBN unless (isbn.size == 10 || isbn.size == 13)
|
26
23
|
isbn = isbn.delete("-")
|
24
|
+
raise Invalid13DigitISBN unless (isbn.size == 10 || isbn.size == 13)
|
27
25
|
isbn = isbn.rjust(13,"978")[/(.+)\w/,1] # adjust to 13 digit isbn and remove check digit
|
28
26
|
raise Invalid13DigitISBN unless isbn.size == 12 # after adjustments isbn should be 12 digits
|
29
27
|
case ck = (10 - (isbn.split(//).zip([1,3]*6).inject(0) {|s,n| s += n[0].to_i * n[1]} % 10))
|
data/test/isbn_spec.rb
CHANGED
@@ -12,6 +12,8 @@ describe ISBN do
|
|
12
12
|
["0743488040","9780743488044"], ["0470130733","9780470130735"], ["0816516502","9780816516506"],
|
13
13
|
["074324382X","9780743243827"], ["0887401392","9780887401398"], ["0582404800","9780582404809"],
|
14
14
|
["2906571385","9782906571389"]]
|
15
|
+
|
16
|
+
ISBN13DASH = [ ["978-1-934356-47-0", "9781934356470"], ["0-13-532762-8","9780135327623"]]
|
15
17
|
|
16
18
|
it "should respond with a ten digit isbn" do
|
17
19
|
ISBNS.each do |isbn|
|
@@ -32,6 +34,13 @@ describe ISBN do
|
|
32
34
|
proc { ISBN.thirteen("97908793927888") }.must_raise ISBN::Invalid13DigitISBN
|
33
35
|
proc { ISBN.thirteen(nil) }.must_raise ISBN::InvalidISBNError
|
34
36
|
proc { ISBN.thirteen("") }.must_raise ISBN::Invalid13DigitISBN
|
37
|
+
|
38
|
+
ISBN13DASH.each do |isbn|
|
39
|
+
ISBN.thirteen(isbn[0]).must_equal isbn[1]
|
40
|
+
end
|
41
|
+
proc { ISBN.thirteen("1978-1-934356-47-0") }.must_raise ISBN::Invalid13DigitISBN
|
42
|
+
proc { ISBN.thirteen("978-1-934356-47") }.must_raise ISBN::Invalid13DigitISBN
|
43
|
+
|
35
44
|
end
|
36
45
|
|
37
46
|
it "should convert a NEW isbn into USED" do
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isbn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.10
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tim Kersey
|
@@ -10,46 +9,45 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2014-10-05 00:00:00.000000000 Z
|
14
13
|
dependencies: []
|
15
|
-
description:
|
16
|
-
|
17
|
-
|
18
|
-
'
|
14
|
+
description: |2
|
15
|
+
library to transform ISBN's from new to used, between 10 and 13, etc...
|
19
16
|
email: entangledstate@gmail.com
|
20
17
|
executables: []
|
21
18
|
extensions: []
|
22
19
|
extra_rdoc_files: []
|
23
20
|
files:
|
24
|
-
- .gitignore
|
21
|
+
- ".gitignore"
|
22
|
+
- LICENSE
|
25
23
|
- README.md
|
26
24
|
- Rakefile
|
25
|
+
- VERSION
|
27
26
|
- isbn.gemspec
|
28
27
|
- lib/isbn.rb
|
29
28
|
- test/isbn_spec.rb
|
30
29
|
homepage: http://github.com/entangledstate/isbn
|
31
30
|
licenses: []
|
31
|
+
metadata: {}
|
32
32
|
post_install_message:
|
33
33
|
rdoc_options: []
|
34
34
|
require_paths:
|
35
35
|
- lib
|
36
36
|
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
-
none: false
|
38
37
|
requirements:
|
39
|
-
- -
|
38
|
+
- - ">="
|
40
39
|
- !ruby/object:Gem::Version
|
41
40
|
version: '0'
|
42
41
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
42
|
requirements:
|
45
|
-
- -
|
43
|
+
- - ">="
|
46
44
|
- !ruby/object:Gem::Version
|
47
45
|
version: '0'
|
48
46
|
requirements: []
|
49
47
|
rubyforge_project:
|
50
|
-
rubygems_version:
|
48
|
+
rubygems_version: 2.4.2
|
51
49
|
signing_key:
|
52
|
-
specification_version:
|
50
|
+
specification_version: 4
|
53
51
|
summary: a simple library of functions on ISBN's
|
54
52
|
test_files:
|
55
53
|
- test/isbn_spec.rb
|