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
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
module Imb
|
|
2
2
|
|
|
3
3
|
# This class represents a mailer ID.
|
|
4
|
-
|
|
5
4
|
class MailerId
|
|
6
5
|
|
|
7
6
|
# The allowable range for a short (6-digit) mailer ID
|
|
@@ -19,7 +18,6 @@ module Imb
|
|
|
19
18
|
# * Integer
|
|
20
19
|
# @return [MailerId]
|
|
21
20
|
# @raise [ArgumentError] If the argument cannot be coerced
|
|
22
|
-
|
|
23
21
|
def self.coerce(o)
|
|
24
22
|
case o
|
|
25
23
|
when MailerId
|
|
@@ -33,39 +31,44 @@ module Imb
|
|
|
33
31
|
end
|
|
34
32
|
end
|
|
35
33
|
|
|
36
|
-
#
|
|
37
|
-
|
|
34
|
+
# Construct an instance.
|
|
35
|
+
#
|
|
36
|
+
# @param value [Integer]
|
|
38
37
|
def initialize(value)
|
|
39
38
|
@value = value
|
|
40
39
|
end
|
|
41
40
|
|
|
42
41
|
# Return true if this object is equal to o
|
|
43
|
-
#
|
|
44
|
-
|
|
42
|
+
#
|
|
43
|
+
# @param o [Object] Any object acceptable to {.coerce}
|
|
45
44
|
def ==(o)
|
|
46
45
|
MailerId.coerce(o).to_i == to_i
|
|
47
46
|
rescue ArgumentError
|
|
48
47
|
false
|
|
49
48
|
end
|
|
50
49
|
|
|
51
|
-
# @return [Integer] The value of the mailer ID
|
|
52
|
-
|
|
50
|
+
# @return [Integer] The integer value of the mailer ID
|
|
53
51
|
def to_i
|
|
54
52
|
@value
|
|
55
53
|
end
|
|
56
54
|
|
|
55
|
+
# @return [String] The string value of the mailer ID
|
|
56
|
+
def to_s
|
|
57
|
+
@value.to_s
|
|
58
|
+
end
|
|
59
|
+
|
|
57
60
|
# @!group Internal
|
|
58
61
|
|
|
59
62
|
# Return true if this is a long (9 digit) mailer ID
|
|
60
|
-
|
|
61
63
|
def long?
|
|
62
64
|
LONG_RANGE === @value
|
|
63
65
|
end
|
|
64
66
|
|
|
65
67
|
# Validate the value.
|
|
66
|
-
#
|
|
68
|
+
#
|
|
69
|
+
# @param long_mailer_id [boolean] truthy if the mailer ID is long
|
|
70
|
+
# (9 digits).
|
|
67
71
|
# @raise ArgumentError if invalid
|
|
68
|
-
|
|
69
72
|
def validate(long_mailer_id)
|
|
70
73
|
unless in_range?
|
|
71
74
|
raise ArgumentError, "Must be #{RANGES.join(' or ')}"
|
|
@@ -74,10 +77,11 @@ module Imb
|
|
|
74
77
|
|
|
75
78
|
# Add this object's value to target, shifting it left as many
|
|
76
79
|
# digts as are needed to make room.
|
|
77
|
-
#
|
|
78
|
-
# @param
|
|
80
|
+
#
|
|
81
|
+
# @param target [Integer] The target to be shifted and added to
|
|
82
|
+
# @param long_mailer_id [boolean] truthy if the mailer ID is long
|
|
83
|
+
# (9 digits).
|
|
79
84
|
# @return [Integer] The new value of the target
|
|
80
|
-
|
|
81
85
|
def shift_and_add_to(target, long_mailer_id)
|
|
82
86
|
target * 10 ** num_digits + to_i
|
|
83
87
|
end
|
|
@@ -3,14 +3,15 @@ module Imb
|
|
|
3
3
|
# @!group Internal
|
|
4
4
|
|
|
5
5
|
# Numeric conversions
|
|
6
|
-
|
|
7
6
|
module NumericConversions
|
|
8
7
|
|
|
9
|
-
# Convert a numeric to an array of at least +min_bytes+ bytes.
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
|
|
8
|
+
# Convert a numeric to an array of at least +min_bytes+ bytes. If
|
|
9
|
+
# the resulting array is larger than is needed, then the most
|
|
10
|
+
# significant bytes are zero padded.
|
|
11
|
+
#
|
|
12
|
+
# @param n [Numeric] The number to convert.
|
|
13
|
+
# @param min_bytes [Integer] The minimum number of bytes to return
|
|
14
|
+
# @return [Array<Integer>] Array of bytes between 0 and 255
|
|
14
15
|
def numeric_to_bytes(n, min_bytes=0)
|
|
15
16
|
n.to_s(16).rjust(2 * min_bytes, '0').scan(/../).map do |s|
|
|
16
17
|
s.to_i(16)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Imb
|
|
2
|
+
|
|
3
|
+
# Provides paths to gem directories
|
|
4
|
+
module ProjectDirs
|
|
5
|
+
|
|
6
|
+
# Returns the root directory of the gem
|
|
7
|
+
# @return [String] absolute path to gem root
|
|
8
|
+
def self.project_dir
|
|
9
|
+
File.expand_path('../..', __dir__)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Returns the bundled fonts directory
|
|
13
|
+
# @return [String] absolute path to fonts/ directory
|
|
14
|
+
def self.font_dir
|
|
15
|
+
File.join(project_dir, 'fonts')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
module Imb
|
|
2
2
|
|
|
3
3
|
# Represents a routing code
|
|
4
|
-
|
|
5
4
|
class RoutingCode
|
|
6
5
|
|
|
7
6
|
# Turn the argument into a RoutingCode if possible. Accepts:
|
|
@@ -39,11 +38,11 @@ module Imb
|
|
|
39
38
|
# @return [Integer] The delivery point (or nil)
|
|
40
39
|
attr_accessor :delivery_point
|
|
41
40
|
|
|
42
|
-
# Create a RoutingCode.
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
#
|
|
46
|
-
|
|
41
|
+
# Create a RoutingCode.
|
|
42
|
+
#
|
|
43
|
+
# @param zip [Integer, nil] Five-digit zip code. Mayb be nil.
|
|
44
|
+
# @param plus4 [Integer, nil] Four-digit "plus 4" code.
|
|
45
|
+
# @param delivery_point [Integer, nil] Two-digit Delivery point
|
|
47
46
|
def initialize(zip, plus4, delivery_point)
|
|
48
47
|
@zip = arg_to_i(zip)
|
|
49
48
|
@plus4 = arg_to_i(plus4)
|
|
@@ -51,8 +50,7 @@ module Imb
|
|
|
51
50
|
end
|
|
52
51
|
|
|
53
52
|
# Return true if this object is equal to o
|
|
54
|
-
# @param [Object]
|
|
55
|
-
|
|
53
|
+
# @param o [Object] Any object acceptable to {.coerce}
|
|
56
54
|
def ==(o)
|
|
57
55
|
RoutingCode.coerce(o).to_a == to_a
|
|
58
56
|
rescue ArgumentError
|
|
@@ -62,14 +60,16 @@ module Imb
|
|
|
62
60
|
# @!group Internal
|
|
63
61
|
|
|
64
62
|
# Convert a string representation of a routing code into
|
|
65
|
-
# an array that can be passed to the constructor.
|
|
66
|
-
#
|
|
63
|
+
# an array that can be passed to the constructor. The routing string length may be:
|
|
64
|
+
#
|
|
67
65
|
# * 0 - no routing code
|
|
68
66
|
# * 5 - zip
|
|
69
67
|
# * 9 - zip + plus4
|
|
70
68
|
# * 11 - zip + plus4 + delivery point
|
|
71
|
-
#
|
|
72
|
-
|
|
69
|
+
#
|
|
70
|
+
# @param s [String] Routing code.
|
|
71
|
+
# @return [Array<String, String, String>] zip, plus4, and
|
|
72
|
+
# delivery_point that can be passed to the constructor.
|
|
73
73
|
def self.string_to_array(s)
|
|
74
74
|
s = s.gsub(/[\D]/, '')
|
|
75
75
|
match = /^(?:(\d{5})(?:(\d{4})(\d{2})?)?)?$/.match(s)
|
|
@@ -81,42 +81,45 @@ module Imb
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
# Validate the value.
|
|
84
|
-
#
|
|
84
|
+
#
|
|
85
|
+
# @param long_mailer_id [boolean] truthy if the mailer ID is long
|
|
86
|
+
# (9 digits).
|
|
85
87
|
# @raise ArgumentError if invalid
|
|
86
|
-
|
|
87
88
|
def validate(long_mailer_id)
|
|
88
89
|
end
|
|
89
90
|
|
|
90
91
|
# Add this object's value to target, shifting it left as many
|
|
91
92
|
# digts as are needed to make room.
|
|
93
|
+
#
|
|
92
94
|
# @param [Integer] target The target to be shifted and added to
|
|
93
|
-
# @param long_mailer_id truthy if the mailer ID is long
|
|
95
|
+
# @param long_mailer_id [boolean] truthy if the mailer ID is long
|
|
96
|
+
# (9 digits).
|
|
94
97
|
# @return [Integer] The new value of the target
|
|
95
|
-
|
|
96
98
|
def shift_and_add_to(target, long_mailer_id)
|
|
97
99
|
target * 10 ** NUM_DIGITS + convert
|
|
98
100
|
end
|
|
99
101
|
|
|
100
102
|
# @!endgroup
|
|
101
103
|
|
|
102
|
-
protected
|
|
103
|
-
|
|
104
104
|
# Convert to an array of [zip, plus4, delivery point]
|
|
105
|
-
|
|
105
|
+
# @return [Array<Integer, Integer, Integer>]
|
|
106
|
+
# @note Public for testing
|
|
106
107
|
def to_a
|
|
107
108
|
[@zip, @plus4, @delivery_point]
|
|
108
109
|
end
|
|
109
110
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
# Convert to a string
|
|
112
|
+
def to_s
|
|
113
|
+
"%05d%04d%02d" % [
|
|
114
|
+
@zip,
|
|
115
|
+
@plus4,
|
|
116
|
+
@delivery_point,
|
|
117
|
+
]
|
|
116
118
|
end
|
|
117
|
-
|
|
118
|
-
# Convert to an integer value
|
|
119
119
|
|
|
120
|
+
# Convert to an integer value
|
|
121
|
+
# @return [Integer]
|
|
122
|
+
# @note Public for testing
|
|
120
123
|
def convert
|
|
121
124
|
if @zip && @plus4 && @delivery_point
|
|
122
125
|
@zip * 1000000 + @plus4 * 100 + @delivery_point + 1000100001
|
|
@@ -129,6 +132,14 @@ module Imb
|
|
|
129
132
|
end
|
|
130
133
|
end
|
|
131
134
|
|
|
135
|
+
private
|
|
136
|
+
|
|
137
|
+
NUM_DIGITS = 11 #:nodoc:
|
|
138
|
+
|
|
139
|
+
def arg_to_i(o)
|
|
140
|
+
o.andand.to_i
|
|
141
|
+
end
|
|
142
|
+
|
|
132
143
|
end
|
|
133
144
|
|
|
134
145
|
end
|
|
@@ -9,7 +9,6 @@ module Imb
|
|
|
9
9
|
# * String
|
|
10
10
|
# * Integer
|
|
11
11
|
# @return [SerialNumber]
|
|
12
|
-
|
|
13
12
|
def self.coerce(o)
|
|
14
13
|
case o
|
|
15
14
|
when SerialNumber
|
|
@@ -23,33 +22,38 @@ module Imb
|
|
|
23
22
|
end
|
|
24
23
|
end
|
|
25
24
|
|
|
25
|
+
# Construct an instance.
|
|
26
|
+
#
|
|
26
27
|
# @param [Integer] value
|
|
27
|
-
|
|
28
28
|
def initialize(value)
|
|
29
29
|
@value = value
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
# Return true if this object is equal to o
|
|
33
|
-
# @param [Object]
|
|
34
|
-
|
|
33
|
+
# @param o [Object] Any object acceptable to {.coerce}
|
|
35
34
|
def ==(o)
|
|
36
35
|
SerialNumber.coerce(o).to_i == to_i
|
|
37
36
|
rescue ArgumentError
|
|
38
37
|
false
|
|
39
38
|
end
|
|
40
39
|
|
|
41
|
-
# @return [Integer] The value of the serial number
|
|
42
|
-
|
|
40
|
+
# @return [Integer] The integer value of the serial number
|
|
43
41
|
def to_i
|
|
44
42
|
@value
|
|
45
43
|
end
|
|
46
44
|
|
|
45
|
+
# @return [String] The string value of the serial number
|
|
46
|
+
def to_s
|
|
47
|
+
@value.to_s
|
|
48
|
+
end
|
|
49
|
+
|
|
47
50
|
# @!group Internal
|
|
48
51
|
|
|
49
52
|
# Validate the value.
|
|
50
|
-
#
|
|
53
|
+
#
|
|
54
|
+
# @param long_mailer_id [boolean] truthy if the mailer ID is long
|
|
55
|
+
# (9 digits).
|
|
51
56
|
# @raise ArgumentError if invalid
|
|
52
|
-
|
|
53
57
|
def validate(long_mailer_id)
|
|
54
58
|
range = 0..max_value(long_mailer_id)
|
|
55
59
|
unless range === @value
|
|
@@ -59,10 +63,11 @@ module Imb
|
|
|
59
63
|
|
|
60
64
|
# Add this object's value to target, shifting it left as many
|
|
61
65
|
# digts as are needed to make room.
|
|
62
|
-
#
|
|
63
|
-
# @param
|
|
66
|
+
#
|
|
67
|
+
# @param target [Integer] The target to be shifted and added to
|
|
68
|
+
# @param long_mailer_id [boolean] truthy if the mailer ID is long
|
|
69
|
+
# (9 digits).
|
|
64
70
|
# @return [Integer] The new value of the target
|
|
65
|
-
|
|
66
71
|
def shift_and_add_to(target, long_mailer_id)
|
|
67
72
|
target * 10 ** num_digits(long_mailer_id) + to_i
|
|
68
73
|
end
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
module Imb
|
|
2
2
|
|
|
3
3
|
# This class represents a service type.
|
|
4
|
-
|
|
5
4
|
class ServiceType
|
|
6
5
|
|
|
7
6
|
# The valid range of a service type
|
|
@@ -11,7 +10,6 @@ module Imb
|
|
|
11
10
|
# * {ServiceType}
|
|
12
11
|
# * String
|
|
13
12
|
# * Integer
|
|
14
|
-
|
|
15
13
|
def self.coerce(o)
|
|
16
14
|
case o
|
|
17
15
|
when ServiceType
|
|
@@ -25,33 +23,36 @@ module Imb
|
|
|
25
23
|
end
|
|
26
24
|
end
|
|
27
25
|
|
|
28
|
-
# @param [Integer]
|
|
29
|
-
|
|
26
|
+
# @param value [Integer]
|
|
30
27
|
def initialize(value)
|
|
31
28
|
@value = value
|
|
32
29
|
end
|
|
33
30
|
|
|
34
31
|
# Return true if this object is equal to o
|
|
35
|
-
# @param [Object]
|
|
36
|
-
|
|
32
|
+
# @param o [Object] Any object acceptable to {.coerce}
|
|
37
33
|
def ==(o)
|
|
38
34
|
ServiceType.coerce(o).to_i == to_i
|
|
39
35
|
rescue ArgumentError
|
|
40
36
|
false
|
|
41
37
|
end
|
|
42
38
|
|
|
43
|
-
# @return [Integer] The value of the service type
|
|
44
|
-
|
|
39
|
+
# @return [Integer] The integer value of the service type
|
|
45
40
|
def to_i
|
|
46
41
|
@value
|
|
47
42
|
end
|
|
48
43
|
|
|
44
|
+
# @return [Integer] The string value of the service type
|
|
45
|
+
def to_s
|
|
46
|
+
@value.to_s
|
|
47
|
+
end
|
|
48
|
+
|
|
49
49
|
# @!group Internal
|
|
50
50
|
|
|
51
51
|
# Validate the value.
|
|
52
|
-
#
|
|
52
|
+
#
|
|
53
|
+
# @param long_mailer_id [boolean] truthy if the mailer ID is long
|
|
54
|
+
# (9 digits).
|
|
53
55
|
# @raise ArgumentError if invalid
|
|
54
|
-
|
|
55
56
|
def validate(long_mailer_id)
|
|
56
57
|
unless (RANGE) === @value
|
|
57
58
|
raise ArgumentError, "Must be #{RANGE}"
|
|
@@ -60,10 +61,11 @@ module Imb
|
|
|
60
61
|
|
|
61
62
|
# Add this object's value to target, shifting it left as many
|
|
62
63
|
# digts as are needed to make room.
|
|
64
|
+
#
|
|
63
65
|
# @param [Integer] target The target to be shifted and added to
|
|
64
|
-
# @param long_mailer_id truthy if the mailer ID is long
|
|
66
|
+
# @param long_mailer_id [boolean] truthy if the mailer ID is long
|
|
67
|
+
# (9 digits).
|
|
65
68
|
# @return [Integer] The new value of the target
|
|
66
|
-
|
|
67
69
|
def shift_and_add_to(target, long_mailer_id)
|
|
68
70
|
target * 10 ** NUM_DIGITS + to_i
|
|
69
71
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Imb
|
|
2
|
+
|
|
3
|
+
# Provides access to bundled USPS Intelligent Mail Barcode fonts
|
|
4
|
+
class UspsFonts
|
|
5
|
+
|
|
6
|
+
# USPS recommended font size in points (16pt for standard fonts per spec)
|
|
7
|
+
STANDARD_FONT_SIZE = 16
|
|
8
|
+
|
|
9
|
+
# Returns path to the standard USPS IMB font (recommended for most use)
|
|
10
|
+
# USPSIMBStandard is the primary USPS Intelligent Mail Barcode font
|
|
11
|
+
# @return [String] absolute path to USPSIMBStandard.ttf
|
|
12
|
+
def self.standard_font_path
|
|
13
|
+
font_path('USPSIMBStandard.ttf')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Returns path to the compact USPS IMB font
|
|
17
|
+
# USPSIMBCompact provides a more compact barcode rendering
|
|
18
|
+
# @return [String] absolute path to USPSIMBCompact.ttf
|
|
19
|
+
def self.compact_font_path
|
|
20
|
+
font_path('USPSIMBCompact.ttf')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Returns paths to all bundled USPS fonts
|
|
24
|
+
# @return [Hash<Symbol, String>] font name symbols to file paths
|
|
25
|
+
def self.all_font_paths
|
|
26
|
+
{
|
|
27
|
+
standard: standard_font_path,
|
|
28
|
+
compact: compact_font_path
|
|
29
|
+
}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Returns the USPS-recommended font size
|
|
33
|
+
# @return [Integer] font size in points (16pt)
|
|
34
|
+
def self.font_size
|
|
35
|
+
STANDARD_FONT_SIZE
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
# Returns absolute path to a font file in the bundled fonts directory
|
|
41
|
+
# @param filename [String] font filename
|
|
42
|
+
# @return [String] absolute path to font file
|
|
43
|
+
def self.font_path(filename)
|
|
44
|
+
File.join(ProjectDirs.font_dir, filename)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -12,6 +12,8 @@ require 'usps_intelligent_barcode/codeword_map'
|
|
|
12
12
|
require 'usps_intelligent_barcode/crc'
|
|
13
13
|
require 'usps_intelligent_barcode/mailer_id'
|
|
14
14
|
require 'usps_intelligent_barcode/numeric_conversions'
|
|
15
|
+
require 'usps_intelligent_barcode/project_dirs'
|
|
15
16
|
require 'usps_intelligent_barcode/routing_code'
|
|
16
17
|
require 'usps_intelligent_barcode/serial_number'
|
|
17
18
|
require 'usps_intelligent_barcode/service_type'
|
|
19
|
+
require 'usps_intelligent_barcode/usps_fonts'
|
data/rake/bundler.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
data/rake/default.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
task :default => :spec
|
data/rake/rspec.rb
ADDED
data/rake/version.rb
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
namespace :version do
|
|
2
|
+
VERSION_FILE = 'VERSION'
|
|
3
|
+
desc "Bump major version (X.0.0)"
|
|
4
|
+
task :bump_major do
|
|
5
|
+
bump_version(:major)
|
|
6
|
+
end
|
|
7
|
+
desc "Bump minor version (x.X.0)"
|
|
8
|
+
task :bump_minor do
|
|
9
|
+
bump_version(:minor)
|
|
10
|
+
end
|
|
11
|
+
desc "Bump patch version (x.x.X)"
|
|
12
|
+
task :bump_patch do
|
|
13
|
+
bump_version(:patch)
|
|
14
|
+
end
|
|
15
|
+
def bump_version(level)
|
|
16
|
+
current = File.read(VERSION_FILE).strip
|
|
17
|
+
major, minor, patch = current.split('.').map(&:to_i)
|
|
18
|
+
case level
|
|
19
|
+
when :major
|
|
20
|
+
major += 1
|
|
21
|
+
minor = 0
|
|
22
|
+
patch = 0
|
|
23
|
+
when :minor
|
|
24
|
+
minor += 1
|
|
25
|
+
patch = 0
|
|
26
|
+
when :patch
|
|
27
|
+
patch += 1
|
|
28
|
+
end
|
|
29
|
+
new_version = "#{major}.#{minor}.#{patch}"
|
|
30
|
+
File.write(VERSION_FILE, new_version + "\n")
|
|
31
|
+
puts "Bumped version from #{current} to #{new_version}"
|
|
32
|
+
end
|
|
33
|
+
end
|
data/rake/yard.rb
ADDED
|
@@ -1,102 +1,27 @@
|
|
|
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.1 ruby lib
|
|
6
|
-
|
|
7
1
|
Gem::Specification.new do |s|
|
|
8
|
-
s.name
|
|
9
|
-
s.version
|
|
10
|
-
|
|
11
|
-
s.
|
|
12
|
-
s.
|
|
13
|
-
s.
|
|
14
|
-
s.
|
|
15
|
-
s.
|
|
16
|
-
s.
|
|
17
|
-
s.
|
|
18
|
-
|
|
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
|
-
"USPS-intelligent-barcode.gemspec",
|
|
30
|
-
"VERSION",
|
|
31
|
-
"examples/example.rb",
|
|
32
|
-
"lib/usps_intelligent_barcode.rb",
|
|
33
|
-
"lib/usps_intelligent_barcode/bar_map.rb",
|
|
34
|
-
"lib/usps_intelligent_barcode/bar_position.rb",
|
|
35
|
-
"lib/usps_intelligent_barcode/bar_symbol.rb",
|
|
36
|
-
"lib/usps_intelligent_barcode/bar_to_character_mapping.yml",
|
|
37
|
-
"lib/usps_intelligent_barcode/barcode.rb",
|
|
38
|
-
"lib/usps_intelligent_barcode/barcode_id.rb",
|
|
39
|
-
"lib/usps_intelligent_barcode/character_position.rb",
|
|
40
|
-
"lib/usps_intelligent_barcode/codeword_map.rb",
|
|
41
|
-
"lib/usps_intelligent_barcode/codeword_to_character_mapping.yml",
|
|
42
|
-
"lib/usps_intelligent_barcode/crc.rb",
|
|
43
|
-
"lib/usps_intelligent_barcode/mailer_id.rb",
|
|
44
|
-
"lib/usps_intelligent_barcode/numeric_conversions.rb",
|
|
45
|
-
"lib/usps_intelligent_barcode/routing_code.rb",
|
|
46
|
-
"lib/usps_intelligent_barcode/serial_number.rb",
|
|
47
|
-
"lib/usps_intelligent_barcode/service_type.rb",
|
|
48
|
-
"spec/bar_map_spec.rb",
|
|
49
|
-
"spec/bar_position_spec.rb",
|
|
50
|
-
"spec/bar_symbol_spec.rb",
|
|
51
|
-
"spec/barcode_id_spec.rb",
|
|
52
|
-
"spec/barcode_spec.rb",
|
|
53
|
-
"spec/character_position_spec.rb",
|
|
54
|
-
"spec/codeword_map_spec.rb",
|
|
55
|
-
"spec/crc_spec.rb",
|
|
56
|
-
"spec/mailer_id_spec.rb",
|
|
57
|
-
"spec/numeric_conversions_spec.rb",
|
|
58
|
-
"spec/routing_code_spec.rb",
|
|
59
|
-
"spec/serial_number_spec.rb",
|
|
60
|
-
"spec/service_type_spec.rb",
|
|
61
|
-
"spec/spec_helper.rb",
|
|
62
|
-
"usps_intelligent_barcode.gemspec"
|
|
63
|
-
]
|
|
64
|
-
s.homepage = "http://github.com/wconrad/usps_intelligent_barcode"
|
|
65
|
-
s.licenses = ["MIT"]
|
|
66
|
-
s.rubygems_version = "2.4.3"
|
|
67
|
-
s.summary = "Generates a USPS Intelligent Mail Barcode."
|
|
68
|
-
|
|
69
|
-
if s.respond_to? :specification_version then
|
|
70
|
-
s.specification_version = 4
|
|
71
|
-
|
|
72
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
73
|
-
s.add_runtime_dependency(%q<andand>, ["~> 1.3"])
|
|
74
|
-
s.add_runtime_dependency(%q<memoizer>, ["~> 1.0"])
|
|
75
|
-
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
|
76
|
-
s.add_development_dependency(%q<rspec>, ["~> 3.3"])
|
|
77
|
-
s.add_development_dependency(%q<rspec-its>, ["~> 1.0"])
|
|
78
|
-
s.add_development_dependency(%q<simplecov>, ["~> 0.10.0"])
|
|
79
|
-
s.add_development_dependency(%q<yard>, ["~> 0.8.5"])
|
|
80
|
-
s.add_development_dependency(%q<rake>, ["~> 10.0"])
|
|
81
|
-
else
|
|
82
|
-
s.add_dependency(%q<andand>, ["~> 1.3"])
|
|
83
|
-
s.add_dependency(%q<memoizer>, ["~> 1.0"])
|
|
84
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
|
85
|
-
s.add_dependency(%q<rspec>, ["~> 3.3"])
|
|
86
|
-
s.add_dependency(%q<rspec-its>, ["~> 1.0"])
|
|
87
|
-
s.add_dependency(%q<simplecov>, ["~> 0.10.0"])
|
|
88
|
-
s.add_dependency(%q<yard>, ["~> 0.8.5"])
|
|
89
|
-
s.add_dependency(%q<rake>, ["~> 10.0"])
|
|
90
|
-
end
|
|
91
|
-
else
|
|
92
|
-
s.add_dependency(%q<andand>, ["~> 1.3"])
|
|
93
|
-
s.add_dependency(%q<memoizer>, ["~> 1.0"])
|
|
94
|
-
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
|
95
|
-
s.add_dependency(%q<rspec>, ["~> 3.3"])
|
|
96
|
-
s.add_dependency(%q<rspec-its>, ["~> 1.0"])
|
|
97
|
-
s.add_dependency(%q<simplecov>, ["~> 0.10.0"])
|
|
98
|
-
s.add_dependency(%q<yard>, ["~> 0.8.5"])
|
|
99
|
-
s.add_dependency(%q<rake>, ["~> 10.0"])
|
|
2
|
+
s.name = 'usps_intelligent_barcode'
|
|
3
|
+
s.version = File.read('VERSION').strip
|
|
4
|
+
s.summary = 'Generates a USPS Intelligent Mail Barcode.'
|
|
5
|
+
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.'
|
|
6
|
+
s.authors = ['Wayne Conrad']
|
|
7
|
+
s.email = 'kf7qga@gmail.com'
|
|
8
|
+
s.homepage = 'https://github.com/wconrad/usps_intelligent_barcode'
|
|
9
|
+
s.license = 'MIT'
|
|
10
|
+
s.required_ruby_version = '>= 3.2.0'
|
|
11
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
12
|
+
f.match(%r{^(test|spec|features)/})
|
|
100
13
|
end
|
|
14
|
+
s.require_paths = ['lib']
|
|
15
|
+
s.add_runtime_dependency 'andand', '~> 1.3'
|
|
16
|
+
s.add_runtime_dependency 'memoizer', '~> 1.0'
|
|
17
|
+
s.add_development_dependency 'prawn', '~> 2.5'
|
|
18
|
+
s.add_development_dependency 'rake', '~> 13.0'
|
|
19
|
+
s.add_development_dependency 'rspec', '~> 3.12'
|
|
20
|
+
s.add_development_dependency 'rspec-its', '~> 2.0'
|
|
21
|
+
s.add_development_dependency 'simplecov', '~> 0.22'
|
|
22
|
+
s.add_development_dependency 'yard', '~> 0.9'
|
|
23
|
+
s.metadata = {
|
|
24
|
+
'source_code_uri' => 'https://github.com/wconrad/usps_intelligent_barcode',
|
|
25
|
+
'bug_tracker_uri' => 'https://github.com/wconrad/usps_intelligent_barcode/issues'
|
|
26
|
+
}
|
|
101
27
|
end
|
|
102
|
-
|