USPS-intelligent-barcode 0.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 (37) hide show
  1. data/Gemfile +9 -0
  2. data/Gemfile.lock +33 -0
  3. data/LICENSE.md +11 -0
  4. data/README.md +56 -0
  5. data/Rakefile +46 -0
  6. data/VERSION +1 -0
  7. data/examples/example.rb +17 -0
  8. data/lib/USPS-intelligent-barcode.rb +5 -0
  9. data/lib/USPS-intelligent-barcode/BarMap.rb +40 -0
  10. data/lib/USPS-intelligent-barcode/BarPosition.rb +26 -0
  11. data/lib/USPS-intelligent-barcode/Barcode.rb +110 -0
  12. data/lib/USPS-intelligent-barcode/BarcodeId.rb +66 -0
  13. data/lib/USPS-intelligent-barcode/CharacterPosition.rb +16 -0
  14. data/lib/USPS-intelligent-barcode/CodewordMap.rb +28 -0
  15. data/lib/USPS-intelligent-barcode/Crc.rb +42 -0
  16. data/lib/USPS-intelligent-barcode/MailerId.rb +70 -0
  17. data/lib/USPS-intelligent-barcode/NumericConversions.rb +13 -0
  18. data/lib/USPS-intelligent-barcode/RoutingCode.rb +77 -0
  19. data/lib/USPS-intelligent-barcode/SerialNumber.rb +61 -0
  20. data/lib/USPS-intelligent-barcode/ServiceType.rb +51 -0
  21. data/lib/USPS-intelligent-barcode/autoload.rb +61 -0
  22. data/lib/USPS-intelligent-barcode/bar_to_character_mapping.yml +66 -0
  23. data/lib/USPS-intelligent-barcode/codeword_to_character_mapping.yml +1366 -0
  24. data/spec/BarMap_spec.rb +30 -0
  25. data/spec/BarPosition_spec.rb +52 -0
  26. data/spec/BarcodeId_spec.rb +118 -0
  27. data/spec/Barcode_spec.rb +213 -0
  28. data/spec/CharacterPosition_spec.rb +25 -0
  29. data/spec/CodewordMap_spec.rb +22 -0
  30. data/spec/Crc_spec.rb +21 -0
  31. data/spec/MailerId_spec.rb +114 -0
  32. data/spec/NumericConversions_spec.rb +23 -0
  33. data/spec/RoutingCode_spec.rb +180 -0
  34. data/spec/SerialNumber_spec.rb +117 -0
  35. data/spec/ServiceType_spec.rb +93 -0
  36. data/spec/spec_helper.rb +1 -0
  37. metadata +160 -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 {o1.should == o1}
49
+ specify {o1.should == o2}
50
+ specify {o1.should_not == o3}
51
+ specify {o1.should_not == o4}
52
+ end
53
+
54
+ describe '#validate' do
55
+
56
+ let(:long_mailer_id?) {mock '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?) {mock 'long mailer id'}
88
+ specify {service_type.shift_and_add_to(1, long_mailer_id?).should == 1999}
89
+ end
90
+
91
+ end
92
+
93
+ end
@@ -0,0 +1 @@
1
+ require File.expand_path('../lib/USPS-intelligent-barcode', File.dirname(__FILE__))
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: USPS-intelligent-barcode
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Wayne Conrad
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-12-27 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: andand
22
+ prerelease: false
23
+ type: :runtime
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 9
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
38
+ type: :runtime
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 15
45
+ segments:
46
+ - 1
47
+ - 0
48
+ version: "1.0"
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: rspec
52
+ prerelease: false
53
+ type: :development
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 27
60
+ segments:
61
+ - 2
62
+ - 12
63
+ version: "2.12"
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: jeweler
67
+ prerelease: false
68
+ type: :development
69
+ requirement: &id004 !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ~>
73
+ - !ruby/object:Gem::Version
74
+ hash: 31
75
+ segments:
76
+ - 1
77
+ - 8
78
+ version: "1.8"
79
+ version_requirements: *id004
80
+ description: A pure Ruby gem to generate a USPS Intelligent Mail barcode. It generates the string of characters to print with one of the USPS Intelligent Mail barcode fonts.
81
+ email: wayne@databill.com
82
+ executables: []
83
+
84
+ extensions: []
85
+
86
+ extra_rdoc_files:
87
+ - LICENSE.md
88
+ - README.md
89
+ files:
90
+ - Gemfile
91
+ - Gemfile.lock
92
+ - LICENSE.md
93
+ - README.md
94
+ - Rakefile
95
+ - VERSION
96
+ - examples/example.rb
97
+ - lib/USPS-intelligent-barcode.rb
98
+ - lib/USPS-intelligent-barcode/BarMap.rb
99
+ - lib/USPS-intelligent-barcode/BarPosition.rb
100
+ - lib/USPS-intelligent-barcode/Barcode.rb
101
+ - lib/USPS-intelligent-barcode/BarcodeId.rb
102
+ - lib/USPS-intelligent-barcode/CharacterPosition.rb
103
+ - lib/USPS-intelligent-barcode/CodewordMap.rb
104
+ - lib/USPS-intelligent-barcode/Crc.rb
105
+ - lib/USPS-intelligent-barcode/MailerId.rb
106
+ - lib/USPS-intelligent-barcode/NumericConversions.rb
107
+ - lib/USPS-intelligent-barcode/RoutingCode.rb
108
+ - lib/USPS-intelligent-barcode/SerialNumber.rb
109
+ - lib/USPS-intelligent-barcode/ServiceType.rb
110
+ - lib/USPS-intelligent-barcode/autoload.rb
111
+ - lib/USPS-intelligent-barcode/bar_to_character_mapping.yml
112
+ - lib/USPS-intelligent-barcode/codeword_to_character_mapping.yml
113
+ - spec/BarMap_spec.rb
114
+ - spec/BarPosition_spec.rb
115
+ - spec/BarcodeId_spec.rb
116
+ - spec/Barcode_spec.rb
117
+ - spec/CharacterPosition_spec.rb
118
+ - spec/CodewordMap_spec.rb
119
+ - spec/Crc_spec.rb
120
+ - spec/MailerId_spec.rb
121
+ - spec/NumericConversions_spec.rb
122
+ - spec/RoutingCode_spec.rb
123
+ - spec/SerialNumber_spec.rb
124
+ - spec/ServiceType_spec.rb
125
+ - spec/spec_helper.rb
126
+ homepage: http://github.com/wconrad/USPS-intelligent-barcode
127
+ licenses:
128
+ - MIT
129
+ post_install_message:
130
+ rdoc_options: []
131
+
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ hash: 3
140
+ segments:
141
+ - 0
142
+ version: "0"
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ none: false
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ hash: 3
149
+ segments:
150
+ - 0
151
+ version: "0"
152
+ requirements: []
153
+
154
+ rubyforge_project:
155
+ rubygems_version: 1.8.17
156
+ signing_key:
157
+ specification_version: 3
158
+ summary: Generates a USPS Intelligent Mail Barcode.
159
+ test_files: []
160
+