usps_intelligent_barcode 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.
- checksums.yaml +5 -5
- data/.gitignore +6 -0
- data/.ruby-version +1 -0
- data/{CHANGELOG.markdown → CHANGELOG.md} +27 -12
- data/Gemfile +2 -16
- data/Gemfile.lock +74 -85
- data/LICENSE.md +7 -0
- data/{README.markdown → README.md} +56 -36
- data/VERSION +1 -1
- data/doc/font_installation.md +55 -0
- data/doc/migration.md +47 -0
- data/doc/publishing.md +75 -0
- data/examples/example.rb +4 -4
- data/examples/generate_pdf.rb +70 -0
- data/fonts/LICENSE +47 -0
- data/fonts/USPSIMBCompact.ttf +0 -0
- data/fonts/USPSIMBStandard.ttf +0 -0
- data/lib/usps_intelligent_barcode/barcode.rb +33 -30
- data/lib/usps_intelligent_barcode/barcode_id.rb +5 -0
- data/lib/usps_intelligent_barcode/mailer_id.rb +6 -1
- data/lib/usps_intelligent_barcode/project_dirs.rb +19 -0
- data/lib/usps_intelligent_barcode/routing_code.rb +20 -10
- data/lib/usps_intelligent_barcode/serial_number.rb +6 -1
- data/lib/usps_intelligent_barcode/service_type.rb +6 -1
- data/lib/usps_intelligent_barcode/usps_fonts.rb +48 -0
- data/lib/usps_intelligent_barcode.rb +2 -0
- data/rake/bundler.rb +1 -0
- data/rake/version.rb +33 -0
- data/rake/yard.rb +1 -0
- data/usps_intelligent_barcode.gemspec +24 -97
- metadata +67 -46
- data/USPS-intelligent-barcode.gemspec +0 -95
- data/rake/jeweler.rb +0 -23
- data/spec/bar_map_spec.rb +0 -30
- data/spec/bar_position_spec.rb +0 -40
- data/spec/bar_symbol_spec.rb +0 -39
- data/spec/barcode_id_spec.rb +0 -106
- data/spec/barcode_spec.rb +0 -213
- data/spec/character_position_spec.rb +0 -25
- data/spec/codeword_map_spec.rb +0 -22
- data/spec/crc_spec.rb +0 -21
- data/spec/mailer_id_spec.rb +0 -124
- data/spec/numeric_conversions_spec.rb +0 -23
- data/spec/routing_code_spec.rb +0 -180
- data/spec/serial_number_spec.rb +0 -117
- data/spec/service_type_spec.rb +0 -93
- data/spec/spec_helper.rb +0 -9
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: usps_intelligent_barcode
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Wayne Conrad
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: andand
|
|
@@ -39,81 +38,115 @@ dependencies:
|
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
39
|
version: '1.0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
41
|
+
name: prawn
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
44
|
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '2.
|
|
46
|
+
version: '2.5'
|
|
48
47
|
type: :development
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
51
|
- - "~>"
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '2.
|
|
53
|
+
version: '2.5'
|
|
55
54
|
- !ruby/object:Gem::Dependency
|
|
56
55
|
name: rake
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
58
|
- - "~>"
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
60
|
+
version: '13.0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '13.0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: rspec
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '3.12'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '3.12'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: rspec-its
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - "~>"
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '2.0'
|
|
62
89
|
type: :development
|
|
63
90
|
prerelease: false
|
|
64
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
92
|
requirements:
|
|
66
93
|
- - "~>"
|
|
67
94
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
95
|
+
version: '2.0'
|
|
69
96
|
- !ruby/object:Gem::Dependency
|
|
70
97
|
name: simplecov
|
|
71
98
|
requirement: !ruby/object:Gem::Requirement
|
|
72
99
|
requirements:
|
|
73
|
-
- - "
|
|
100
|
+
- - "~>"
|
|
74
101
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0'
|
|
102
|
+
version: '0.22'
|
|
76
103
|
type: :development
|
|
77
104
|
prerelease: false
|
|
78
105
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
106
|
requirements:
|
|
80
|
-
- - "
|
|
107
|
+
- - "~>"
|
|
81
108
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0'
|
|
109
|
+
version: '0.22'
|
|
83
110
|
- !ruby/object:Gem::Dependency
|
|
84
111
|
name: yard
|
|
85
112
|
requirement: !ruby/object:Gem::Requirement
|
|
86
113
|
requirements:
|
|
87
114
|
- - "~>"
|
|
88
115
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 0.
|
|
116
|
+
version: '0.9'
|
|
90
117
|
type: :development
|
|
91
118
|
prerelease: false
|
|
92
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
120
|
requirements:
|
|
94
121
|
- - "~>"
|
|
95
122
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 0.
|
|
97
|
-
description: A pure Ruby library to generate a USPS Intelligent Mail barcode.
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
email:
|
|
123
|
+
version: '0.9'
|
|
124
|
+
description: A pure Ruby library to generate a USPS Intelligent Mail barcode. It generates
|
|
125
|
+
the string of characters to print with one of the USPS Intelligent Mail barcode
|
|
126
|
+
fonts.
|
|
127
|
+
email: kf7qga@gmail.com
|
|
101
128
|
executables: []
|
|
102
129
|
extensions: []
|
|
103
|
-
extra_rdoc_files:
|
|
104
|
-
- LICENSE.md
|
|
105
|
-
- README.markdown
|
|
130
|
+
extra_rdoc_files: []
|
|
106
131
|
files:
|
|
132
|
+
- ".gitignore"
|
|
133
|
+
- ".ruby-version"
|
|
107
134
|
- ".travis.yml"
|
|
108
|
-
- CHANGELOG.
|
|
135
|
+
- CHANGELOG.md
|
|
109
136
|
- Gemfile
|
|
110
137
|
- Gemfile.lock
|
|
111
138
|
- LICENSE.md
|
|
112
|
-
- README.
|
|
139
|
+
- README.md
|
|
113
140
|
- Rakefile
|
|
114
|
-
- USPS-intelligent-barcode.gemspec
|
|
115
141
|
- VERSION
|
|
142
|
+
- doc/font_installation.md
|
|
143
|
+
- doc/migration.md
|
|
144
|
+
- doc/publishing.md
|
|
116
145
|
- examples/example.rb
|
|
146
|
+
- examples/generate_pdf.rb
|
|
147
|
+
- fonts/LICENSE
|
|
148
|
+
- fonts/USPSIMBCompact.ttf
|
|
149
|
+
- fonts/USPSIMBStandard.ttf
|
|
117
150
|
- lib/usps_intelligent_barcode.rb
|
|
118
151
|
- lib/usps_intelligent_barcode/bar_map.rb
|
|
119
152
|
- lib/usps_intelligent_barcode/bar_position.rb
|
|
@@ -127,33 +160,23 @@ files:
|
|
|
127
160
|
- lib/usps_intelligent_barcode/crc.rb
|
|
128
161
|
- lib/usps_intelligent_barcode/mailer_id.rb
|
|
129
162
|
- lib/usps_intelligent_barcode/numeric_conversions.rb
|
|
163
|
+
- lib/usps_intelligent_barcode/project_dirs.rb
|
|
130
164
|
- lib/usps_intelligent_barcode/routing_code.rb
|
|
131
165
|
- lib/usps_intelligent_barcode/serial_number.rb
|
|
132
166
|
- lib/usps_intelligent_barcode/service_type.rb
|
|
167
|
+
- lib/usps_intelligent_barcode/usps_fonts.rb
|
|
168
|
+
- rake/bundler.rb
|
|
133
169
|
- rake/default.rb
|
|
134
|
-
- rake/jeweler.rb
|
|
135
170
|
- rake/rspec.rb
|
|
171
|
+
- rake/version.rb
|
|
136
172
|
- rake/yard.rb
|
|
137
|
-
- spec/bar_map_spec.rb
|
|
138
|
-
- spec/bar_position_spec.rb
|
|
139
|
-
- spec/bar_symbol_spec.rb
|
|
140
|
-
- spec/barcode_id_spec.rb
|
|
141
|
-
- spec/barcode_spec.rb
|
|
142
|
-
- spec/character_position_spec.rb
|
|
143
|
-
- spec/codeword_map_spec.rb
|
|
144
|
-
- spec/crc_spec.rb
|
|
145
|
-
- spec/mailer_id_spec.rb
|
|
146
|
-
- spec/numeric_conversions_spec.rb
|
|
147
|
-
- spec/routing_code_spec.rb
|
|
148
|
-
- spec/serial_number_spec.rb
|
|
149
|
-
- spec/service_type_spec.rb
|
|
150
|
-
- spec/spec_helper.rb
|
|
151
173
|
- usps_intelligent_barcode.gemspec
|
|
152
|
-
homepage:
|
|
174
|
+
homepage: https://github.com/wconrad/usps_intelligent_barcode
|
|
153
175
|
licenses:
|
|
154
176
|
- MIT
|
|
155
|
-
metadata:
|
|
156
|
-
|
|
177
|
+
metadata:
|
|
178
|
+
source_code_uri: https://github.com/wconrad/usps_intelligent_barcode
|
|
179
|
+
bug_tracker_uri: https://github.com/wconrad/usps_intelligent_barcode/issues
|
|
157
180
|
rdoc_options: []
|
|
158
181
|
require_paths:
|
|
159
182
|
- lib
|
|
@@ -161,16 +184,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
161
184
|
requirements:
|
|
162
185
|
- - ">="
|
|
163
186
|
- !ruby/object:Gem::Version
|
|
164
|
-
version:
|
|
187
|
+
version: 3.2.0
|
|
165
188
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
189
|
requirements:
|
|
167
190
|
- - ">="
|
|
168
191
|
- !ruby/object:Gem::Version
|
|
169
192
|
version: '0'
|
|
170
193
|
requirements: []
|
|
171
|
-
|
|
172
|
-
rubygems_version: 2.5.1
|
|
173
|
-
signing_key:
|
|
194
|
+
rubygems_version: 4.0.3
|
|
174
195
|
specification_version: 4
|
|
175
196
|
summary: Generates a USPS Intelligent Mail Barcode.
|
|
176
197
|
test_files: []
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
# Generated by jeweler
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
-
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: USPS-intelligent-barcode 0.2.7 ruby lib
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |s|
|
|
8
|
-
s.name = "USPS-intelligent-barcode"
|
|
9
|
-
s.version = "0.2.7"
|
|
10
|
-
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
|
-
s.require_paths = ["lib"]
|
|
13
|
-
s.authors = ["Wayne Conrad"]
|
|
14
|
-
s.date = "2015-06-13"
|
|
15
|
-
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. NOTE: Deprecated. Please use usps_intelligent_barcode instead.\n"
|
|
16
|
-
s.email = "wconrad@yagni.com"
|
|
17
|
-
s.extra_rdoc_files = [
|
|
18
|
-
"LICENSE.md"
|
|
19
|
-
]
|
|
20
|
-
s.files = [
|
|
21
|
-
"Gemfile",
|
|
22
|
-
"Gemfile.lock",
|
|
23
|
-
"LICENSE.md",
|
|
24
|
-
"Rakefile",
|
|
25
|
-
"USPS-intelligent-barcode.gemspec",
|
|
26
|
-
"VERSION",
|
|
27
|
-
"examples/example.rb",
|
|
28
|
-
"lib/USPS-intelligent-barcode.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",
|
|
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",
|
|
37
|
-
"lib/USPS-intelligent-barcode/codeword_to_character_mapping.yml",
|
|
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",
|
|
57
|
-
"spec/spec_helper.rb"
|
|
58
|
-
]
|
|
59
|
-
s.homepage = "http://github.com/wconrad/USPS-intelligent-barcode"
|
|
60
|
-
s.licenses = ["MIT"]
|
|
61
|
-
s.post_install_message = " The USPS-intelligent-barcode gem has been deprecated and has been\n replaced by usps-intelligent-barcode.\n See: https://rubygems.org/gems/usps_intelligent_barcode\n And: https://github.com/wconrad/usps_intellgent_barcode\n"
|
|
62
|
-
s.rubygems_version = "2.4.3"
|
|
63
|
-
s.summary = "Generates a USPS Intelligent Mail Barcode."
|
|
64
|
-
|
|
65
|
-
if s.respond_to? :specification_version then
|
|
66
|
-
s.specification_version = 4
|
|
67
|
-
|
|
68
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
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>, [">= 0"])
|
|
72
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
|
73
|
-
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
|
74
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
|
75
|
-
s.add_development_dependency(%q<rake>, [">= 0"])
|
|
76
|
-
else
|
|
77
|
-
s.add_dependency(%q<andand>, ["~> 1.3.3"])
|
|
78
|
-
s.add_dependency(%q<memoizer>, ["~> 1.0.1"])
|
|
79
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
80
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
|
81
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
|
82
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
|
83
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
|
84
|
-
end
|
|
85
|
-
else
|
|
86
|
-
s.add_dependency(%q<andand>, ["~> 1.3.3"])
|
|
87
|
-
s.add_dependency(%q<memoizer>, ["~> 1.0.1"])
|
|
88
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
89
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
|
90
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
|
91
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
|
92
|
-
s.add_dependency(%q<rake>, [">= 0"])
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
data/rake/jeweler.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
if Gem::Specification::find_all_by_name("jeweler").any?
|
|
2
|
-
|
|
3
|
-
require 'jeweler'
|
|
4
|
-
|
|
5
|
-
Jeweler::Tasks.new do |gem|
|
|
6
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
7
|
-
gem.name = "usps_intelligent_barcode"
|
|
8
|
-
gem.homepage = "http://github.com/wconrad/usps_intelligent_barcode"
|
|
9
|
-
gem.license = "MIT"
|
|
10
|
-
gem.summary = %Q{Generates a USPS Intelligent Mail Barcode.}
|
|
11
|
-
gem.description =
|
|
12
|
-
("A pure Ruby library to generate a USPS Intelligent "\
|
|
13
|
-
"Mail barcode. It generates the string of characters "\
|
|
14
|
-
"to print with one of the USPS Intelligent Mail barcode "\
|
|
15
|
-
"fonts.")
|
|
16
|
-
gem.email = "wconrad@yagni.com"
|
|
17
|
-
gem.authors = ["Wayne Conrad"]
|
|
18
|
-
# dependencies defined in Gemfile
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
Jeweler::RubygemsDotOrgTasks.new
|
|
22
|
-
|
|
23
|
-
end
|
data/spec/bar_map_spec.rb
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
|
2
|
-
|
|
3
|
-
module Imb
|
|
4
|
-
|
|
5
|
-
describe BarMap do
|
|
6
|
-
|
|
7
|
-
let(:characters) do
|
|
8
|
-
[
|
|
9
|
-
0x1FE0, 0x001F, 0x001F, 0x001F, 0x0ADB,
|
|
10
|
-
0x01A3, 0x1BC3, 0x1838, 0x012B, 0x0076,
|
|
11
|
-
]
|
|
12
|
-
end
|
|
13
|
-
let(:codes) do
|
|
14
|
-
[
|
|
15
|
-
2, 0, 0, 3, 2, 0, 0, 1, 0, 0, 2, 1, 0,
|
|
16
|
-
2, 2, 0, 0, 1, 0, 1, 0, 2, 0, 0, 1, 2,
|
|
17
|
-
3, 1, 1, 3, 2, 1, 3, 1, 3, 0, 3, 3, 3,
|
|
18
|
-
3, 3, 0, 2, 0, 3, 2, 2, 2, 2, 0, 1, 3,
|
|
19
|
-
3, 0, 1, 2, 2, 1, 3, 0, 3, 1, 0, 1, 0,
|
|
20
|
-
]
|
|
21
|
-
end
|
|
22
|
-
let(:bar_map) {BarMap.new}
|
|
23
|
-
|
|
24
|
-
specify do
|
|
25
|
-
expect(bar_map.symbols(characters).map(&:code)).to eq(codes)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
end
|
data/spec/bar_position_spec.rb
DELETED
|
@@ -1,40 +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(:ascender_bit) {double 'ascender bit'}
|
|
10
|
-
let(:descender_bit) {double 'descender bit'}
|
|
11
|
-
let(:characters) {double 'array of characters'}
|
|
12
|
-
let(:descender_character_position) {double CharacterPosition}
|
|
13
|
-
let(:ascender_character_position) {double CharacterPosition}
|
|
14
|
-
let(:bar_position) do
|
|
15
|
-
BarPosition.new(descender_character_position,
|
|
16
|
-
ascender_character_position)
|
|
17
|
-
end
|
|
18
|
-
let(:bar_symbol) {double BarSymbol}
|
|
19
|
-
|
|
20
|
-
before(:each) do
|
|
21
|
-
allow(descender_character_position).to receive(:extract_bit_from_characters)\
|
|
22
|
-
.with(characters)\
|
|
23
|
-
.and_return(descender_bit)
|
|
24
|
-
allow(ascender_character_position).to receive(:extract_bit_from_characters)\
|
|
25
|
-
.with(characters)\
|
|
26
|
-
.and_return(ascender_bit)
|
|
27
|
-
allow(BarSymbol).to receive(:make)\
|
|
28
|
-
.with(ascender_bit, descender_bit)\
|
|
29
|
-
.and_return(bar_symbol)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
specify do
|
|
33
|
-
expect(bar_position.map(characters)).to eq(bar_symbol)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
end
|
data/spec/bar_symbol_spec.rb
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
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
|
data/spec/barcode_id_spec.rb
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
|
2
|
-
|
|
3
|
-
module Imb
|
|
4
|
-
|
|
5
|
-
describe BarcodeId do
|
|
6
|
-
|
|
7
|
-
describe '::coerce' do
|
|
8
|
-
|
|
9
|
-
subject {BarcodeId.coerce(o)}
|
|
10
|
-
|
|
11
|
-
context 'BarcodeId' do
|
|
12
|
-
let(:o) {BarcodeId.new(12)}
|
|
13
|
-
its(:to_i) {should == 12}
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
context 'String' do
|
|
17
|
-
let(:o) {'12'}
|
|
18
|
-
its(:to_i) {should == 12}
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
context 'Integer' do
|
|
22
|
-
let(:o) {12}
|
|
23
|
-
its(:to_i) {should == 12}
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context 'unknown' do
|
|
27
|
-
let(:o) {Object.new}
|
|
28
|
-
specify do
|
|
29
|
-
expect {
|
|
30
|
-
BarcodeId.coerce(o)
|
|
31
|
-
}.to raise_error ArgumentError, 'Cannot coerce to BarcodeId'
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe '#to_i' do
|
|
38
|
-
let(:value) {23}
|
|
39
|
-
subject {BarcodeId.new(value)}
|
|
40
|
-
its(:to_i) {should == value}
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
describe '#=' do
|
|
44
|
-
def o1 ; BarcodeId.new(1) ; end
|
|
45
|
-
def o2 ; 1 ; end
|
|
46
|
-
def o3 ; BarcodeId.new(2) ; end
|
|
47
|
-
def o4 ; Object.new ; end
|
|
48
|
-
specify {expect(o1).to eq(o1)}
|
|
49
|
-
specify {expect(o1).to eq(o2)}
|
|
50
|
-
specify {expect(o1).not_to eq(o3)}
|
|
51
|
-
specify {expect(o1).not_to eq(o4)}
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
describe '#validate' do
|
|
55
|
-
|
|
56
|
-
let(:long_mailer_id?) {double 'long_mailer_id?'}
|
|
57
|
-
|
|
58
|
-
def validate(value)
|
|
59
|
-
BarcodeId.new(value).validate(long_mailer_id?)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def self.is_valid(value)
|
|
63
|
-
context "#{value}" do
|
|
64
|
-
specify {validate(value)}
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def self.is_out_of_range(value)
|
|
69
|
-
context "#{value}" do
|
|
70
|
-
specify do
|
|
71
|
-
expect {
|
|
72
|
-
validate(value)
|
|
73
|
-
}.to raise_error ArgumentError, 'Must be 0..94'
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def self.has_bad_least_significant_digit(value)
|
|
79
|
-
context "#{value}" do
|
|
80
|
-
specify do
|
|
81
|
-
expect {
|
|
82
|
-
validate(value)
|
|
83
|
-
}.to raise_error(ArgumentError,
|
|
84
|
-
'Least significant digit must be 0..4')
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
is_out_of_range -1
|
|
90
|
-
is_valid 0
|
|
91
|
-
is_valid 4
|
|
92
|
-
has_bad_least_significant_digit 5
|
|
93
|
-
is_valid 94
|
|
94
|
-
is_out_of_range 95
|
|
95
|
-
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
describe '#shift_and_add_to' do
|
|
99
|
-
let(:barcode_id) {BarcodeId.new(12)}
|
|
100
|
-
let(:long_mailer_id?) {double 'long mailer id'}
|
|
101
|
-
specify {expect(barcode_id.shift_and_add_to(1, long_mailer_id?)).to eq(57)}
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
end
|