bookland 1.0.1 → 1.0.2

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.
@@ -0,0 +1,8 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby
6
+ - rbx
7
+ - rbx-2.0
8
+ - ree
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem 'rake'
data/LICENSE CHANGED
@@ -1,7 +1,4 @@
1
- Copyright (c) 2008, Keiichirou SHIKANO <k16.shikano@gmail.com> and
2
- shamelessly hacked by folks at Paper Cavalier in the year of the
3
- Lord 2010.
4
-
1
+ Copyright (c) 2008, Keiichirou SHIKANO <k16.shikano@gmail.com>
5
2
  All rights reserved.
6
3
 
7
4
  Redistribution and use in source and binary forms, with or without
data/README.md CHANGED
@@ -1,38 +1,28 @@
1
- Bookland
2
- ========
1
+ # Bookland
3
2
 
4
- [Bookland](http://en.wikipedia.org/wiki/Bookland) provides an ISBN class in
5
- Ruby.
3
+ [Bookland] [1] provides an ISBN class in Ruby.
6
4
 
7
- Usage
8
- -----
5
+ [![travis](https://secure.travis-ci.org/hakanensari/bookland.png)](http://travis-ci.org/hakanensari/bookland)
9
6
 
10
- require 'bookland'
7
+ ## Usage
11
8
 
12
- isbn10 = ISBN.new('0262011530')
13
- isbn10.to_isbn13
14
- => "9780262011532"
15
-
16
- isbn10.to_s(1, 3, 5)
17
- => "0-262-01153-0"
9
+ require "bookland"
18
10
 
19
- isbn13 == ISBN.new('9780262011532')
11
+ isbn = ISBN.new("0262011530")
12
+ isbn.to_isbn13
13
+ => "9780262011532"
14
+ isbn.valid?
20
15
  => true
21
16
 
22
- # Does an invalid ISBN quack like an ISBN?
23
- bad_isbn = ISBN.new('0262011531')
24
- bad_isbn.valid?
25
- => false
26
- bad_isbn.to_isbn13
27
- => Bookland::ISBNError: Invalid ISBN
17
+ Bookland provides certain utility methods defined on the class level:
28
18
 
29
- Some utility methods defined in the class level:
30
-
31
- ISBN.to_13('0262011530')
19
+ ISBN.to_13("0262011530")
32
20
  => "9780262011532"
33
21
 
34
- ISBN.to_10('9780262011532')
22
+ ISBN.to_10("9780262011532")
35
23
  => "0262011530"
36
24
 
37
- ISBN.valid?('9780262011532')
25
+ ISBN.valid?("9780262011532")
38
26
  => true
27
+
28
+ [1]: http://en.wikipedia.org/wiki/Bookland
data/Rakefile CHANGED
@@ -9,15 +9,3 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
9
9
  end
10
10
 
11
11
  task :default => :spec
12
-
13
- require 'rocco/tasks'
14
- Rocco::make 'docs/'
15
-
16
- desc 'Build rocco docs'
17
- task :docs => :rocco
18
- directory 'docs/'
19
-
20
- desc 'Build docs and open in browser for the reading'
21
- task :read => :docs do
22
- sh 'open docs/lib/bookland/isbn.html'
23
- end
@@ -6,11 +6,11 @@ Gem::Specification.new do |s|
6
6
  s.name = 'bookland'
7
7
  s.version = Bookland::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ['Paper Cavalier']
9
+ s.authors = ['Hakan Ensari']
10
10
  s.email = 'code@papercavalier.com'
11
- s.homepage = 'https://rubygems.org/gems/bookland'
12
- s.summary = %q{An ISBN class in Ruby}
13
- s.description = %q{Bookland is an ISBN class in Ruby.}
11
+ s.homepage = 'https://github.com/hakanensari/bookland'
12
+ s.summary = %q{An ISBN class}
13
+ s.description = %q{Bookland provides an ISBN class.}
14
14
 
15
15
  s.rubyforge_project = 'bookland'
16
16
 
@@ -19,6 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ['lib']
21
21
 
22
- s.add_development_dependency('rspec', '~> 2.5.0')
23
- s.add_development_dependency('rocco', '~> 0.6.0')
22
+ s.add_development_dependency('rspec', '~> 2.6')
24
23
  end
@@ -1,32 +1,17 @@
1
- # encoding: UTF-8
2
- #
3
- # [Bookland][bl] is a simple ISBN class in Ruby.
1
+ # [Bookland][bl] is an ISBN class in Ruby.
4
2
  #
5
3
  # [bl]: http://en.wikipedia.org/wiki/Bookland
6
4
  module Bookland
7
-
8
- #### Public Interface
9
- #
10
- # `ISBN.new` takes an optional string. The string should look like an ISBN
11
- # and may contain extra characters that are traditionally used to format
12
- # ISBNs.
13
- #
14
- # The following are valid instantiations:
15
- #
16
- # isbn13 = ISBN.new('9780826476951')
17
- # isbn10 = ISBN.new('0-8264-7695-3')
18
- #
19
- # isbn10 == isbn13
20
- # => true
21
5
  class ISBN
22
6
  class << self
23
-
24
- # Casts a specified string to a 10-digit ISBN.
7
+ # Converts specified string to a 10-digit ISBN and returns its
8
+ # string representation.
25
9
  def to_10(isbn)
26
10
  new(isbn).to_isbn10.to_s
27
11
  end
28
12
 
29
- # Casts a specified string to a 13-digit ISBN.
13
+ # Converts specified string to a 13-digit ISBN and returns its
14
+ # string representation.
30
15
  def to_13(isbn)
31
16
  new(isbn).to_isbn13.to_s
32
17
  end
@@ -37,11 +22,22 @@ module Bookland
37
22
  end
38
23
  end
39
24
 
40
- def initialize(seed=nil)
25
+ # Instantiates a new ISBN object.
26
+ #
27
+ # Takes an optional string. The string should look like an ISBN and
28
+ # may contain extra characters that are traditionally used to
29
+ # format ISBNs.
30
+ #
31
+ # The following are valid instantiations for the same ISBN:
32
+ #
33
+ # isbn13 = ISBN.new('9780826476951')
34
+ # isbn10 = ISBN.new('0-8264-7695-3')
35
+ #
36
+ def initialize(seed = nil)
41
37
  self.seed = seed
42
38
  end
43
39
 
44
- # Returns `true` if the ISBN is equal to another specified ISBN.
40
+ # Returns +true+ if the ISBN is equal to another specified ISBN.
45
41
  def ==(other)
46
42
  to_isbn13.to_s == other.to_isbn13.to_s
47
43
  end
@@ -53,12 +49,11 @@ module Bookland
53
49
 
54
50
  # Sets the seed of the ISBN based on a specified string.
55
51
  def seed=(seed)
56
- @raw = seed.gsub(/[^Xx0-9]/, '').split(//) rescue @raw = []
52
+ @raw = seed.gsub(/[^\dx]/i, '').split('') rescue []
57
53
  end
58
54
 
59
- # Casts the ISBN to a ten-digit ISBN.
55
+ # Casts the ISBN to a 10-digit ISBN.
60
56
  def to_isbn10
61
-
62
57
  raise ISBNError unless valid?
63
58
 
64
59
  if isbn13?
@@ -80,17 +75,17 @@ module Bookland
80
75
  end
81
76
  end
82
77
 
83
- # Casts ISBN to a string.
78
+ # Returns a string representation of the ISBN.
84
79
  #
85
- # Takes an optional list of integers, which it then uses to dashify the
86
- # ISBN like so:
80
+ # Takes an optional list of integers, which it then uses to dashify
81
+ # the ISBN like so:
87
82
  #
88
83
  # isbn = ISBN.new('0826476953')
89
84
  # isbn.to_s(1,4,4,1)
90
85
  # => "0-8264-7695-3"
91
86
  #
92
87
  def to_s(*blocks)
93
- return false unless valid?
88
+ return nil unless valid?
94
89
 
95
90
  raw = @raw.dup
96
91
  if blocks.any?
@@ -100,7 +95,7 @@ module Bookland
100
95
  end
101
96
  end
102
97
 
103
- # Returns `true` if the ISBN is valid.
98
+ # Returns +true+ if the ISBN is valid.
104
99
  def valid?
105
100
  if isbn10?
106
101
  @raw[9] == check_digit_10(@raw)
@@ -142,5 +137,3 @@ module Bookland
142
137
  end
143
138
  end
144
139
  end
145
-
146
- # C'est ça.
@@ -1,3 +1,3 @@
1
1
  module Bookland
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.2'
3
3
  end
@@ -153,7 +153,7 @@ module Bookland
153
153
  ISBN.new('9780485113358').to_s(3, 10).should eql '978-0485113358'
154
154
  end
155
155
 
156
- it "casts to string and hyphenate a ten-digit ISBN" do
156
+ it "casts to string and hyphenates a ten-digit ISBN" do
157
157
  ISBN.new('048511335X').to_s(1, 3, 5, 1).should eql '0-485-11335-X'
158
158
  end
159
159
 
metadata CHANGED
@@ -1,69 +1,36 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: bookland
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 0
9
- - 1
10
- version: 1.0.1
11
6
  platform: ruby
12
- authors:
13
- - Paper Cavalier
7
+ authors:
8
+ - Hakan Ensari
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-03-17 00:00:00 +00:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-08-21 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rspec
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70172727862740 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
18
+ requirements:
27
19
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 27
30
- segments:
31
- - 2
32
- - 5
33
- - 0
34
- version: 2.5.0
20
+ - !ruby/object:Gem::Version
21
+ version: '2.6'
35
22
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: rocco
39
23
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- hash: 7
46
- segments:
47
- - 0
48
- - 6
49
- - 0
50
- version: 0.6.0
51
- type: :development
52
- version_requirements: *id002
53
- description: Bookland is an ISBN class in Ruby.
24
+ version_requirements: *70172727862740
25
+ description: Bookland provides an ISBN class.
54
26
  email: code@papercavalier.com
55
27
  executables: []
56
-
57
28
  extensions: []
58
-
59
29
  extra_rdoc_files: []
60
-
61
- files:
30
+ files:
62
31
  - .gitignore
63
- - .rspec
64
- - .rvmrc
32
+ - .travis.yml
65
33
  - Gemfile
66
- - History.md
67
34
  - LICENSE
68
35
  - README.md
69
36
  - Rakefile
@@ -75,41 +42,37 @@ files:
75
42
  - spec/bookland_spec.rb
76
43
  - spec/fixtures/isbn
77
44
  - spec/spec_helper.rb
78
- has_rdoc: true
79
- homepage: https://rubygems.org/gems/bookland
45
+ homepage: https://github.com/hakanensari/bookland
80
46
  licenses: []
81
-
82
47
  post_install_message:
83
48
  rdoc_options: []
84
-
85
- require_paths:
49
+ require_paths:
86
50
  - lib
87
- required_ruby_version: !ruby/object:Gem::Requirement
51
+ required_ruby_version: !ruby/object:Gem::Requirement
88
52
  none: false
89
- requirements:
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- hash: 3
93
- segments:
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ segments:
94
58
  - 0
95
- version: "0"
96
- required_rubygems_version: !ruby/object:Gem::Requirement
59
+ hash: -3532017646566011220
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
61
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ segments:
103
67
  - 0
104
- version: "0"
68
+ hash: -3532017646566011220
105
69
  requirements: []
106
-
107
70
  rubyforge_project: bookland
108
- rubygems_version: 1.5.2
71
+ rubygems_version: 1.8.6
109
72
  signing_key:
110
73
  specification_version: 3
111
- summary: An ISBN class in Ruby
112
- test_files:
74
+ summary: An ISBN class
75
+ test_files:
113
76
  - spec/bookland/isbn_spec.rb
114
77
  - spec/bookland_spec.rb
115
78
  - spec/fixtures/isbn
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color --format=documentation
data/.rvmrc DELETED
@@ -1,3 +0,0 @@
1
- rvm_gemset_create_on_use_flag=1
2
- rvm wrapper ree@bookland textmate
3
- rvm ree@bookland
data/History.md DELETED
@@ -1,9 +0,0 @@
1
- # 0.1.0 / 2010-04-22
2
- * First public release
3
-
4
- # 0.2.0 / 2010-04-28
5
- * Made valid? public
6
- * Will raise error if invalid ISBN instance is cast as string or recast as ISBN
7
-
8
- # 0.3.0 / 2010-08-09
9
- * Added class methods to cast to ISBN-10 and ISBN-13