ean13 1.2.0 → 1.3.0

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.
Files changed (4) hide show
  1. data/CHANGELOG +6 -0
  2. data/lib/ean13.rb +5 -1
  3. data/spec/ean13_spec.rb +8 -0
  4. metadata +6 -4
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ v1.3 (11th July 2009)
2
+ - add a bookland? method. Returns true if ean is a book EAN
3
+
4
+ v1.2 (25th February 2009)
5
+ - Make SAN an optional dependency
6
+
1
7
  v1.1 (25th November 2008)
2
8
  - Add support for detecting and extracting embedded SANs
3
9
 
data/lib/ean13.rb CHANGED
@@ -4,7 +4,7 @@ class EAN13
4
4
 
5
5
  class Version #:nodoc:
6
6
  Major = 1
7
- Minor = 2
7
+ Minor = 3
8
8
  Tiny = 0
9
9
 
10
10
  String = [Major, Minor, Tiny].join('.')
@@ -18,6 +18,10 @@ class EAN13
18
18
  EAN13.valid? @number
19
19
  end
20
20
 
21
+ def bookland?
22
+ valid? && (@number[0,3] == "978" || @number[0,3] == "979")
23
+ end
24
+
21
25
  def self.valid?(ean)
22
26
  ean = ean.to_s
23
27
  ean.length == 13 && ean == EAN13.complete(ean[0,12])
data/spec/ean13_spec.rb CHANGED
@@ -24,6 +24,14 @@ describe "The EAN13 class" do
24
24
  EAN13.valid?("9781843549162").should be_false
25
25
  end
26
26
 
27
+ it "should identify a bookland EAN13" do
28
+ EAN13.new("9781843549161").bookland?.should be_true
29
+ EAN13.new("9791843549160").bookland?.should be_true
30
+ EAN13.new("9791843549161").bookland?.should be_false
31
+ EAN13.new("sdw32423").bookland?.should be_false
32
+ EAN13.new("632737715836").bookland?.should be_false
33
+ end
34
+
27
35
  it "should calculate a EAN13 check digit correctly" do
28
36
  EAN13.complete("978184354916").should eql("9781843549161")
29
37
  EAN13.complete(978184354916).should eql("9781843549161")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ean13
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Healy
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-25 00:00:00 +11:00
12
+ date: 2009-07-11 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -28,6 +28,8 @@ files:
28
28
  - CHANGELOG
29
29
  has_rdoc: true
30
30
  homepage: http://github.com/yob/ean13/tree/master
31
+ licenses: []
32
+
31
33
  post_install_message:
32
34
  rdoc_options:
33
35
  - --title
@@ -50,9 +52,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
52
  requirements: []
51
53
 
52
54
  rubyforge_project: yob-projects
53
- rubygems_version: 1.3.1
55
+ rubygems_version: 1.3.4
54
56
  signing_key:
55
- specification_version: 2
57
+ specification_version: 3
56
58
  summary: a (very) small library for working with EAN-13 codes
57
59
  test_files:
58
60
  - spec/ean13_spec.rb