cuecat 1.0.0 → 1.1.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 +3 -0
  2. data/lib/cuecat.rb +11 -1
  3. data/spec/cuecat_spec.rb +10 -0
  4. metadata +12 -2
data/CHANGELOG CHANGED
@@ -1,2 +1,5 @@
1
+ v1.1 (XX)
2
+ - Add UPC detection
3
+
1
4
  v1.0 (1st November 2008)
2
5
  - Initial Release
@@ -1,5 +1,6 @@
1
1
  require 'base64'
2
2
  require 'ean13'
3
+ require 'upc'
3
4
 
4
5
  # An extra simple class for decoding a cuecat code into
5
6
  # its components.
@@ -19,7 +20,7 @@ class CueCat
19
20
 
20
21
  class Version #:nodoc:
21
22
  Major = 1
22
- Minor = 0
23
+ Minor = 1
23
24
  Tiny = 0
24
25
 
25
26
  String = [Major, Minor, Tiny].join('.')
@@ -45,6 +46,10 @@ class CueCat
45
46
  def ean?(code)
46
47
  self.new(code).ean?
47
48
  end
49
+
50
+ def upc?(code)
51
+ self.new(code).upc?
52
+ end
48
53
  end
49
54
 
50
55
  # process a new cuecat code
@@ -68,6 +73,11 @@ class CueCat
68
73
  EAN13.valid?(@value)
69
74
  end
70
75
 
76
+ def upc?
77
+ return false if @value.nil?
78
+ UPC.valid?(@value)
79
+ end
80
+
71
81
  private
72
82
 
73
83
  # Swap letters with their upper or lower case equivilants.
@@ -23,11 +23,15 @@ describe "The CueCat class" do
23
23
  end
24
24
 
25
25
  it "should correctly detect valid codes" do
26
+ # EAN
26
27
  CueCat.valid?(".C3nZC3nZC3n2CNjXCNz0DxnY.cGf2.ENr7C3j3C3f7Dxr7DxzYDNnZ.").should be_true
27
28
  CueCat.valid?(".C3nZC3nZC3n2CNjXCNz0DxnY.cGen.ENr7C3T1E3DZDxPWCW.").should be_true
28
29
  CueCat.valid?(".C3nZC3nZC3n2CNjXCNz0DxnY.cGen.ENr7CNT3Chz3ENj1CG.").should be_true
29
30
 
30
31
  CueCat.new(".C3nZC3nZC3n2CNjXCNz0DxnY.cGen.ENr7CNT3Chz3ENj1CG.").valid?.should be_true
32
+
33
+ # UPC
34
+ CueCat.valid?(".C3nZC3nZC3n2CNjXCNz0DxnY.fHmc.DxbXDhb0Dhf7ChbY.").should be_true
31
35
  end
32
36
 
33
37
  it "should correctly detect invalid codes" do
@@ -44,4 +48,10 @@ describe "The CueCat class" do
44
48
  CueCat.ean?(".C3nZC3nZC3n2CNjXCNz0DxnY.cGen.ENr7CNT3Chz3ENj1CG.").should be_true
45
49
  end
46
50
 
51
+ it "should correctly detect UPC12 codes" do
52
+ CueCat.new(".C3nZC3nZC3n2CNjXCNz0DxnY.fHmc.DxbXDhb0Dhf7ChbY.").upc?.should be_true
53
+
54
+ CueCat.upc?(".C3nZC3nZC3n2CNjXCNz0DxnY.fHmc.DxbXDhb0Dhf7ChbY.").should be_true
55
+ end
56
+
47
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cuecat
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.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: 2008-11-03 00:00:00 +11:00
12
+ date: 2008-11-05 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: "1.0"
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: upc
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "1.0"
34
+ version:
25
35
  description: a (very) small library for working with cuecat codes
26
36
  email: jimmy@deefa.com
27
37
  executables: []