USPS-intelligent-barcode 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -6
- data/Gemfile.lock +8 -7
- data/Rakefile +1 -1
- data/USPS-intelligent-barcode.gemspec +50 -45
- data/VERSION +1 -1
- data/lib/USPS-intelligent-barcode.rb +13 -12
- data/lib/USPS-intelligent-barcode/{BarMap.rb → bar_map.rb} +6 -9
- data/lib/USPS-intelligent-barcode/{BarPosition.rb → bar_position.rb} +5 -8
- data/lib/USPS-intelligent-barcode/bar_symbol.rb +49 -0
- data/lib/USPS-intelligent-barcode/{Barcode.rb → barcode.rb} +7 -5
- data/lib/USPS-intelligent-barcode/{BarcodeId.rb → barcode_id.rb} +0 -0
- data/lib/USPS-intelligent-barcode/{CharacterPosition.rb → character_position.rb} +0 -0
- data/lib/USPS-intelligent-barcode/{CodewordMap.rb → codeword_map.rb} +0 -0
- data/lib/USPS-intelligent-barcode/{Crc.rb → crc.rb} +4 -8
- data/lib/USPS-intelligent-barcode/{MailerId.rb → mailer_id.rb} +0 -0
- data/lib/USPS-intelligent-barcode/{NumericConversions.rb → numeric_conversions.rb} +0 -0
- data/lib/USPS-intelligent-barcode/{RoutingCode.rb → routing_code.rb} +0 -0
- data/lib/USPS-intelligent-barcode/{SerialNumber.rb → serial_number.rb} +0 -0
- data/lib/USPS-intelligent-barcode/{ServiceType.rb → service_type.rb} +0 -0
- data/spec/{BarMap_spec.rb → bar_map_spec.rb} +2 -2
- data/spec/bar_position_spec.rb +40 -0
- data/spec/bar_symbol_spec.rb +39 -0
- data/spec/{BarcodeId_spec.rb → barcode_id_spec.rb} +0 -0
- data/spec/{Barcode_spec.rb → barcode_spec.rb} +0 -0
- data/spec/{CharacterPosition_spec.rb → character_position_spec.rb} +0 -0
- data/spec/{CodewordMap_spec.rb → codeword_map_spec.rb} +0 -0
- data/spec/{Crc_spec.rb → crc_spec.rb} +2 -2
- data/spec/{MailerId_spec.rb → mailer_id_spec.rb} +0 -0
- data/spec/{NumericConversions_spec.rb → numeric_conversions_spec.rb} +0 -0
- data/spec/{RoutingCode_spec.rb → routing_code_spec.rb} +0 -0
- data/spec/{SerialNumber_spec.rb → serial_number_spec.rb} +0 -0
- data/spec/{ServiceType_spec.rb → service_type_spec.rb} +0 -0
- metadata +110 -133
- data/spec/BarPosition_spec.rb +0 -52
data/Gemfile
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
gem 'andand', '~> 1.3'
|
4
|
-
gem 'memoizer', '~> 1.0'
|
3
|
+
gem 'andand', '~> 1.3.3'
|
4
|
+
gem 'memoizer', '~> 1.0.1'
|
5
5
|
|
6
6
|
group :development do
|
7
|
-
gem 'jeweler', '~> 1.8'
|
8
|
-
gem 'rspec', '~> 2.12'
|
9
|
-
gem 'simplecov', '~> 0.7', :platform => :ruby_19
|
10
|
-
gem 'yard', '~> 0.8'
|
7
|
+
gem 'jeweler', '~> 1.8.4'
|
8
|
+
gem 'rspec', '~> 2.12.0'
|
9
|
+
gem 'simplecov', '~> 0.7.1', :platform => :ruby_19
|
10
|
+
gem 'yard', '~> 0.8.3'
|
11
|
+
gem 'rake', '~> 10.0.3'
|
11
12
|
end
|
data/Gemfile.lock
CHANGED
@@ -9,7 +9,7 @@ GEM
|
|
9
9
|
git (>= 1.2.5)
|
10
10
|
rake
|
11
11
|
rdoc
|
12
|
-
json (1.7.
|
12
|
+
json (1.7.6)
|
13
13
|
memoizer (1.0.1)
|
14
14
|
multi_json (1.5.0)
|
15
15
|
rake (10.0.3)
|
@@ -33,9 +33,10 @@ PLATFORMS
|
|
33
33
|
ruby
|
34
34
|
|
35
35
|
DEPENDENCIES
|
36
|
-
andand (~> 1.3)
|
37
|
-
jeweler (~> 1.8)
|
38
|
-
memoizer (~> 1.0)
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
andand (~> 1.3.3)
|
37
|
+
jeweler (~> 1.8.4)
|
38
|
+
memoizer (~> 1.0.1)
|
39
|
+
rake (~> 10.0.3)
|
40
|
+
rspec (~> 2.12.0)
|
41
|
+
simplecov (~> 0.7.1)
|
42
|
+
yard (~> 0.8.3)
|
data/Rakefile
CHANGED
@@ -24,7 +24,7 @@ Jeweler::Tasks.new do |gem|
|
|
24
24
|
"Mail barcode. It generates the string of characters "\
|
25
25
|
"to print with one of the USPS Intelligent Mail barcode "\
|
26
26
|
"fonts.")
|
27
|
-
gem.email = "
|
27
|
+
gem.email = "wconrad@yagni.com"
|
28
28
|
gem.authors = ["Wayne Conrad"]
|
29
29
|
# dependencies defined in Gemfile
|
30
30
|
end
|
@@ -5,13 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "USPS-intelligent-barcode"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Wayne Conrad"]
|
12
|
-
s.date = "
|
12
|
+
s.date = "2013-01-05"
|
13
13
|
s.description = "A pure Ruby library to generate a USPS Intelligent Mail barcode. It generates the string of characters to print with one of the USPS Intelligent Mail barcode fonts."
|
14
|
-
s.email = "
|
14
|
+
s.email = "wconrad@yagni.com"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.md",
|
17
17
|
"README.rdoc"
|
@@ -26,32 +26,34 @@ Gem::Specification.new do |s|
|
|
26
26
|
"VERSION",
|
27
27
|
"examples/example.rb",
|
28
28
|
"lib/USPS-intelligent-barcode.rb",
|
29
|
-
"lib/USPS-intelligent-barcode/
|
30
|
-
"lib/USPS-intelligent-barcode/
|
31
|
-
"lib/USPS-intelligent-barcode/
|
32
|
-
"lib/USPS-intelligent-barcode/BarcodeId.rb",
|
33
|
-
"lib/USPS-intelligent-barcode/CharacterPosition.rb",
|
34
|
-
"lib/USPS-intelligent-barcode/CodewordMap.rb",
|
35
|
-
"lib/USPS-intelligent-barcode/Crc.rb",
|
36
|
-
"lib/USPS-intelligent-barcode/MailerId.rb",
|
37
|
-
"lib/USPS-intelligent-barcode/NumericConversions.rb",
|
38
|
-
"lib/USPS-intelligent-barcode/RoutingCode.rb",
|
39
|
-
"lib/USPS-intelligent-barcode/SerialNumber.rb",
|
40
|
-
"lib/USPS-intelligent-barcode/ServiceType.rb",
|
29
|
+
"lib/USPS-intelligent-barcode/bar_map.rb",
|
30
|
+
"lib/USPS-intelligent-barcode/bar_position.rb",
|
31
|
+
"lib/USPS-intelligent-barcode/bar_symbol.rb",
|
41
32
|
"lib/USPS-intelligent-barcode/bar_to_character_mapping.yml",
|
33
|
+
"lib/USPS-intelligent-barcode/barcode.rb",
|
34
|
+
"lib/USPS-intelligent-barcode/barcode_id.rb",
|
35
|
+
"lib/USPS-intelligent-barcode/character_position.rb",
|
36
|
+
"lib/USPS-intelligent-barcode/codeword_map.rb",
|
42
37
|
"lib/USPS-intelligent-barcode/codeword_to_character_mapping.yml",
|
43
|
-
"
|
44
|
-
"
|
45
|
-
"
|
46
|
-
"
|
47
|
-
"
|
48
|
-
"
|
49
|
-
"spec/
|
50
|
-
"spec/
|
51
|
-
"spec/
|
52
|
-
"spec/
|
53
|
-
"spec/
|
54
|
-
"spec/
|
38
|
+
"lib/USPS-intelligent-barcode/crc.rb",
|
39
|
+
"lib/USPS-intelligent-barcode/mailer_id.rb",
|
40
|
+
"lib/USPS-intelligent-barcode/numeric_conversions.rb",
|
41
|
+
"lib/USPS-intelligent-barcode/routing_code.rb",
|
42
|
+
"lib/USPS-intelligent-barcode/serial_number.rb",
|
43
|
+
"lib/USPS-intelligent-barcode/service_type.rb",
|
44
|
+
"spec/bar_map_spec.rb",
|
45
|
+
"spec/bar_position_spec.rb",
|
46
|
+
"spec/bar_symbol_spec.rb",
|
47
|
+
"spec/barcode_id_spec.rb",
|
48
|
+
"spec/barcode_spec.rb",
|
49
|
+
"spec/character_position_spec.rb",
|
50
|
+
"spec/codeword_map_spec.rb",
|
51
|
+
"spec/crc_spec.rb",
|
52
|
+
"spec/mailer_id_spec.rb",
|
53
|
+
"spec/numeric_conversions_spec.rb",
|
54
|
+
"spec/routing_code_spec.rb",
|
55
|
+
"spec/serial_number_spec.rb",
|
56
|
+
"spec/service_type_spec.rb",
|
55
57
|
"spec/spec_helper.rb"
|
56
58
|
]
|
57
59
|
s.homepage = "http://github.com/wconrad/USPS-intelligent-barcode"
|
@@ -64,27 +66,30 @@ Gem::Specification.new do |s|
|
|
64
66
|
s.specification_version = 3
|
65
67
|
|
66
68
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
67
|
-
s.add_runtime_dependency(%q<andand>, ["~> 1.3"])
|
68
|
-
s.add_runtime_dependency(%q<memoizer>, ["~> 1.0"])
|
69
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.8"])
|
70
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.12"])
|
71
|
-
s.add_development_dependency(%q<simplecov>, ["~> 0.7"])
|
72
|
-
s.add_development_dependency(%q<yard>, ["~> 0.8"])
|
69
|
+
s.add_runtime_dependency(%q<andand>, ["~> 1.3.3"])
|
70
|
+
s.add_runtime_dependency(%q<memoizer>, ["~> 1.0.1"])
|
71
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
72
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.12.0"])
|
73
|
+
s.add_development_dependency(%q<simplecov>, ["~> 0.7.1"])
|
74
|
+
s.add_development_dependency(%q<yard>, ["~> 0.8.3"])
|
75
|
+
s.add_development_dependency(%q<rake>, ["~> 10.0.3"])
|
73
76
|
else
|
74
|
-
s.add_dependency(%q<andand>, ["~> 1.3"])
|
75
|
-
s.add_dependency(%q<memoizer>, ["~> 1.0"])
|
76
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
77
|
-
s.add_dependency(%q<rspec>, ["~> 2.12"])
|
78
|
-
s.add_dependency(%q<simplecov>, ["~> 0.7"])
|
79
|
-
s.add_dependency(%q<yard>, ["~> 0.8"])
|
77
|
+
s.add_dependency(%q<andand>, ["~> 1.3.3"])
|
78
|
+
s.add_dependency(%q<memoizer>, ["~> 1.0.1"])
|
79
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
80
|
+
s.add_dependency(%q<rspec>, ["~> 2.12.0"])
|
81
|
+
s.add_dependency(%q<simplecov>, ["~> 0.7.1"])
|
82
|
+
s.add_dependency(%q<yard>, ["~> 0.8.3"])
|
83
|
+
s.add_dependency(%q<rake>, ["~> 10.0.3"])
|
80
84
|
end
|
81
85
|
else
|
82
|
-
s.add_dependency(%q<andand>, ["~> 1.3"])
|
83
|
-
s.add_dependency(%q<memoizer>, ["~> 1.0"])
|
84
|
-
s.add_dependency(%q<jeweler>, ["~> 1.8"])
|
85
|
-
s.add_dependency(%q<rspec>, ["~> 2.12"])
|
86
|
-
s.add_dependency(%q<simplecov>, ["~> 0.7"])
|
87
|
-
s.add_dependency(%q<yard>, ["~> 0.8"])
|
86
|
+
s.add_dependency(%q<andand>, ["~> 1.3.3"])
|
87
|
+
s.add_dependency(%q<memoizer>, ["~> 1.0.1"])
|
88
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
89
|
+
s.add_dependency(%q<rspec>, ["~> 2.12.0"])
|
90
|
+
s.add_dependency(%q<simplecov>, ["~> 0.7.1"])
|
91
|
+
s.add_dependency(%q<yard>, ["~> 0.8.3"])
|
92
|
+
s.add_dependency(%q<rake>, ["~> 10.0.3"])
|
88
93
|
end
|
89
94
|
end
|
90
95
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
@@ -2,15 +2,16 @@ require 'andand'
|
|
2
2
|
require 'memoizer'
|
3
3
|
require 'yaml'
|
4
4
|
|
5
|
-
require 'USPS-intelligent-barcode/
|
6
|
-
require 'USPS-intelligent-barcode/
|
7
|
-
require 'USPS-intelligent-barcode/
|
8
|
-
require 'USPS-intelligent-barcode/
|
9
|
-
require 'USPS-intelligent-barcode/
|
10
|
-
require 'USPS-intelligent-barcode/
|
11
|
-
require 'USPS-intelligent-barcode/
|
12
|
-
require 'USPS-intelligent-barcode/
|
13
|
-
require 'USPS-intelligent-barcode/
|
14
|
-
require 'USPS-intelligent-barcode/
|
15
|
-
require 'USPS-intelligent-barcode/
|
16
|
-
require 'USPS-intelligent-barcode/
|
5
|
+
require 'USPS-intelligent-barcode/bar_map'
|
6
|
+
require 'USPS-intelligent-barcode/bar_position'
|
7
|
+
require 'USPS-intelligent-barcode/bar_symbol'
|
8
|
+
require 'USPS-intelligent-barcode/barcode'
|
9
|
+
require 'USPS-intelligent-barcode/barcode_id'
|
10
|
+
require 'USPS-intelligent-barcode/character_position'
|
11
|
+
require 'USPS-intelligent-barcode/codeword_map'
|
12
|
+
require 'USPS-intelligent-barcode/crc'
|
13
|
+
require 'USPS-intelligent-barcode/mailer_id'
|
14
|
+
require 'USPS-intelligent-barcode/numeric_conversions'
|
15
|
+
require 'USPS-intelligent-barcode/routing_code'
|
16
|
+
require 'USPS-intelligent-barcode/serial_number'
|
17
|
+
require 'USPS-intelligent-barcode/service_type'
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'USPS-intelligent-barcode/
|
1
|
+
require 'USPS-intelligent-barcode/character_position'
|
2
2
|
|
3
3
|
# @!group Internal
|
4
4
|
|
@@ -14,14 +14,11 @@ module Imb
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# Given an array of intelligent barcode "characters", return an
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
|
21
|
-
|
22
|
-
# @return [[Integer]]
|
23
|
-
|
24
|
-
def barcode(characters)
|
17
|
+
# the symbols for each position.
|
18
|
+
# @param [[Integer]] characters array of characters
|
19
|
+
# @return [[BarSymbol]] array of symbols
|
20
|
+
|
21
|
+
def symbols(characters)
|
25
22
|
@mapping.map do |bar_position|
|
26
23
|
bar_position.map(characters)
|
27
24
|
end
|
@@ -15,17 +15,14 @@ module Imb
|
|
15
15
|
@ascender_character_position = ascender_character_position
|
16
16
|
end
|
17
17
|
|
18
|
-
# Given an array of characters, return a symbol
|
19
|
-
# barcode position.
|
20
|
-
# * 0 - tracking mark (neither ascending nor descending)
|
21
|
-
# * 1 - descending mark
|
22
|
-
# * 2 - ascending mark
|
23
|
-
# * 3 - full mark (both ascending and descending)
|
18
|
+
# Given an array of characters, return a symbol for this
|
19
|
+
# barcode position.
|
24
20
|
# @param [[Integer]] characters character codes
|
25
|
-
# @return [
|
21
|
+
# @return [BarSymbol] symbol code
|
26
22
|
|
27
23
|
def map(characters)
|
28
|
-
|
24
|
+
BarSymbol.make(ascender_bit(characters),
|
25
|
+
descender_bit(characters))
|
29
26
|
end
|
30
27
|
|
31
28
|
private
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Imb
|
2
|
+
|
3
|
+
# @!group Internal
|
4
|
+
|
5
|
+
# Represents a symbol in the barcode.
|
6
|
+
|
7
|
+
class BarSymbol
|
8
|
+
|
9
|
+
# @param [Integer] ascender_bit (0..1)
|
10
|
+
# @param [Integer] descender_bit (0..1)
|
11
|
+
# @return [BarSymbol]
|
12
|
+
|
13
|
+
def self.make(ascender_bit, descender_bit)
|
14
|
+
case [ascender_bit, descender_bit]
|
15
|
+
when [0, 0]
|
16
|
+
TRACKER
|
17
|
+
when [0, 1]
|
18
|
+
DESCENDER
|
19
|
+
when [1, 0]
|
20
|
+
ASCENDER
|
21
|
+
when [1, 1]
|
22
|
+
FULL
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# @return [Integer] the code for this symbol
|
27
|
+
attr_reader :code
|
28
|
+
|
29
|
+
# @return [String] the letter for this symbol
|
30
|
+
attr_reader :letter
|
31
|
+
|
32
|
+
# @param [Integer] code (0..3)
|
33
|
+
# @param [String] letter
|
34
|
+
|
35
|
+
def initialize(code, letter)
|
36
|
+
@code = code
|
37
|
+
@letter = letter
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
TRACKER = BarSymbol.new(0, 'T')
|
43
|
+
DESCENDER = BarSymbol.new(1, 'D')
|
44
|
+
ASCENDER = BarSymbol.new(2, 'A')
|
45
|
+
FULL = BarSymbol.new(3, 'F')
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require 'USPS-intelligent-barcode/
|
1
|
+
require 'USPS-intelligent-barcode/codeword_map'
|
2
|
+
require 'USPS-intelligent-barcode/crc'
|
2
3
|
|
3
4
|
# The namespace for everything in this library.
|
4
5
|
|
@@ -62,7 +63,7 @@ module Imb
|
|
62
63
|
# @return [String] A string that represents the barcode.
|
63
64
|
|
64
65
|
def barcode_letters
|
65
|
-
|
66
|
+
symbols.map(&:letter).join
|
66
67
|
end
|
67
68
|
|
68
69
|
private
|
@@ -70,6 +71,7 @@ module Imb
|
|
70
71
|
# :stopdoc:
|
71
72
|
BAR_MAP = BarMap.new
|
72
73
|
CODEWORD_MAP = CodewordMap.new
|
74
|
+
CRC = Crc.new
|
73
75
|
# :startdoc:
|
74
76
|
|
75
77
|
def validate_components
|
@@ -100,7 +102,7 @@ module Imb
|
|
100
102
|
memoize :binary_data
|
101
103
|
|
102
104
|
def frame_check_sequence
|
103
|
-
|
105
|
+
CRC.crc(binary_data)
|
104
106
|
end
|
105
107
|
memoize :frame_check_sequence
|
106
108
|
|
@@ -141,8 +143,8 @@ module Imb
|
|
141
143
|
end
|
142
144
|
end
|
143
145
|
|
144
|
-
def
|
145
|
-
BAR_MAP.
|
146
|
+
def symbols
|
147
|
+
BAR_MAP.symbols(characters_with_fcs_bits_0_through_9)
|
146
148
|
end
|
147
149
|
|
148
150
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'USPS-intelligent-barcode/
|
1
|
+
require 'USPS-intelligent-barcode/numeric_conversions'
|
2
2
|
|
3
3
|
module Imb
|
4
4
|
|
@@ -8,13 +8,13 @@ module Imb
|
|
8
8
|
|
9
9
|
class Crc
|
10
10
|
|
11
|
-
|
11
|
+
include NumericConversions
|
12
12
|
|
13
13
|
# Calculate a CRC.
|
14
14
|
# @param [Integer] binary_data A 102-bit integer
|
15
15
|
# @return [Integer] An 11-bit CRC
|
16
16
|
|
17
|
-
def
|
17
|
+
def crc(binary_data)
|
18
18
|
crc = MASK
|
19
19
|
bytes = numeric_to_bytes(binary_data, NUM_INPUT_BYTES)
|
20
20
|
crc = crc_byte(crc, bytes.first, LEADING_BITS_TO_IGNORE)
|
@@ -26,8 +26,6 @@ module Imb
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
# :stopdoc:
|
30
|
-
|
31
29
|
LEADING_BITS_TO_IGNORE = 2
|
32
30
|
CRC_BITS = 11
|
33
31
|
CRC_MSB_MASK = 1 << (CRC_BITS - 1)
|
@@ -36,9 +34,7 @@ module Imb
|
|
36
34
|
MASK = (1 << CRC_BITS) - 1
|
37
35
|
NUM_INPUT_BYTES = 13
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
def self.crc_byte(crc, byte, leading_bits_to_ignore)
|
37
|
+
def crc_byte(crc, byte, leading_bits_to_ignore)
|
42
38
|
num_bits = BITS_PER_BYTE - leading_bits_to_ignore
|
43
39
|
data = byte << CRC_BITS - BITS_PER_BYTE + leading_bits_to_ignore
|
44
40
|
num_bits.times do
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -10,7 +10,7 @@ module Imb
|
|
10
10
|
0x01A3, 0x1BC3, 0x1838, 0x012B, 0x0076,
|
11
11
|
]
|
12
12
|
end
|
13
|
-
let(:
|
13
|
+
let(:codes) do
|
14
14
|
[
|
15
15
|
2, 0, 0, 3, 2, 0, 0, 1, 0, 0, 2, 1, 0,
|
16
16
|
2, 2, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 2,
|
@@ -22,7 +22,7 @@ module Imb
|
|
22
22
|
let(:bar_map) {BarMap.new}
|
23
23
|
|
24
24
|
specify do
|
25
|
-
bar_map.
|
25
|
+
bar_map.symbols(characters).map(&:code).should == codes
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module Imb
|
4
|
+
|
5
|
+
describe BarPosition do
|
6
|
+
|
7
|
+
describe '#map' do
|
8
|
+
|
9
|
+
let(:ascender_bit) {mock 'ascender bit'}
|
10
|
+
let(:descender_bit) {mock 'descender bit'}
|
11
|
+
let(:characters) {mock 'array of characters'}
|
12
|
+
let(:descender_character_position) {mock CharacterPosition}
|
13
|
+
let(:ascender_character_position) {mock CharacterPosition}
|
14
|
+
let(:bar_position) do
|
15
|
+
BarPosition.new(descender_character_position,
|
16
|
+
ascender_character_position)
|
17
|
+
end
|
18
|
+
let(:bar_symbol) {mock BarSymbol}
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
descender_character_position.stub(:extract_bit_from_characters)\
|
22
|
+
.with(characters)\
|
23
|
+
.and_return(descender_bit)
|
24
|
+
ascender_character_position.stub(:extract_bit_from_characters)\
|
25
|
+
.with(characters)\
|
26
|
+
.and_return(ascender_bit)
|
27
|
+
BarSymbol.stub(:make)\
|
28
|
+
.with(ascender_bit, descender_bit)\
|
29
|
+
.and_return(bar_symbol)
|
30
|
+
end
|
31
|
+
|
32
|
+
specify do
|
33
|
+
bar_position.map(characters).should == bar_symbol
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
+
|
3
|
+
module Imb
|
4
|
+
|
5
|
+
describe BarSymbol do
|
6
|
+
|
7
|
+
subject {BarSymbol.make(ascender_bit, descender_bit)}
|
8
|
+
|
9
|
+
context 'tracker' do
|
10
|
+
let(:ascender_bit) {0}
|
11
|
+
let(:descender_bit) {0}
|
12
|
+
its(:code) {should eq 0}
|
13
|
+
its(:letter) {should eq 'T'}
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'descender' do
|
17
|
+
let(:ascender_bit) {0}
|
18
|
+
let(:descender_bit) {1}
|
19
|
+
its(:code) {should eq 1}
|
20
|
+
its(:letter) {should eq 'D'}
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'ascender' do
|
24
|
+
let(:ascender_bit) {1}
|
25
|
+
let(:descender_bit) {0}
|
26
|
+
its(:code) {should eq 2}
|
27
|
+
its(:letter) {should eq 'A'}
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'full' do
|
31
|
+
let(:ascender_bit) {1}
|
32
|
+
let(:descender_bit) {1}
|
33
|
+
its(:code) {should eq 3}
|
34
|
+
its(:letter) {should eq 'F'}
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -7,11 +7,11 @@ module Imb
|
|
7
7
|
describe '#crc' do
|
8
8
|
|
9
9
|
specify do
|
10
|
-
Crc.crc(0x016907B2A24ABC16A2E5C004B1).should == 0x751
|
10
|
+
Crc.new.crc(0x016907B2A24ABC16A2E5C004B1).should == 0x751
|
11
11
|
end
|
12
12
|
|
13
13
|
specify do
|
14
|
-
Crc.crc(0).should == 0x6e0
|
14
|
+
Crc.new.crc(0).should == 0x6e0
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,122 +1,103 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: USPS-intelligent-barcode
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 3
|
10
|
-
version: 0.2.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Wayne Conrad
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-01-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: andand
|
22
|
-
|
23
|
-
type: :runtime
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &74337050 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 3
|
33
|
-
version: "1.3"
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: memoizer
|
37
|
-
prerelease: false
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.3.3
|
38
22
|
type: :runtime
|
39
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *74337050
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: memoizer
|
27
|
+
requirement: &74336660 !ruby/object:Gem::Requirement
|
40
28
|
none: false
|
41
|
-
requirements:
|
29
|
+
requirements:
|
42
30
|
- - ~>
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
- 1
|
47
|
-
- 0
|
48
|
-
version: "1.0"
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: jeweler
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.1
|
33
|
+
type: :runtime
|
52
34
|
prerelease: false
|
53
|
-
|
54
|
-
|
35
|
+
version_requirements: *74336660
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jeweler
|
38
|
+
requirement: &74336040 !ruby/object:Gem::Requirement
|
55
39
|
none: false
|
56
|
-
requirements:
|
40
|
+
requirements:
|
57
41
|
- - ~>
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 1
|
62
|
-
- 8
|
63
|
-
version: "1.8"
|
64
|
-
version_requirements: *id003
|
65
|
-
- !ruby/object:Gem::Dependency
|
66
|
-
name: rspec
|
67
|
-
prerelease: false
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.8.4
|
68
44
|
type: :development
|
69
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *74336040
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: &74335400 !ruby/object:Gem::Requirement
|
70
50
|
none: false
|
71
|
-
requirements:
|
51
|
+
requirements:
|
72
52
|
- - ~>
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 2
|
77
|
-
- 12
|
78
|
-
version: "2.12"
|
79
|
-
version_requirements: *id004
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: simplecov
|
82
|
-
prerelease: false
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.12.0
|
83
55
|
type: :development
|
84
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *74335400
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: simplecov
|
60
|
+
requirement: &74334690 !ruby/object:Gem::Requirement
|
85
61
|
none: false
|
86
|
-
requirements:
|
62
|
+
requirements:
|
87
63
|
- - ~>
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
|
91
|
-
- 0
|
92
|
-
- 7
|
93
|
-
version: "0.7"
|
94
|
-
version_requirements: *id005
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: yard
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: 0.7.1
|
66
|
+
type: :development
|
97
67
|
prerelease: false
|
68
|
+
version_requirements: *74334690
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: yard
|
71
|
+
requirement: &74334240 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.8.3
|
98
77
|
type: :development
|
99
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *74334240
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rake
|
82
|
+
requirement: &74333530 !ruby/object:Gem::Requirement
|
100
83
|
none: false
|
101
|
-
requirements:
|
84
|
+
requirements:
|
102
85
|
- - ~>
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
email:
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 10.0.3
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *74333530
|
91
|
+
description: A pure Ruby library to generate a USPS Intelligent Mail barcode. It
|
92
|
+
generates the string of characters to print with one of the USPS Intelligent Mail
|
93
|
+
barcode fonts.
|
94
|
+
email: wconrad@yagni.com
|
112
95
|
executables: []
|
113
|
-
|
114
96
|
extensions: []
|
115
|
-
|
116
|
-
extra_rdoc_files:
|
97
|
+
extra_rdoc_files:
|
117
98
|
- LICENSE.md
|
118
99
|
- README.rdoc
|
119
|
-
files:
|
100
|
+
files:
|
120
101
|
- Gemfile
|
121
102
|
- Gemfile.lock
|
122
103
|
- LICENSE.md
|
@@ -126,65 +107,61 @@ files:
|
|
126
107
|
- VERSION
|
127
108
|
- examples/example.rb
|
128
109
|
- lib/USPS-intelligent-barcode.rb
|
129
|
-
- lib/USPS-intelligent-barcode/
|
130
|
-
- lib/USPS-intelligent-barcode/
|
131
|
-
- lib/USPS-intelligent-barcode/
|
132
|
-
- lib/USPS-intelligent-barcode/BarcodeId.rb
|
133
|
-
- lib/USPS-intelligent-barcode/CharacterPosition.rb
|
134
|
-
- lib/USPS-intelligent-barcode/CodewordMap.rb
|
135
|
-
- lib/USPS-intelligent-barcode/Crc.rb
|
136
|
-
- lib/USPS-intelligent-barcode/MailerId.rb
|
137
|
-
- lib/USPS-intelligent-barcode/NumericConversions.rb
|
138
|
-
- lib/USPS-intelligent-barcode/RoutingCode.rb
|
139
|
-
- lib/USPS-intelligent-barcode/SerialNumber.rb
|
140
|
-
- lib/USPS-intelligent-barcode/ServiceType.rb
|
110
|
+
- lib/USPS-intelligent-barcode/bar_map.rb
|
111
|
+
- lib/USPS-intelligent-barcode/bar_position.rb
|
112
|
+
- lib/USPS-intelligent-barcode/bar_symbol.rb
|
141
113
|
- lib/USPS-intelligent-barcode/bar_to_character_mapping.yml
|
114
|
+
- lib/USPS-intelligent-barcode/barcode.rb
|
115
|
+
- lib/USPS-intelligent-barcode/barcode_id.rb
|
116
|
+
- lib/USPS-intelligent-barcode/character_position.rb
|
117
|
+
- lib/USPS-intelligent-barcode/codeword_map.rb
|
142
118
|
- lib/USPS-intelligent-barcode/codeword_to_character_mapping.yml
|
143
|
-
-
|
144
|
-
-
|
145
|
-
-
|
146
|
-
-
|
147
|
-
-
|
148
|
-
-
|
149
|
-
- spec/
|
150
|
-
- spec/
|
151
|
-
- spec/
|
152
|
-
- spec/
|
153
|
-
- spec/
|
154
|
-
- spec/
|
119
|
+
- lib/USPS-intelligent-barcode/crc.rb
|
120
|
+
- lib/USPS-intelligent-barcode/mailer_id.rb
|
121
|
+
- lib/USPS-intelligent-barcode/numeric_conversions.rb
|
122
|
+
- lib/USPS-intelligent-barcode/routing_code.rb
|
123
|
+
- lib/USPS-intelligent-barcode/serial_number.rb
|
124
|
+
- lib/USPS-intelligent-barcode/service_type.rb
|
125
|
+
- spec/bar_map_spec.rb
|
126
|
+
- spec/bar_position_spec.rb
|
127
|
+
- spec/bar_symbol_spec.rb
|
128
|
+
- spec/barcode_id_spec.rb
|
129
|
+
- spec/barcode_spec.rb
|
130
|
+
- spec/character_position_spec.rb
|
131
|
+
- spec/codeword_map_spec.rb
|
132
|
+
- spec/crc_spec.rb
|
133
|
+
- spec/mailer_id_spec.rb
|
134
|
+
- spec/numeric_conversions_spec.rb
|
135
|
+
- spec/routing_code_spec.rb
|
136
|
+
- spec/serial_number_spec.rb
|
137
|
+
- spec/service_type_spec.rb
|
155
138
|
- spec/spec_helper.rb
|
156
139
|
homepage: http://github.com/wconrad/USPS-intelligent-barcode
|
157
|
-
licenses:
|
140
|
+
licenses:
|
158
141
|
- MIT
|
159
142
|
post_install_message:
|
160
143
|
rdoc_options: []
|
161
|
-
|
162
|
-
require_paths:
|
144
|
+
require_paths:
|
163
145
|
- lib
|
164
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
147
|
none: false
|
166
|
-
requirements:
|
167
|
-
- -
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
|
170
|
-
segments:
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
segments:
|
171
153
|
- 0
|
172
|
-
|
173
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
hash: 56220669
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
156
|
none: false
|
175
|
-
requirements:
|
176
|
-
- -
|
177
|
-
- !ruby/object:Gem::Version
|
178
|
-
|
179
|
-
segments:
|
180
|
-
- 0
|
181
|
-
version: "0"
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
182
161
|
requirements: []
|
183
|
-
|
184
162
|
rubyforge_project:
|
185
163
|
rubygems_version: 1.8.17
|
186
164
|
signing_key:
|
187
165
|
specification_version: 3
|
188
166
|
summary: Generates a USPS Intelligent Mail Barcode.
|
189
167
|
test_files: []
|
190
|
-
|
data/spec/BarPosition_spec.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
2
|
-
|
3
|
-
module Imb
|
4
|
-
|
5
|
-
describe BarPosition do
|
6
|
-
|
7
|
-
describe '#map' do
|
8
|
-
|
9
|
-
let(:characters) {mock 'array of characters'}
|
10
|
-
let(:descender_character_position) {mock CharacterPosition}
|
11
|
-
let(:ascender_character_position) {mock CharacterPosition}
|
12
|
-
let(:bar_position) do
|
13
|
-
BarPosition.new(descender_character_position,
|
14
|
-
ascender_character_position)
|
15
|
-
end
|
16
|
-
|
17
|
-
before(:each) do
|
18
|
-
descender_character_position.stub(:extract_bit_from_characters)\
|
19
|
-
.with(characters).and_return(descender_bit)
|
20
|
-
ascender_character_position.stub(:extract_bit_from_characters)\
|
21
|
-
.with(characters).and_return(ascender_bit)
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'without ascender, without descender' do
|
25
|
-
let(:ascender_bit) {0}
|
26
|
-
let(:descender_bit) {0}
|
27
|
-
specify {bar_position.map(characters).should == 0}
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'without ascender, with descender' do
|
31
|
-
let(:ascender_bit) {0}
|
32
|
-
let(:descender_bit) {1}
|
33
|
-
specify {bar_position.map(characters).should == 1}
|
34
|
-
end
|
35
|
-
|
36
|
-
context 'with ascender, without descender' do
|
37
|
-
let(:ascender_bit) {1}
|
38
|
-
let(:descender_bit) {0}
|
39
|
-
specify {bar_position.map(characters).should == 2}
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'with ascender, with descender' do
|
43
|
-
let(:ascender_bit) {1}
|
44
|
-
let(:descender_bit) {1}
|
45
|
-
specify {bar_position.map(characters).should == 3}
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|