easyzpl 0.2.1 → 0.2.3
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/easyzpl.gemspec +2 -4
- data/lib/easyzpl/label.rb +6 -8
- data/lib/easyzpl/version.rb +1 -1
- data/spec/easyzpl_spec.rb +36 -36
- metadata +2 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbabe402e3cf1d8f39a7fe870988511f6ebddacd
|
4
|
+
data.tar.gz: 1bb9367bb7746c7ab9317baf7cc675b91ca3877a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4c38d67b19d1c4453ea137ca31934b1aeefd8c98a19ea808042cf2152bdfd75aff421547e4cbc2fe9eeaf93166c16d14259412b64cae0fcbc88c16c48d70941
|
7
|
+
data.tar.gz: bf8bf8dc14e882279a977b05d7f8581e86fd6cfe5669b089e9d160c586a297cf1e622c1e8569217b4325c2c769ad05b4761c7da1d5e651ba7b5eaaeaa3fe036c
|
data/easyzpl.gemspec
CHANGED
@@ -21,9 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
22
|
spec.add_development_dependency 'rake'
|
23
23
|
spec.add_development_dependency 'rspec'
|
24
|
-
# spec.add_development_dependency 'prawn'
|
25
|
-
# spec.add_development_dependency 'barby'
|
26
24
|
|
27
|
-
spec.add_runtime_dependency 'prawn', '>= 1.0.0'
|
28
|
-
spec.add_runtime_dependency 'barby', '>= 0.6.1'
|
25
|
+
spec.add_runtime_dependency 'prawn', '>= 1.0.0'
|
26
|
+
spec.add_runtime_dependency 'barby', '>= 0.6.1'
|
29
27
|
end
|
data/lib/easyzpl/label.rb
CHANGED
@@ -52,19 +52,19 @@ module Easyzpl
|
|
52
52
|
end
|
53
53
|
|
54
54
|
# Draws a square border on dot in width
|
55
|
-
def draw_border(x, y,
|
56
|
-
return unless numeric?(
|
55
|
+
def draw_border(x, y, height, width)
|
56
|
+
return unless numeric?(height) && numeric?(width)
|
57
57
|
x = 0 unless numeric?(x)
|
58
58
|
y = 0 unless numeric?(y)
|
59
59
|
|
60
|
-
label_data.push('^FO' + x.to_s + ',' + y.to_s + '^GB' +
|
60
|
+
label_data.push('^FO' + x.to_s + ',' + y.to_s + '^GB' + height.to_s +
|
61
61
|
',' + width.to_s + ',1^FS')
|
62
62
|
|
63
63
|
# PDF creation if the label height & width has been set
|
64
64
|
return unless label_height && label_width
|
65
65
|
pdf.stroke_axis
|
66
66
|
pdf.stroke do
|
67
|
-
pdf.rectangle [x, y],
|
67
|
+
pdf.rectangle [x, label_width - y - width], height, width * -1
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -78,8 +78,7 @@ module Easyzpl
|
|
78
78
|
'^FD' + text + '^FS')
|
79
79
|
|
80
80
|
return unless label_height && label_width
|
81
|
-
pdf.text_box text, at: [x,
|
82
|
-
Integer(options[:height]) - 1]
|
81
|
+
pdf.text_box text, at: [x, label_width - y]
|
83
82
|
end
|
84
83
|
|
85
84
|
# Prints a bar code in barcode39 font
|
@@ -90,8 +89,7 @@ module Easyzpl
|
|
90
89
|
bar_code_string + '^FS')
|
91
90
|
|
92
91
|
return unless label_height && label_width
|
93
|
-
pdf.bounding_box [x, Integer(
|
94
|
-
50 - 1], width: 100 do
|
92
|
+
pdf.bounding_box [x, Integer(label_width) - y - 40], width: 50 do
|
95
93
|
barcode = Barby::Code39.new(bar_code_string)
|
96
94
|
barcode.annotate_pdf(pdf)
|
97
95
|
end
|
data/lib/easyzpl/version.rb
CHANGED
data/spec/easyzpl_spec.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
describe 'Testing easyzpl Gem' do
|
4
|
+
context 'When creating an empty label' do
|
5
|
+
it 'should output a blank label' do
|
6
|
+
label = Easyzpl::Label.new
|
7
|
+
expect(label.to_s).to eq('^XA^PQ1^XZ')
|
8
|
+
end
|
9
|
+
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
context 'When creating a simple lable' do
|
12
|
+
it 'should output a label with the text "Zebra" and a barcode representation' do
|
13
|
+
label = Easyzpl::Label.new
|
14
|
+
label.home_position(30, 30)
|
15
|
+
label.draw_border(0, 0, 400, 300)
|
16
|
+
label.text_field('ZEBRA', 10, 10)
|
17
|
+
label.bar_code_39('ZEBRA', 10, 30)
|
18
|
+
expect(label.to_s).to eq('^XA^LH30,30^FO0,0^GB400,300,1^FS^FO10,10^AFN,10,10^FDZEBRA^FS^FO10,30^B3N,Y,20,N,N^FDZEBRA^FS^PQ1^XZ')
|
19
|
+
end
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
context 'When creating a stored template' do
|
23
|
+
it 'should output a label template with one variable text field and one variable barcode' do
|
24
|
+
label = Easyzpl::LabelTemplate.new('Template1')
|
25
|
+
label.home_position(30, 30)
|
26
|
+
label.draw_border(0, 0, 400, 300)
|
27
|
+
label.variable_text_field(10, 10)
|
28
|
+
label.variable_bar_code_39(10, 30)
|
29
|
+
expect(label.to_s).to eq('^XA^DFTemplate1^FS^LH30,30^FO0,0^GB400,300,1^FS^FO10,10^FN1^FS^FO10,30^B3N,Y,20,N,N^FN2^FS^PQ1^XZ')
|
30
|
+
end
|
31
|
+
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
context 'When accessing the stored template' do
|
34
|
+
it 'should output a label with only two fields of data that are passed into a saved template' do
|
35
|
+
label = Easyzpl::StoredLabel.new('Template1')
|
36
|
+
label.add_field('ZEBRA')
|
37
|
+
label.add_field('ZEBRA')
|
38
|
+
expect(label.to_s).to eq('^XA^XFTemplate1^FS^FN1^FDZEBRA^FS^FN2^FDZEBRA^FS^PQ1^XZ')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easyzpl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Grigajtis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -59,9 +59,6 @@ dependencies:
|
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.0.0
|
62
|
-
- - ">="
|
63
|
-
- !ruby/object:Gem::Version
|
64
|
-
version: '0'
|
65
62
|
type: :runtime
|
66
63
|
prerelease: false
|
67
64
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -69,9 +66,6 @@ dependencies:
|
|
69
66
|
- - ">="
|
70
67
|
- !ruby/object:Gem::Version
|
71
68
|
version: 1.0.0
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
75
69
|
- !ruby/object:Gem::Dependency
|
76
70
|
name: barby
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -79,9 +73,6 @@ dependencies:
|
|
79
73
|
- - ">="
|
80
74
|
- !ruby/object:Gem::Version
|
81
75
|
version: 0.6.1
|
82
|
-
- - ">="
|
83
|
-
- !ruby/object:Gem::Version
|
84
|
-
version: '0'
|
85
76
|
type: :runtime
|
86
77
|
prerelease: false
|
87
78
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -89,9 +80,6 @@ dependencies:
|
|
89
80
|
- - ">="
|
90
81
|
- !ruby/object:Gem::Version
|
91
82
|
version: 0.6.1
|
92
|
-
- - ">="
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '0'
|
95
83
|
description: This Gem is a wrapper for the ZPL and ZPL 2 languages that are used to
|
96
84
|
build labels for Zebra printers.
|
97
85
|
email:
|