bookland 0.3.0 → 0.3.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/.gitignore +3 -3
- data/README.md +33 -12
- data/VERSION +1 -1
- data/bookland.gemspec +2 -3
- data/lib/bookland.rb +7 -3
- data/spec/bookland_spec.rb +5 -0
- metadata +4 -5
- data/rake_rubies.sh +0 -26
data/.gitignore
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
.DS_Store
|
2
|
-
pkg
|
3
|
-
.bundle
|
1
|
+
.DS_Store
|
2
|
+
pkg
|
3
|
+
.bundle
|
data/README.md
CHANGED
@@ -1,25 +1,46 @@
|
|
1
|
-
|
1
|
+
Bookland
|
2
|
+
========
|
2
3
|
|
3
4
|
Bookland provides a simple ISBN class in Ruby.
|
4
5
|
|
5
|
-
|
6
|
-
|
6
|
+

|
7
|
+
|
8
|
+
Examples
|
9
|
+
--------
|
10
|
+
|
11
|
+
include Bookland
|
12
|
+
|
13
|
+
book = ISBN.new("0262011530")
|
14
|
+
book.to_isbn13
|
7
15
|
=> "9780262011532"
|
8
|
-
|
16
|
+
|
17
|
+
book.to_s(1, 3, 5)
|
9
18
|
=> "0-262-01153-0"
|
10
|
-
|
19
|
+
|
20
|
+
book == ISBN.new("9780262011532")
|
11
21
|
=> true
|
12
|
-
|
13
|
-
|
22
|
+
|
23
|
+
# An invalid ISBN
|
24
|
+
book = ISBN.new("0262011531")
|
25
|
+
book.valid?
|
14
26
|
=> false
|
15
|
-
|
27
|
+
|
28
|
+
book.to_isbn13
|
16
29
|
=> Bookland::ISBNError: ISBN not valid
|
17
30
|
|
18
|
-
|
31
|
+
Or use some class methods:
|
19
32
|
|
20
|
-
|
33
|
+
include Bookland
|
34
|
+
ISBN.to_13("0262011530")
|
21
35
|
=> "9780262011532"
|
22
|
-
|
36
|
+
|
37
|
+
ISBN.to_10("9780262011532")
|
23
38
|
=> "0262011530"
|
24
39
|
|
25
|
-
|
40
|
+
ISBN.valid?("9780262011532")
|
41
|
+
=> true
|
42
|
+
|
43
|
+
Compatibility
|
44
|
+
-------------
|
45
|
+
|
46
|
+
Specs pass against all usual suspects, including Ruby 1.8.7, 1.9.1, and 1.9.2.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/bookland.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bookland}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Hakan Ensari", "Piotr Laszewski"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-09}
|
13
13
|
s.description = %q{A simple ISBN class in Ruby}
|
14
14
|
s.email = %q{code@papercavalier.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,7 +29,6 @@ Gem::Specification.new do |s|
|
|
29
29
|
"VERSION",
|
30
30
|
"bookland.gemspec",
|
31
31
|
"lib/bookland.rb",
|
32
|
-
"rake_rubies.sh",
|
33
32
|
"spec/bookland_spec.rb",
|
34
33
|
"spec/fixtures/isbn",
|
35
34
|
"spec/spec_helper.rb"
|
data/lib/bookland.rb
CHANGED
@@ -10,6 +10,10 @@ module Bookland
|
|
10
10
|
def to_13(isbn)
|
11
11
|
new(isbn).to_isbn13.to_s
|
12
12
|
end
|
13
|
+
|
14
|
+
def valid?(isbn)
|
15
|
+
new(isbn).valid?
|
16
|
+
end
|
13
17
|
end
|
14
18
|
|
15
19
|
def initialize(seed=nil)
|
@@ -17,7 +21,7 @@ module Bookland
|
|
17
21
|
end
|
18
22
|
|
19
23
|
def ==(other)
|
20
|
-
|
24
|
+
to_isbn13.to_s == other.to_isbn13.to_s
|
21
25
|
end
|
22
26
|
|
23
27
|
def inspect
|
@@ -35,7 +39,7 @@ module Bookland
|
|
35
39
|
raw = @raw[3..11]
|
36
40
|
ISBN.new((raw << check_digit_10(raw)).to_s)
|
37
41
|
else
|
38
|
-
|
42
|
+
dup
|
39
43
|
end
|
40
44
|
end
|
41
45
|
|
@@ -46,7 +50,7 @@ module Bookland
|
|
46
50
|
raw = @raw[0..8].unshift('9', '7', '8')
|
47
51
|
ISBN.new((raw << check_digit_13(raw)).to_s)
|
48
52
|
else
|
49
|
-
|
53
|
+
dup
|
50
54
|
end
|
51
55
|
end
|
52
56
|
|
data/spec/bookland_spec.rb
CHANGED
@@ -23,6 +23,11 @@ module Bookland
|
|
23
23
|
lambda { Bookland::ISBN.to_13(isbn)}.should raise_error Bookland::ISBNError
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
it "validates an ISBN" do
|
28
|
+
Bookland::ISBN.valid?("9780485113358").should be_true
|
29
|
+
Bookland::ISBN.valid?("9780485113359").should be_false
|
30
|
+
end
|
26
31
|
end
|
27
32
|
|
28
33
|
it "converts an ISBN-10 to ISBN-13" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookland
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hakan Ensari
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-
|
19
|
+
date: 2010-09-09 00:00:00 +01:00
|
20
20
|
default_executable:
|
21
21
|
dependencies: []
|
22
22
|
|
@@ -42,7 +42,6 @@ files:
|
|
42
42
|
- VERSION
|
43
43
|
- bookland.gemspec
|
44
44
|
- lib/bookland.rb
|
45
|
-
- rake_rubies.sh
|
46
45
|
- spec/bookland_spec.rb
|
47
46
|
- spec/fixtures/isbn
|
48
47
|
- spec/spec_helper.rb
|
data/rake_rubies.sh
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
# http://github.com/papercavalier/rake_rubies
|
4
|
-
|
5
|
-
if which rvm > /dev/null; then
|
6
|
-
RUBIES=$(echo `rvm list strings` | tr " " "\n")
|
7
|
-
if [ -e ".rvmrc" ]; then
|
8
|
-
GEMSET=`grep -m 1 -o -e "\@[^ ]*" .rvmrc`
|
9
|
-
fi
|
10
|
-
for RUBY in $RUBIES; do
|
11
|
-
if [ $RUBY != "default" ]; then
|
12
|
-
if [ -e "Gemfile" ]; then
|
13
|
-
if !(which bundle > /dev/null); then
|
14
|
-
rvm "$RUBY@global" gem install bundler --pre
|
15
|
-
fi
|
16
|
-
rvm "$RUBY$GEMSET" ruby -S bundle install > /dev/null
|
17
|
-
fi
|
18
|
-
rvm "$RUBY$GEMSET" rake $1
|
19
|
-
fi
|
20
|
-
done
|
21
|
-
if [ -e ".rvmrc" ]; then
|
22
|
-
sh .rvmrc > /dev/null
|
23
|
-
fi
|
24
|
-
else
|
25
|
-
rake $1
|
26
|
-
fi
|