zebra-zpl 1.0.5 → 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 +4 -4
- data/CHANGELOG.md +62 -0
- data/CONTRIBUTING.md +49 -0
- data/Gemfile +6 -0
- data/README.md +259 -76
- data/docs/example.rb +249 -0
- data/docs/images/barcode.png +0 -0
- data/docs/images/datamatrix.png +0 -0
- data/docs/images/earth.jpg +0 -0
- data/docs/images/graphics.png +0 -0
- data/docs/images/image.png +0 -0
- data/docs/images/image_inverted.png +0 -0
- data/docs/images/images.png +0 -0
- data/docs/images/justification.png +0 -0
- data/docs/images/qrcode.png +0 -0
- data/docs/images/rotation.png +0 -0
- data/docs/images/text.png +0 -0
- data/lib/zebra/print_job.rb +7 -13
- data/lib/zebra/zpl.rb +20 -13
- data/lib/zebra/zpl/barcode.rb +29 -12
- data/lib/zebra/zpl/barcode_type.rb +4 -1
- data/lib/zebra/zpl/box.rb +16 -4
- data/lib/zebra/zpl/comment.rb +15 -0
- data/lib/zebra/zpl/datamatrix.rb +76 -0
- data/lib/zebra/zpl/graphic.rb +91 -0
- data/lib/zebra/zpl/image.rb +91 -0
- data/lib/zebra/zpl/label.rb +2 -13
- data/lib/zebra/zpl/pdf417.rb +50 -0
- data/lib/zebra/zpl/qrcode.rb +2 -2
- data/lib/zebra/zpl/text.rb +44 -20
- data/lib/zebra/zpl/version.rb +1 -1
- data/spec/fixtures/default.jpg +0 -0
- data/spec/spec_helper.rb +6 -2
- data/spec/zebra/print_job_spec.rb +13 -18
- data/spec/zebra/zpl/barcode_spec.rb +70 -63
- data/spec/zebra/zpl/box_spec.rb +27 -31
- data/spec/zebra/zpl/character_set_spec.rb +7 -7
- data/spec/zebra/zpl/comment_spec.rb +18 -0
- data/spec/zebra/zpl/datamatrix_spec.rb +124 -0
- data/spec/zebra/zpl/graphics_spec.rb +227 -0
- data/spec/zebra/zpl/image_spec.rb +113 -0
- data/spec/zebra/zpl/label_spec.rb +40 -52
- data/spec/zebra/zpl/pdf417_spec.rb +108 -0
- data/spec/zebra/zpl/qrcode_spec.rb +92 -92
- data/spec/zebra/zpl/text_spec.rb +57 -55
- data/zebra-zpl.gemspec +14 -15
- metadata +71 -22
data/spec/zebra/zpl/text_spec.rb
CHANGED
@@ -3,46 +3,46 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe Zebra::Zpl::Text do
|
5
5
|
it "can be initialized with the position of the text to be printed" do
|
6
|
-
text = described_class.new :
|
7
|
-
text.position.
|
8
|
-
text.x.
|
9
|
-
text.y.
|
6
|
+
text = described_class.new position: [20, 40]
|
7
|
+
expect(text.position).to eq [20,40]
|
8
|
+
expect(text.x).to eq 20
|
9
|
+
expect(text.y).to eq 40
|
10
10
|
end
|
11
11
|
|
12
12
|
it "can be initialized with the text rotation" do
|
13
13
|
rotation = Zebra::Zpl::Rotation::DEGREES_90
|
14
|
-
text = described_class.new :
|
15
|
-
text.rotation.
|
14
|
+
text = described_class.new rotation: rotation
|
15
|
+
expect(text.rotation).to eq rotation
|
16
16
|
end
|
17
17
|
|
18
18
|
it "can be initialized with the font_size to be used" do
|
19
19
|
font_size = Zebra::Zpl::FontSize::SIZE_1
|
20
|
-
text = described_class.new :
|
21
|
-
text.font_size.
|
20
|
+
text = described_class.new font_size: font_size
|
21
|
+
expect(text.font_size).to eq font_size
|
22
22
|
end
|
23
23
|
|
24
|
-
it "can be initialized with the horizontal multiplier" do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
it "can be initialized with the vertical multiplier" do
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
24
|
+
# it "can be initialized with the horizontal multiplier" do
|
25
|
+
# multiplier = Zebra::Zpl::HorizontalMultiplier::VALUE_1
|
26
|
+
# text = described_class.new h_multiplier: multiplier
|
27
|
+
# expect(text.h_multiplier).to eq multiplier
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# it "can be initialized with the vertical multiplier" do
|
31
|
+
# multiplier = Zebra::Zpl::VerticalMultiplier::VALUE_1
|
32
|
+
# text = described_class.new v_multiplier: multiplier
|
33
|
+
# expect(text.v_multiplier).to eq multiplier
|
34
|
+
# end
|
35
35
|
|
36
36
|
it "can be initialized with the data to be printed" do
|
37
37
|
data = "foobar"
|
38
|
-
text = described_class.new :
|
39
|
-
text.data.
|
38
|
+
text = described_class.new data: data
|
39
|
+
expect(text.data).to eq data
|
40
40
|
end
|
41
41
|
|
42
42
|
it "can be initialized with the printing mode" do
|
43
43
|
print_mode = Zebra::Zpl::PrintMode::REVERSE
|
44
|
-
text = described_class.new :
|
45
|
-
text.print_mode.
|
44
|
+
text = described_class.new print_mode: print_mode
|
45
|
+
expect(text.print_mode).to eq print_mode
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "#rotation=" do
|
@@ -61,21 +61,21 @@ describe Zebra::Zpl::Text do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
describe "#h_multiplier=" do
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
describe "#v_multiplier=" do
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
64
|
+
# describe "#h_multiplier=" do
|
65
|
+
# it "raises an error if the received multiplier is invalid" do
|
66
|
+
# expect {
|
67
|
+
# described_class.new.h_multiplier = 9
|
68
|
+
# }.to raise_error(Zebra::Zpl::HorizontalMultiplier::InvalidMultiplierError)
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
#
|
72
|
+
# describe "#v_multiplier=" do
|
73
|
+
# it "raises an error if the received multiplier is invalid" do
|
74
|
+
# expect {
|
75
|
+
# described_class.new.v_multiplier = 10
|
76
|
+
# }.to raise_error(Zebra::Zpl::VerticalMultiplier::InvalidMultiplierError)
|
77
|
+
# end
|
78
|
+
# end
|
79
79
|
|
80
80
|
describe "#print_mode=" do
|
81
81
|
it "raises an error if the received print mode is invalid" do
|
@@ -86,24 +86,26 @@ describe Zebra::Zpl::Text do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
describe "#to_zpl" do
|
89
|
-
subject(:text) { described_class.new :
|
89
|
+
subject(:text) { described_class.new position: [100, 150], font_size: Zebra::Zpl::FontSize::SIZE_3, data: "foobar" }
|
90
|
+
subject(:text_bold) { described_class.new position: [100, 150], font_size: Zebra::Zpl::FontSize::SIZE_3, bold: true, data: "foobar" }
|
91
|
+
subject(:tokens) { text.to_zpl.split(/(\^[A-Z]+|\,)/).reject{ |e| ['', ',', nil].include?(e) } }
|
90
92
|
|
91
93
|
it "raises an error if the X position was not informed" do
|
92
|
-
text = described_class.new :
|
94
|
+
text = described_class.new position: [nil, 100], data: "foobar"
|
93
95
|
expect {
|
94
96
|
text.to_zpl
|
95
97
|
}.to raise_error(Zebra::Zpl::Printable::MissingAttributeError, "Can't print if the X value is not given")
|
96
98
|
end
|
97
99
|
|
98
100
|
it "raises an error if the Y position was not informed" do
|
99
|
-
text = described_class.new :
|
101
|
+
text = described_class.new position: [100, nil]
|
100
102
|
expect {
|
101
103
|
text.to_zpl
|
102
104
|
}.to raise_error(Zebra::Zpl::Printable::MissingAttributeError, "Can't print if the Y value is not given")
|
103
105
|
end
|
104
106
|
|
105
107
|
it "raises an error if the font_size is not informed" do
|
106
|
-
text = described_class.new :
|
108
|
+
text = described_class.new position: [100, 100], data: "foobar"
|
107
109
|
expect {
|
108
110
|
text.to_zpl
|
109
111
|
}.to raise_error(Zebra::Zpl::Printable::MissingAttributeError, "Can't print if the font_size to be used is not given")
|
@@ -116,24 +118,24 @@ describe Zebra::Zpl::Text do
|
|
116
118
|
}.to raise_error(Zebra::Zpl::Printable::MissingAttributeError, "Can't print if the data to be printed is not given")
|
117
119
|
end
|
118
120
|
|
119
|
-
it "
|
120
|
-
text.to_zpl.
|
121
|
+
it "contains the '^FB' command" do
|
122
|
+
expect(text.to_zpl).to match /\^FB/
|
121
123
|
end
|
122
124
|
|
123
|
-
it "
|
124
|
-
text.to_zpl
|
125
|
+
it "contains the attributes in correct order" do
|
126
|
+
expect(text.to_zpl).to eq '^FWN^CF0,28^CI28^FO100,150^FB,4,,L,^FDfoobar^FS'
|
125
127
|
end
|
126
128
|
|
127
|
-
it "
|
128
|
-
|
129
|
+
it "contains the properly duplicated attributes in correct order for bold text" do
|
130
|
+
expect(text_bold.to_zpl).to eq '^FWN^CF0,28^CI28^FO102,150^FB,4,,L,^FDfoobar^FS^FWN^CF0,28^CI28^FO100,152^FB,4,,L,^FDfoobar^FS'
|
129
131
|
end
|
130
132
|
|
131
|
-
it "assumes
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
it "assumes
|
136
|
-
|
137
|
-
end
|
133
|
+
# it "assumes 1 as the default horizontal multipler" do
|
134
|
+
# expect(text.to_zpl.split(",")[4].to_i).to eq Zebra::Zpl::HorizontalMultiplier::VALUE_1
|
135
|
+
# end
|
136
|
+
#
|
137
|
+
# it "assumes 1 as the default vertical multiplier" do
|
138
|
+
# expect(text.to_zpl.split(",")[5].to_i).to eq Zebra::Zpl::VerticalMultiplier::VALUE_1
|
139
|
+
# end
|
138
140
|
end
|
139
141
|
end
|
data/zebra-zpl.gemspec
CHANGED
@@ -1,30 +1,29 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
4
|
require 'zebra/zpl/version'
|
6
5
|
|
7
6
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
7
|
+
spec.name = 'zebra-zpl'
|
9
8
|
spec.version = Zebra::Zpl::VERSION
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
9
|
+
spec.authors = ['Barnabas Bulpett','Michael King','Logan Green']
|
10
|
+
spec.email = ['barnabasbulpett@gmail.com','mtking1123@gmail.com','loganagreen95@gmail.com']
|
12
11
|
spec.description = %q{Print labels using ZPL2 and Ruby}
|
13
12
|
spec.summary = %q{Simple DSL to create labels and send them to a Zebra printer using Ruby, ZPL2 and CUPS}
|
14
13
|
|
15
|
-
spec.homepage =
|
16
|
-
spec.license =
|
14
|
+
spec.homepage = 'https://github.com/bbulpett/zebra-zpl'
|
15
|
+
spec.license = 'MIT'
|
17
16
|
|
18
17
|
spec.files = `git ls-files`.split($/)
|
19
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ['lib']
|
22
21
|
|
23
|
-
|
22
|
+
spec.add_dependency 'img2zpl', '~> 1.0.0'
|
24
23
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
25
|
+
spec.add_development_dependency 'rake', '~> 13'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.9'
|
27
|
+
spec.add_development_dependency 'guard', '~> 2.15'
|
28
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
30
29
|
end
|
metadata
CHANGED
@@ -1,112 +1,149 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zebra-zpl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Barnabas Bulpett
|
8
|
+
- Michael King
|
9
|
+
- Logan Green
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date: 2019-
|
13
|
+
date: 2019-11-04 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: img2zpl
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: 1.0.0
|
13
29
|
- !ruby/object:Gem::Dependency
|
14
30
|
name: bundler
|
15
31
|
requirement: !ruby/object:Gem::Requirement
|
16
32
|
requirements:
|
17
|
-
- - "
|
33
|
+
- - "~>"
|
18
34
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
35
|
+
version: '2.0'
|
20
36
|
type: :development
|
21
37
|
prerelease: false
|
22
38
|
version_requirements: !ruby/object:Gem::Requirement
|
23
39
|
requirements:
|
24
|
-
- - "
|
40
|
+
- - "~>"
|
25
41
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
42
|
+
version: '2.0'
|
27
43
|
- !ruby/object:Gem::Dependency
|
28
44
|
name: rake
|
29
45
|
requirement: !ruby/object:Gem::Requirement
|
30
46
|
requirements:
|
31
|
-
- - "
|
47
|
+
- - "~>"
|
32
48
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
49
|
+
version: '13'
|
34
50
|
type: :development
|
35
51
|
prerelease: false
|
36
52
|
version_requirements: !ruby/object:Gem::Requirement
|
37
53
|
requirements:
|
38
|
-
- - "
|
54
|
+
- - "~>"
|
39
55
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
56
|
+
version: '13'
|
41
57
|
- !ruby/object:Gem::Dependency
|
42
58
|
name: rspec
|
43
59
|
requirement: !ruby/object:Gem::Requirement
|
44
60
|
requirements:
|
45
|
-
- - "
|
61
|
+
- - "~>"
|
46
62
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
63
|
+
version: '3.9'
|
48
64
|
type: :development
|
49
65
|
prerelease: false
|
50
66
|
version_requirements: !ruby/object:Gem::Requirement
|
51
67
|
requirements:
|
52
|
-
- - "
|
68
|
+
- - "~>"
|
53
69
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
70
|
+
version: '3.9'
|
55
71
|
- !ruby/object:Gem::Dependency
|
56
72
|
name: guard
|
57
73
|
requirement: !ruby/object:Gem::Requirement
|
58
74
|
requirements:
|
59
|
-
- - "
|
75
|
+
- - "~>"
|
60
76
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
77
|
+
version: '2.15'
|
62
78
|
type: :development
|
63
79
|
prerelease: false
|
64
80
|
version_requirements: !ruby/object:Gem::Requirement
|
65
81
|
requirements:
|
66
|
-
- - "
|
82
|
+
- - "~>"
|
67
83
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
84
|
+
version: '2.15'
|
69
85
|
- !ruby/object:Gem::Dependency
|
70
86
|
name: guard-rspec
|
71
87
|
requirement: !ruby/object:Gem::Requirement
|
72
88
|
requirements:
|
73
|
-
- - "
|
89
|
+
- - "~>"
|
74
90
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
91
|
+
version: '4.7'
|
76
92
|
type: :development
|
77
93
|
prerelease: false
|
78
94
|
version_requirements: !ruby/object:Gem::Requirement
|
79
95
|
requirements:
|
80
|
-
- - "
|
96
|
+
- - "~>"
|
81
97
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
98
|
+
version: '4.7'
|
83
99
|
description: Print labels using ZPL2 and Ruby
|
84
100
|
email:
|
85
101
|
- barnabasbulpett@gmail.com
|
102
|
+
- mtking1123@gmail.com
|
103
|
+
- loganagreen95@gmail.com
|
86
104
|
executables: []
|
87
105
|
extensions: []
|
88
106
|
extra_rdoc_files: []
|
89
107
|
files:
|
90
108
|
- ".gitignore"
|
91
109
|
- ".rspec"
|
110
|
+
- CHANGELOG.md
|
111
|
+
- CONTRIBUTING.md
|
92
112
|
- Gemfile
|
93
113
|
- Guardfile
|
94
114
|
- LICENSE
|
95
115
|
- LICENSE_ORIGINAL.txt
|
96
116
|
- README.md
|
97
117
|
- Rakefile
|
118
|
+
- docs/example.rb
|
119
|
+
- docs/images/barcode.png
|
120
|
+
- docs/images/datamatrix.png
|
121
|
+
- docs/images/earth.jpg
|
122
|
+
- docs/images/graphics.png
|
123
|
+
- docs/images/image.png
|
124
|
+
- docs/images/image_inverted.png
|
125
|
+
- docs/images/images.png
|
126
|
+
- docs/images/justification.png
|
127
|
+
- docs/images/qrcode.png
|
128
|
+
- docs/images/rotation.png
|
129
|
+
- docs/images/text.png
|
98
130
|
- lib/zebra/print_job.rb
|
99
131
|
- lib/zebra/zpl.rb
|
100
132
|
- lib/zebra/zpl/barcode.rb
|
101
133
|
- lib/zebra/zpl/barcode_type.rb
|
102
134
|
- lib/zebra/zpl/box.rb
|
103
135
|
- lib/zebra/zpl/character_set.rb
|
136
|
+
- lib/zebra/zpl/comment.rb
|
104
137
|
- lib/zebra/zpl/country_code.rb
|
138
|
+
- lib/zebra/zpl/datamatrix.rb
|
105
139
|
- lib/zebra/zpl/font.rb
|
140
|
+
- lib/zebra/zpl/graphic.rb
|
141
|
+
- lib/zebra/zpl/image.rb
|
106
142
|
- lib/zebra/zpl/justification.rb
|
107
143
|
- lib/zebra/zpl/label.rb
|
108
144
|
- lib/zebra/zpl/language.rb
|
109
145
|
- lib/zebra/zpl/multipliers.rb
|
146
|
+
- lib/zebra/zpl/pdf417.rb
|
110
147
|
- lib/zebra/zpl/print_mode.rb
|
111
148
|
- lib/zebra/zpl/printable.rb
|
112
149
|
- lib/zebra/zpl/qrcode.rb
|
@@ -114,12 +151,18 @@ files:
|
|
114
151
|
- lib/zebra/zpl/rotation.rb
|
115
152
|
- lib/zebra/zpl/text.rb
|
116
153
|
- lib/zebra/zpl/version.rb
|
154
|
+
- spec/fixtures/default.jpg
|
117
155
|
- spec/spec_helper.rb
|
118
156
|
- spec/zebra/print_job_spec.rb
|
119
157
|
- spec/zebra/zpl/barcode_spec.rb
|
120
158
|
- spec/zebra/zpl/box_spec.rb
|
121
159
|
- spec/zebra/zpl/character_set_spec.rb
|
160
|
+
- spec/zebra/zpl/comment_spec.rb
|
161
|
+
- spec/zebra/zpl/datamatrix_spec.rb
|
162
|
+
- spec/zebra/zpl/graphics_spec.rb
|
163
|
+
- spec/zebra/zpl/image_spec.rb
|
122
164
|
- spec/zebra/zpl/label_spec.rb
|
165
|
+
- spec/zebra/zpl/pdf417_spec.rb
|
123
166
|
- spec/zebra/zpl/qrcode_spec.rb
|
124
167
|
- spec/zebra/zpl/text_spec.rb
|
125
168
|
- spec/zebra/zpl/zpl_spec.rb
|
@@ -149,12 +192,18 @@ specification_version: 4
|
|
149
192
|
summary: Simple DSL to create labels and send them to a Zebra printer using Ruby,
|
150
193
|
ZPL2 and CUPS
|
151
194
|
test_files:
|
195
|
+
- spec/fixtures/default.jpg
|
152
196
|
- spec/spec_helper.rb
|
153
197
|
- spec/zebra/print_job_spec.rb
|
154
198
|
- spec/zebra/zpl/barcode_spec.rb
|
155
199
|
- spec/zebra/zpl/box_spec.rb
|
156
200
|
- spec/zebra/zpl/character_set_spec.rb
|
201
|
+
- spec/zebra/zpl/comment_spec.rb
|
202
|
+
- spec/zebra/zpl/datamatrix_spec.rb
|
203
|
+
- spec/zebra/zpl/graphics_spec.rb
|
204
|
+
- spec/zebra/zpl/image_spec.rb
|
157
205
|
- spec/zebra/zpl/label_spec.rb
|
206
|
+
- spec/zebra/zpl/pdf417_spec.rb
|
158
207
|
- spec/zebra/zpl/qrcode_spec.rb
|
159
208
|
- spec/zebra/zpl/text_spec.rb
|
160
209
|
- spec/zebra/zpl/zpl_spec.rb
|