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.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +6 -0
  3. data/.ruby-version +1 -0
  4. data/{CHANGELOG.markdown → CHANGELOG.md} +27 -12
  5. data/Gemfile +2 -16
  6. data/Gemfile.lock +74 -85
  7. data/LICENSE.md +7 -0
  8. data/{README.markdown → README.md} +56 -36
  9. data/VERSION +1 -1
  10. data/doc/font_installation.md +55 -0
  11. data/doc/migration.md +47 -0
  12. data/doc/publishing.md +75 -0
  13. data/examples/example.rb +4 -4
  14. data/examples/generate_pdf.rb +70 -0
  15. data/fonts/LICENSE +47 -0
  16. data/fonts/USPSIMBCompact.ttf +0 -0
  17. data/fonts/USPSIMBStandard.ttf +0 -0
  18. data/lib/usps_intelligent_barcode/barcode.rb +33 -30
  19. data/lib/usps_intelligent_barcode/barcode_id.rb +5 -0
  20. data/lib/usps_intelligent_barcode/mailer_id.rb +6 -1
  21. data/lib/usps_intelligent_barcode/project_dirs.rb +19 -0
  22. data/lib/usps_intelligent_barcode/routing_code.rb +20 -10
  23. data/lib/usps_intelligent_barcode/serial_number.rb +6 -1
  24. data/lib/usps_intelligent_barcode/service_type.rb +6 -1
  25. data/lib/usps_intelligent_barcode/usps_fonts.rb +48 -0
  26. data/lib/usps_intelligent_barcode.rb +2 -0
  27. data/rake/bundler.rb +1 -0
  28. data/rake/version.rb +33 -0
  29. data/rake/yard.rb +1 -0
  30. data/usps_intelligent_barcode.gemspec +24 -97
  31. metadata +67 -46
  32. data/USPS-intelligent-barcode.gemspec +0 -95
  33. data/rake/jeweler.rb +0 -23
  34. data/spec/bar_map_spec.rb +0 -30
  35. data/spec/bar_position_spec.rb +0 -40
  36. data/spec/bar_symbol_spec.rb +0 -39
  37. data/spec/barcode_id_spec.rb +0 -106
  38. data/spec/barcode_spec.rb +0 -213
  39. data/spec/character_position_spec.rb +0 -25
  40. data/spec/codeword_map_spec.rb +0 -22
  41. data/spec/crc_spec.rb +0 -21
  42. data/spec/mailer_id_spec.rb +0 -124
  43. data/spec/numeric_conversions_spec.rb +0 -23
  44. data/spec/routing_code_spec.rb +0 -180
  45. data/spec/serial_number_spec.rb +0 -117
  46. data/spec/service_type_spec.rb +0 -93
  47. data/spec/spec_helper.rb +0 -9
@@ -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
@@ -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
data/spec/spec_helper.rb DELETED
@@ -1,9 +0,0 @@
1
- begin
2
- require 'simplecov'
3
- SimpleCov.start
4
- rescue LoadError
5
- end
6
-
7
- require "rspec/its"
8
-
9
- require File.expand_path('../lib/usps_intelligent_barcode', File.dirname(__FILE__))