usps_intelligent_barcode 0.3.1 → 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 -13
- data/.gitignore +6 -0
- data/.ruby-version +1 -0
- data/.travis.yml +2 -1
- data/{CHANGELOG.markdown → CHANGELOG.md} +27 -12
- data/Gemfile +2 -12
- data/Gemfile.lock +74 -81
- data/LICENSE.md +7 -0
- data/README.md +92 -0
- data/Rakefile +4 -28
- 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/bar_map.rb +10 -8
- data/lib/usps_intelligent_barcode/bar_position.rb +14 -10
- data/lib/usps_intelligent_barcode/bar_symbol.rb +42 -12
- data/lib/usps_intelligent_barcode/bar_to_character_mapping.yml +24 -0
- data/lib/usps_intelligent_barcode/barcode.rb +83 -39
- data/lib/usps_intelligent_barcode/barcode_id.rb +19 -12
- data/lib/usps_intelligent_barcode/character_position.rb +10 -8
- data/lib/usps_intelligent_barcode/codeword_map.rb +0 -1
- data/lib/usps_intelligent_barcode/codeword_to_character_mapping.yml +7 -0
- data/lib/usps_intelligent_barcode/crc.rb +3 -3
- data/lib/usps_intelligent_barcode/mailer_id.rb +18 -14
- data/lib/usps_intelligent_barcode/numeric_conversions.rb +7 -6
- data/lib/usps_intelligent_barcode/project_dirs.rb +19 -0
- data/lib/usps_intelligent_barcode/routing_code.rb +38 -27
- data/lib/usps_intelligent_barcode/serial_number.rb +16 -11
- data/lib/usps_intelligent_barcode/service_type.rb +14 -12
- 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/default.rb +1 -0
- data/rake/rspec.rb +2 -0
- data/rake/version.rb +33 -0
- data/rake/yard.rb +9 -0
- data/usps_intelligent_barcode.gemspec +24 -99
- metadata +68 -71
- data/README.markdown +0 -69
- data/USPS-intelligent-barcode.gemspec +0 -95
- 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 -8
data/spec/serial_number_spec.rb
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
|
2
|
-
|
|
3
|
-
module Imb
|
|
4
|
-
|
|
5
|
-
describe SerialNumber do
|
|
6
|
-
|
|
7
|
-
describe '::coerce' do
|
|
8
|
-
|
|
9
|
-
subject {SerialNumber.coerce(o)}
|
|
10
|
-
|
|
11
|
-
context 'SerialNumber' do
|
|
12
|
-
let(:o) {SerialNumber.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
|
-
SerialNumber.coerce(o)
|
|
31
|
-
}.to raise_error ArgumentError, 'Cannot coerce to SerialNumber'
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe '#to_i' do
|
|
38
|
-
let(:value) {23}
|
|
39
|
-
subject {SerialNumber.new(value)}
|
|
40
|
-
its(:to_i) {should == value}
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
describe '#=' do
|
|
44
|
-
def o1 ; SerialNumber.new(1) ; end
|
|
45
|
-
def o2 ; 1 ; end
|
|
46
|
-
def o3 ; SerialNumber.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
|
-
def self.is_valid(value)
|
|
57
|
-
context "#{value}" do
|
|
58
|
-
let(:serial_number) {SerialNumber.new(value)}
|
|
59
|
-
specify {serial_number.validate(long_mailer_id?)}
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
def self.is_out_of_range(value)
|
|
64
|
-
context "#{value}" do
|
|
65
|
-
let(:serial_number) {SerialNumber.new(value)}
|
|
66
|
-
specify do
|
|
67
|
-
expect {
|
|
68
|
-
serial_number.validate(long_mailer_id?)
|
|
69
|
-
}.to raise_error ArgumentError, message
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
context 'when long mailer id' do
|
|
75
|
-
let(:long_mailer_id?) {true}
|
|
76
|
-
let(:message) {'Must be 0..999999'}
|
|
77
|
-
is_out_of_range -1
|
|
78
|
-
is_valid 0
|
|
79
|
-
is_valid 999_999
|
|
80
|
-
is_out_of_range 1_000_000
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
context 'when short mailer id' do
|
|
84
|
-
let(:long_mailer_id?) {false}
|
|
85
|
-
let(:message) {'Must be 0..999999999'}
|
|
86
|
-
is_out_of_range -1
|
|
87
|
-
is_valid 0
|
|
88
|
-
is_valid 999_999_999
|
|
89
|
-
is_out_of_range 1_000_000_000
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
describe '#shift_and_add_to' do
|
|
95
|
-
|
|
96
|
-
let(:serial_number) {SerialNumber.new(value)}
|
|
97
|
-
|
|
98
|
-
def shift_and_add_to
|
|
99
|
-
serial_number.shift_and_add_to(1, long_mailer_id?)
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
context 'long mailer id' do
|
|
103
|
-
let(:value) {999_999}
|
|
104
|
-
let(:long_mailer_id?) {true}
|
|
105
|
-
specify {expect(shift_and_add_to).to eq(1_999_999)}
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
context 'short mailer id' do
|
|
109
|
-
let(:value) {999_999_999}
|
|
110
|
-
let(:long_mailer_id?) {false}
|
|
111
|
-
specify {expect(shift_and_add_to).to eq(1_999_999_999)}
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
end
|
data/spec/service_type_spec.rb
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
require File.expand_path('spec_helper', File.dirname(__FILE__))
|
|
2
|
-
|
|
3
|
-
module Imb
|
|
4
|
-
|
|
5
|
-
describe ServiceType do
|
|
6
|
-
|
|
7
|
-
describe '::coerce' do
|
|
8
|
-
|
|
9
|
-
subject {ServiceType.coerce(o)}
|
|
10
|
-
|
|
11
|
-
context 'ServiceType' do
|
|
12
|
-
let(:o) {ServiceType.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
|
-
ServiceType.coerce(o)
|
|
31
|
-
}.to raise_error ArgumentError, 'Cannot coerce to ServiceType'
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe '#to_i' do
|
|
38
|
-
let(:value) {23}
|
|
39
|
-
subject {ServiceType.new(value)}
|
|
40
|
-
its(:to_i) {should == value}
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
describe '#=' do
|
|
44
|
-
def o1 ; ServiceType.new(1) ; end
|
|
45
|
-
def o2 ; 1 ; end
|
|
46
|
-
def o3 ; ServiceType.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
|
-
ServiceType.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..999'
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
is_out_of_range -1
|
|
79
|
-
is_valid 0
|
|
80
|
-
is_valid 999
|
|
81
|
-
is_out_of_range 1000
|
|
82
|
-
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
describe '#shift_and_add_to' do
|
|
86
|
-
let(:service_type) {ServiceType.new(999)}
|
|
87
|
-
let(:long_mailer_id?) {double 'long mailer id'}
|
|
88
|
-
specify {expect(service_type.shift_and_add_to(1, long_mailer_id?)).to eq(1999)}
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
end
|