usps_intelligent_barcode 0.3.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 (58) hide show
  1. checksums.yaml +7 -0
  2. data/.travis.yml +8 -0
  3. data/CHANGELOG.markdown +67 -0
  4. data/Gemfile +13 -0
  5. data/Gemfile.lock +90 -0
  6. data/LICENSE.md +11 -0
  7. data/README.markdown +64 -0
  8. data/Rakefile +40 -0
  9. data/VERSION +1 -0
  10. data/examples/example.rb +17 -0
  11. data/lib/USPS-intelligent-barcode.rb +17 -0
  12. data/lib/USPS-intelligent-barcode/bar_map.rb +52 -0
  13. data/lib/USPS-intelligent-barcode/bar_position.rb +40 -0
  14. data/lib/USPS-intelligent-barcode/bar_symbol.rb +49 -0
  15. data/lib/USPS-intelligent-barcode/bar_to_character_mapping.yml +66 -0
  16. data/lib/USPS-intelligent-barcode/barcode.rb +152 -0
  17. data/lib/USPS-intelligent-barcode/barcode_id.rb +98 -0
  18. data/lib/USPS-intelligent-barcode/character_position.rb +28 -0
  19. data/lib/USPS-intelligent-barcode/codeword_map.rb +38 -0
  20. data/lib/USPS-intelligent-barcode/codeword_to_character_mapping.yml +1366 -0
  21. data/lib/USPS-intelligent-barcode/crc.rb +52 -0
  22. data/lib/USPS-intelligent-barcode/mailer_id.rb +105 -0
  23. data/lib/USPS-intelligent-barcode/numeric_conversions.rb +22 -0
  24. data/lib/USPS-intelligent-barcode/routing_code.rb +134 -0
  25. data/lib/USPS-intelligent-barcode/serial_number.rb +88 -0
  26. data/lib/USPS-intelligent-barcode/service_type.rb +79 -0
  27. data/lib/usps_intelligent_barcode.rb +17 -0
  28. data/lib/usps_intelligent_barcode/bar_map.rb +52 -0
  29. data/lib/usps_intelligent_barcode/bar_position.rb +40 -0
  30. data/lib/usps_intelligent_barcode/bar_symbol.rb +49 -0
  31. data/lib/usps_intelligent_barcode/bar_to_character_mapping.yml +66 -0
  32. data/lib/usps_intelligent_barcode/barcode.rb +152 -0
  33. data/lib/usps_intelligent_barcode/barcode_id.rb +98 -0
  34. data/lib/usps_intelligent_barcode/character_position.rb +28 -0
  35. data/lib/usps_intelligent_barcode/codeword_map.rb +38 -0
  36. data/lib/usps_intelligent_barcode/codeword_to_character_mapping.yml +1366 -0
  37. data/lib/usps_intelligent_barcode/crc.rb +52 -0
  38. data/lib/usps_intelligent_barcode/mailer_id.rb +105 -0
  39. data/lib/usps_intelligent_barcode/numeric_conversions.rb +22 -0
  40. data/lib/usps_intelligent_barcode/routing_code.rb +134 -0
  41. data/lib/usps_intelligent_barcode/serial_number.rb +88 -0
  42. data/lib/usps_intelligent_barcode/service_type.rb +79 -0
  43. data/spec/bar_map_spec.rb +30 -0
  44. data/spec/bar_position_spec.rb +40 -0
  45. data/spec/bar_symbol_spec.rb +39 -0
  46. data/spec/barcode_id_spec.rb +106 -0
  47. data/spec/barcode_spec.rb +213 -0
  48. data/spec/character_position_spec.rb +25 -0
  49. data/spec/codeword_map_spec.rb +22 -0
  50. data/spec/crc_spec.rb +21 -0
  51. data/spec/mailer_id_spec.rb +124 -0
  52. data/spec/numeric_conversions_spec.rb +23 -0
  53. data/spec/routing_code_spec.rb +180 -0
  54. data/spec/serial_number_spec.rb +117 -0
  55. data/spec/service_type_spec.rb +93 -0
  56. data/spec/spec_helper.rb +8 -0
  57. data/usps_intelligent_barcode.gemspec +117 -0
  58. metadata +216 -0
@@ -0,0 +1,93 @@
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
@@ -0,0 +1,8 @@
1
+ if RUBY_VERSION >= '1.9'
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+ end
5
+
6
+ require "rspec/its"
7
+
8
+ require File.expand_path('../lib/USPS-intelligent-barcode', File.dirname(__FILE__))
@@ -0,0 +1,117 @@
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.3.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "usps_intelligent_barcode"
9
+ s.version = "0.3.0"
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."
16
+ s.email = "wconrad@yagni.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.md",
19
+ "README.markdown"
20
+ ]
21
+ s.files = [
22
+ ".travis.yml",
23
+ "CHANGELOG.markdown",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.md",
27
+ "README.markdown",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "examples/example.rb",
31
+ "lib/USPS-intelligent-barcode.rb",
32
+ "lib/USPS-intelligent-barcode/bar_map.rb",
33
+ "lib/USPS-intelligent-barcode/bar_position.rb",
34
+ "lib/USPS-intelligent-barcode/bar_symbol.rb",
35
+ "lib/USPS-intelligent-barcode/bar_to_character_mapping.yml",
36
+ "lib/USPS-intelligent-barcode/barcode.rb",
37
+ "lib/USPS-intelligent-barcode/barcode_id.rb",
38
+ "lib/USPS-intelligent-barcode/character_position.rb",
39
+ "lib/USPS-intelligent-barcode/codeword_map.rb",
40
+ "lib/USPS-intelligent-barcode/codeword_to_character_mapping.yml",
41
+ "lib/USPS-intelligent-barcode/crc.rb",
42
+ "lib/USPS-intelligent-barcode/mailer_id.rb",
43
+ "lib/USPS-intelligent-barcode/numeric_conversions.rb",
44
+ "lib/USPS-intelligent-barcode/routing_code.rb",
45
+ "lib/USPS-intelligent-barcode/serial_number.rb",
46
+ "lib/USPS-intelligent-barcode/service_type.rb",
47
+ "lib/usps_intelligent_barcode.rb",
48
+ "lib/usps_intelligent_barcode/bar_map.rb",
49
+ "lib/usps_intelligent_barcode/bar_position.rb",
50
+ "lib/usps_intelligent_barcode/bar_symbol.rb",
51
+ "lib/usps_intelligent_barcode/bar_to_character_mapping.yml",
52
+ "lib/usps_intelligent_barcode/barcode.rb",
53
+ "lib/usps_intelligent_barcode/barcode_id.rb",
54
+ "lib/usps_intelligent_barcode/character_position.rb",
55
+ "lib/usps_intelligent_barcode/codeword_map.rb",
56
+ "lib/usps_intelligent_barcode/codeword_to_character_mapping.yml",
57
+ "lib/usps_intelligent_barcode/crc.rb",
58
+ "lib/usps_intelligent_barcode/mailer_id.rb",
59
+ "lib/usps_intelligent_barcode/numeric_conversions.rb",
60
+ "lib/usps_intelligent_barcode/routing_code.rb",
61
+ "lib/usps_intelligent_barcode/serial_number.rb",
62
+ "lib/usps_intelligent_barcode/service_type.rb",
63
+ "spec/bar_map_spec.rb",
64
+ "spec/bar_position_spec.rb",
65
+ "spec/bar_symbol_spec.rb",
66
+ "spec/barcode_id_spec.rb",
67
+ "spec/barcode_spec.rb",
68
+ "spec/character_position_spec.rb",
69
+ "spec/codeword_map_spec.rb",
70
+ "spec/crc_spec.rb",
71
+ "spec/mailer_id_spec.rb",
72
+ "spec/numeric_conversions_spec.rb",
73
+ "spec/routing_code_spec.rb",
74
+ "spec/serial_number_spec.rb",
75
+ "spec/service_type_spec.rb",
76
+ "spec/spec_helper.rb",
77
+ "usps_intelligent_barcode.gemspec"
78
+ ]
79
+ s.homepage = "http://github.com/wconrad/usps_intelligent_barcode"
80
+ s.licenses = ["MIT"]
81
+ s.rubygems_version = "2.4.6"
82
+ s.summary = "Generates a USPS Intelligent Mail Barcode."
83
+
84
+ if s.respond_to? :specification_version then
85
+ s.specification_version = 4
86
+
87
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
88
+ s.add_runtime_dependency(%q<andand>, ["~> 1.3"])
89
+ s.add_runtime_dependency(%q<memoizer>, ["~> 1.0"])
90
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
91
+ s.add_development_dependency(%q<rspec>, ["~> 3.3"])
92
+ s.add_development_dependency(%q<rspec-its>, ["~> 1.0"])
93
+ s.add_development_dependency(%q<simplecov>, ["~> 0.10.0"])
94
+ s.add_development_dependency(%q<yard>, ["~> 0.8.5"])
95
+ s.add_development_dependency(%q<rake>, ["~> 10.0"])
96
+ else
97
+ s.add_dependency(%q<andand>, ["~> 1.3"])
98
+ s.add_dependency(%q<memoizer>, ["~> 1.0"])
99
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
100
+ s.add_dependency(%q<rspec>, ["~> 3.3"])
101
+ s.add_dependency(%q<rspec-its>, ["~> 1.0"])
102
+ s.add_dependency(%q<simplecov>, ["~> 0.10.0"])
103
+ s.add_dependency(%q<yard>, ["~> 0.8.5"])
104
+ s.add_dependency(%q<rake>, ["~> 10.0"])
105
+ end
106
+ else
107
+ s.add_dependency(%q<andand>, ["~> 1.3"])
108
+ s.add_dependency(%q<memoizer>, ["~> 1.0"])
109
+ s.add_dependency(%q<jeweler>, ["~> 2.0"])
110
+ s.add_dependency(%q<rspec>, ["~> 3.3"])
111
+ s.add_dependency(%q<rspec-its>, ["~> 1.0"])
112
+ s.add_dependency(%q<simplecov>, ["~> 0.10.0"])
113
+ s.add_dependency(%q<yard>, ["~> 0.8.5"])
114
+ s.add_dependency(%q<rake>, ["~> 10.0"])
115
+ end
116
+ end
117
+
metadata ADDED
@@ -0,0 +1,216 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: usps_intelligent_barcode
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Wayne Conrad
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: andand
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: memoizer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jeweler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-its
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.10.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.10.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: yard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.8.5
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.8.5
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '10.0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '10.0'
125
+ description: A pure Ruby library to generate a USPS Intelligent Mail barcode. It
126
+ generates the string of characters to print with one of the USPS Intelligent Mail
127
+ barcode fonts.
128
+ email: wconrad@yagni.com
129
+ executables: []
130
+ extensions: []
131
+ extra_rdoc_files:
132
+ - LICENSE.md
133
+ - README.markdown
134
+ files:
135
+ - ".travis.yml"
136
+ - CHANGELOG.markdown
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - LICENSE.md
140
+ - README.markdown
141
+ - Rakefile
142
+ - VERSION
143
+ - examples/example.rb
144
+ - lib/USPS-intelligent-barcode.rb
145
+ - lib/USPS-intelligent-barcode/bar_map.rb
146
+ - lib/USPS-intelligent-barcode/bar_position.rb
147
+ - lib/USPS-intelligent-barcode/bar_symbol.rb
148
+ - lib/USPS-intelligent-barcode/bar_to_character_mapping.yml
149
+ - lib/USPS-intelligent-barcode/barcode.rb
150
+ - lib/USPS-intelligent-barcode/barcode_id.rb
151
+ - lib/USPS-intelligent-barcode/character_position.rb
152
+ - lib/USPS-intelligent-barcode/codeword_map.rb
153
+ - lib/USPS-intelligent-barcode/codeword_to_character_mapping.yml
154
+ - lib/USPS-intelligent-barcode/crc.rb
155
+ - lib/USPS-intelligent-barcode/mailer_id.rb
156
+ - lib/USPS-intelligent-barcode/numeric_conversions.rb
157
+ - lib/USPS-intelligent-barcode/routing_code.rb
158
+ - lib/USPS-intelligent-barcode/serial_number.rb
159
+ - lib/USPS-intelligent-barcode/service_type.rb
160
+ - lib/usps_intelligent_barcode.rb
161
+ - lib/usps_intelligent_barcode/bar_map.rb
162
+ - lib/usps_intelligent_barcode/bar_position.rb
163
+ - lib/usps_intelligent_barcode/bar_symbol.rb
164
+ - lib/usps_intelligent_barcode/bar_to_character_mapping.yml
165
+ - lib/usps_intelligent_barcode/barcode.rb
166
+ - lib/usps_intelligent_barcode/barcode_id.rb
167
+ - lib/usps_intelligent_barcode/character_position.rb
168
+ - lib/usps_intelligent_barcode/codeword_map.rb
169
+ - lib/usps_intelligent_barcode/codeword_to_character_mapping.yml
170
+ - lib/usps_intelligent_barcode/crc.rb
171
+ - lib/usps_intelligent_barcode/mailer_id.rb
172
+ - lib/usps_intelligent_barcode/numeric_conversions.rb
173
+ - lib/usps_intelligent_barcode/routing_code.rb
174
+ - lib/usps_intelligent_barcode/serial_number.rb
175
+ - lib/usps_intelligent_barcode/service_type.rb
176
+ - spec/bar_map_spec.rb
177
+ - spec/bar_position_spec.rb
178
+ - spec/bar_symbol_spec.rb
179
+ - spec/barcode_id_spec.rb
180
+ - spec/barcode_spec.rb
181
+ - spec/character_position_spec.rb
182
+ - spec/codeword_map_spec.rb
183
+ - spec/crc_spec.rb
184
+ - spec/mailer_id_spec.rb
185
+ - spec/numeric_conversions_spec.rb
186
+ - spec/routing_code_spec.rb
187
+ - spec/serial_number_spec.rb
188
+ - spec/service_type_spec.rb
189
+ - spec/spec_helper.rb
190
+ - usps_intelligent_barcode.gemspec
191
+ homepage: http://github.com/wconrad/usps_intelligent_barcode
192
+ licenses:
193
+ - MIT
194
+ metadata: {}
195
+ post_install_message:
196
+ rdoc_options: []
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ requirements: []
210
+ rubyforge_project:
211
+ rubygems_version: 2.4.6
212
+ signing_key:
213
+ specification_version: 4
214
+ summary: Generates a USPS Intelligent Mail Barcode.
215
+ test_files: []
216
+ has_rdoc: