isbn 2.0.5 → 2.0.6
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/README.md +2 -0
- data/Rakefile +8 -9
- data/isbn.gemspec +2 -1
- data/lib/isbn.rb +9 -2
- data/test/isbn_spec.rb +4 -0
- metadata +6 -6
data/README.md
CHANGED
@@ -24,3 +24,5 @@ This library provides methods to manipulate isbns. As of version 2.0 there has b
|
|
24
24
|
|
25
25
|
* ISBN.from_image accept a jpeg of an isbn and OCR it into an isbn.
|
26
26
|
- it depends on the LibJpeg and Gocr libraries. I recommend [Homebrew](http://github.com/mxcl/homebrew).
|
27
|
+
|
28
|
+
* ISBN.from_string fetches isbn from string
|
data/Rakefile
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
$:.unshift("lib") unless $:.include?("lib")
|
2
2
|
require "isbn"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
`rm isbn-#{ISBN::VERSION}.gem`
|
4
|
+
require 'rake/gempackagetask'
|
5
|
+
spec = eval(File.read("isbn.gemspec"))
|
6
|
+
Rake::GemPackageTask.new(spec).define
|
7
|
+
|
8
|
+
require 'rake/testtask'
|
9
|
+
Rake::TestTask.new(:test) do |test|
|
10
|
+
test.libs << "test"
|
11
|
+
test.pattern = "test/**/*_test.rb"
|
13
12
|
end
|
14
13
|
|
15
14
|
desc "publish to rubygems.org"
|
data/isbn.gemspec
CHANGED
@@ -10,10 +10,11 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.summary = %Q{a simple library of functions on ISBN\'s}
|
11
11
|
s.homepage = "http://github.com/entangledstate/isbn"
|
12
12
|
s.email = "entangledstate@gmail.com"
|
13
|
-
s.authors = ["Tim Kersey"]
|
13
|
+
s.authors = ["Tim Kersey", "Jakub Kaflik"]
|
14
14
|
s.has_rdoc = false
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files test`.split("\n")
|
17
18
|
|
18
19
|
s.executables = `git ls-files bin`.split("\n").map {|f| f[/bin\/(.*)/,1]}
|
19
20
|
|
data/lib/isbn.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module ISBN
|
2
2
|
extend self
|
3
3
|
|
4
|
-
VERSION = "2.0.
|
4
|
+
VERSION = "2.0.6"
|
5
5
|
|
6
6
|
def ten(isbn)
|
7
7
|
raise InvalidISBNError unless isbn.is_a? String
|
@@ -83,8 +83,15 @@ module ISBN
|
|
83
83
|
isbn.strip.gsub(" ", "").gsub(/o/i, "0").gsub("_", "2").gsub(/2J$/, "45")
|
84
84
|
end
|
85
85
|
|
86
|
+
def from_string(source)
|
87
|
+
match = /(97[89][- ]){0,1}[0-9]{1,5}[- ][0-9]{1,7}[- ][0-9]{1,6}[- ][0-9X]/.match(source)
|
88
|
+
raise InvalidSourceString unless match
|
89
|
+
match.to_a.first
|
90
|
+
end
|
91
|
+
|
86
92
|
class InvalidISBNError < RuntimeError; end
|
87
93
|
class No10DigitISBNAvailable < RuntimeError; end
|
88
94
|
class Invalid10DigitISBN < RuntimeError; end
|
89
95
|
class Invalid13DigitISBN < RuntimeError; end
|
90
|
-
end
|
96
|
+
class InvalidSourceString < RuntimeError; end
|
97
|
+
end
|
data/test/isbn_spec.rb
CHANGED
@@ -60,4 +60,8 @@ describe ISBN do
|
|
60
60
|
ISBN.valid?("9887401392").must_equal false
|
61
61
|
ISBN.valid?("082047267").must_equal false
|
62
62
|
end
|
63
|
+
|
64
|
+
it "should get isbn from source string" do
|
65
|
+
ISBN.from_string("ISBN:978-83-7659-303-6\nmore of content").must_equal "978-83-7659-303-6"
|
66
|
+
end
|
63
67
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
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.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tim Kersey
|
9
|
+
- Jakub Kaflik
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2011-
|
13
|
-
default_executable:
|
13
|
+
date: 2011-04-15 00:00:00.000000000Z
|
14
14
|
dependencies: []
|
15
15
|
description: ! ' library to transform ISBN''s from new to used, between 10 and 13,
|
16
16
|
etc...
|
@@ -27,7 +27,6 @@ files:
|
|
27
27
|
- isbn.gemspec
|
28
28
|
- lib/isbn.rb
|
29
29
|
- test/isbn_spec.rb
|
30
|
-
has_rdoc: true
|
31
30
|
homepage: http://github.com/entangledstate/isbn
|
32
31
|
licenses: []
|
33
32
|
post_install_message:
|
@@ -48,8 +47,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
47
|
version: '0'
|
49
48
|
requirements: []
|
50
49
|
rubyforge_project:
|
51
|
-
rubygems_version: 1.
|
50
|
+
rubygems_version: 1.7.2
|
52
51
|
signing_key:
|
53
52
|
specification_version: 3
|
54
53
|
summary: a simple library of functions on ISBN's
|
55
|
-
test_files:
|
54
|
+
test_files:
|
55
|
+
- test/isbn_spec.rb
|