zebra_zpl 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +43 -0
- data/README.md +29 -0
- data/Rakefile +27 -0
- data/lib/brainstorming.rb +121 -0
- data/lib/zebra_zpl.rb +9 -0
- data/lib/zebra_zpl/commands.rb +12 -0
- data/lib/zebra_zpl/commands/default_width.rb +18 -0
- data/lib/zebra_zpl/commands/field_origin.rb +17 -0
- data/lib/zebra_zpl/commands/font.rb +76 -0
- data/lib/zebra_zpl/commands/home.rb +17 -0
- data/lib/zebra_zpl/commands/orientation.rb +17 -0
- data/lib/zebra_zpl/commands/print_rate.rb +19 -0
- data/lib/zebra_zpl/commands/quantity.rb +18 -0
- data/lib/zebra_zpl/field.rb +24 -0
- data/lib/zebra_zpl/field_builder.rb +19 -0
- data/lib/zebra_zpl/label.rb +28 -0
- data/lib/zebra_zpl/label_builder.rb +19 -0
- data/lib/zebra_zpl/version.rb +3 -0
- data/spec/field_builder_spec.rb +25 -0
- data/spec/field_spec.rb +30 -0
- data/spec/label_builder_spec.rb +49 -0
- data/spec/label_spec.rb +71 -0
- data/spec/spec_helper.rb +1 -0
- data/zebra_zpl.gemspec +20 -0
- metadata +135 -0
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
zebra_zpl (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
coderay (1.0.5)
|
10
|
+
configatron (2.9.0)
|
11
|
+
yamler (>= 0.1.0)
|
12
|
+
cover_me (1.2.0)
|
13
|
+
configatron
|
14
|
+
hashie
|
15
|
+
diff-lcs (1.1.3)
|
16
|
+
hashie (1.2.0)
|
17
|
+
method_source (0.7.1)
|
18
|
+
pry (0.9.8.4)
|
19
|
+
coderay (~> 1.0.5)
|
20
|
+
method_source (~> 0.7.1)
|
21
|
+
slop (>= 2.4.4, < 3)
|
22
|
+
pry-nav (0.1.0)
|
23
|
+
pry (~> 0.9.8.1)
|
24
|
+
rspec (2.8.0)
|
25
|
+
rspec-core (~> 2.8.0)
|
26
|
+
rspec-expectations (~> 2.8.0)
|
27
|
+
rspec-mocks (~> 2.8.0)
|
28
|
+
rspec-core (2.8.0)
|
29
|
+
rspec-expectations (2.8.0)
|
30
|
+
diff-lcs (~> 1.1.2)
|
31
|
+
rspec-mocks (2.8.0)
|
32
|
+
slop (2.4.4)
|
33
|
+
yamler (0.1.0)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
cover_me
|
40
|
+
pry
|
41
|
+
pry-nav
|
42
|
+
rspec
|
43
|
+
zebra_zpl!
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Zebra ZPL
|
2
|
+
=========
|
3
|
+
|
4
|
+
Writing Zebra ZPL files shouldn't vomit raw ASCII in your code.
|
5
|
+
|
6
|
+
The goal is to provide a DSL for creating these files without mucking about with control codes.
|
7
|
+
|
8
|
+
Example of the desired usage:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
label = ZebraZpl::Label.build do
|
12
|
+
|
13
|
+
orientation :n
|
14
|
+
home [20, 0]
|
15
|
+
default_width 0, 0
|
16
|
+
print_rate :a
|
17
|
+
quantity 4
|
18
|
+
|
19
|
+
field [5, 20] do
|
20
|
+
font :d, height: 60
|
21
|
+
width 1175
|
22
|
+
lines 5
|
23
|
+
data 'Test'
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
label.to_s # => ^XA^FWN^LH20,0^BY0,0^PRA^PQ4^FO5,20^ADN,60^FB1175,5,,^FDTest^FS^XZ
|
29
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
5
|
+
spec.pattern = 'spec/**_spec.rb'
|
6
|
+
spec.rspec_opts = ['--backtrace']
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :cover_me do
|
10
|
+
|
11
|
+
desc 'Generates and opens code coverage report.'
|
12
|
+
task :report do
|
13
|
+
require 'cover_me'
|
14
|
+
CoverMe.complete!
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
task :test do
|
20
|
+
Rake::Task['cover_me:report'].invoke
|
21
|
+
end
|
22
|
+
|
23
|
+
task :spec do
|
24
|
+
Rake::Task['cover_me:report'].invoke
|
25
|
+
end
|
26
|
+
|
27
|
+
task :default => :spec
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# maybe define re-usable stuffs?
|
2
|
+
# font :big_header, size: 12, foo: "D"
|
3
|
+
|
4
|
+
# Meh, if you want to make re-usable stuffs but don't want to
|
5
|
+
# define custom methods like "font", "lines", whatever ... maybe just
|
6
|
+
# define font: "Big Header", size: 12, foo: "D"
|
7
|
+
#
|
8
|
+
# field font: "Big Header" do
|
9
|
+
# font "Big Header"
|
10
|
+
# end
|
11
|
+
|
12
|
+
label do
|
13
|
+
|
14
|
+
orientation :n
|
15
|
+
home 20, 0
|
16
|
+
default_width 0, 0
|
17
|
+
print_rate :a
|
18
|
+
home 0, 0
|
19
|
+
quantity label_quantity
|
20
|
+
|
21
|
+
bar_code origin: [130, 75], type: 3 do
|
22
|
+
height 100
|
23
|
+
data bar_code_a
|
24
|
+
end
|
25
|
+
|
26
|
+
bar_code origin: [920, 2190], :type => :x do
|
27
|
+
orientation :n
|
28
|
+
height 9
|
29
|
+
quality 200
|
30
|
+
data bar_code_b
|
31
|
+
end
|
32
|
+
|
33
|
+
field origin: [75, 250] do
|
34
|
+
font :d, height: 60
|
35
|
+
width 1175
|
36
|
+
lines 5
|
37
|
+
data field_a
|
38
|
+
end
|
39
|
+
|
40
|
+
field origin: [75, 850] do
|
41
|
+
font :d, height: 60
|
42
|
+
data field_b
|
43
|
+
end
|
44
|
+
|
45
|
+
field origin: [75, 1050] do
|
46
|
+
font :d, height: 60
|
47
|
+
data field_c
|
48
|
+
end
|
49
|
+
|
50
|
+
field origin: [75, 1200] do
|
51
|
+
font name: 'D', height: 25
|
52
|
+
width 1100
|
53
|
+
lines 6
|
54
|
+
data field_d
|
55
|
+
end
|
56
|
+
|
57
|
+
field origin: [995, 1600] do
|
58
|
+
font :d, height: 36
|
59
|
+
orientation :n
|
60
|
+
data field_e
|
61
|
+
end
|
62
|
+
|
63
|
+
field origin: [895, 1600] do
|
64
|
+
font :d, height: 36
|
65
|
+
orientation :n
|
66
|
+
data field_f
|
67
|
+
end
|
68
|
+
|
69
|
+
field origin: [780, 1620] do
|
70
|
+
font :d, height: 36
|
71
|
+
orientation :n
|
72
|
+
data field_g
|
73
|
+
end
|
74
|
+
|
75
|
+
field origin: [660, 1620] do
|
76
|
+
font :d, height: 36
|
77
|
+
orientation :n
|
78
|
+
data field_h
|
79
|
+
end
|
80
|
+
|
81
|
+
field origin: [565, 1620] do
|
82
|
+
orientation :r
|
83
|
+
data field_i
|
84
|
+
end
|
85
|
+
|
86
|
+
field origin: [515, 1620] do
|
87
|
+
orientation :r
|
88
|
+
data field_j
|
89
|
+
end
|
90
|
+
|
91
|
+
field origin: [465, 1620] do
|
92
|
+
orientation :r
|
93
|
+
data field_k
|
94
|
+
end
|
95
|
+
|
96
|
+
field origin: [415, 1620] do
|
97
|
+
orientation :r
|
98
|
+
data field_l
|
99
|
+
end
|
100
|
+
|
101
|
+
field origin: [325, 1620] do
|
102
|
+
orientation :r
|
103
|
+
data field_m
|
104
|
+
end
|
105
|
+
|
106
|
+
field origin: [275, 1620] do
|
107
|
+
orientation :r
|
108
|
+
data field_n
|
109
|
+
end
|
110
|
+
|
111
|
+
field origin: [225, 1620] do
|
112
|
+
orientation :r
|
113
|
+
data field_o
|
114
|
+
end
|
115
|
+
|
116
|
+
field origin: [175, 1620] do
|
117
|
+
orientation :r
|
118
|
+
data field_p
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
data/lib/zebra_zpl.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module ZebraZpl::Commands::DefaultWidth
|
2
|
+
|
3
|
+
COMMAND = '^BY'
|
4
|
+
|
5
|
+
def self.included base
|
6
|
+
base.send :include, InstanceMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
|
11
|
+
def default_width= width, ratio = nil, height = nil
|
12
|
+
params = [width, ratio, height].compact
|
13
|
+
@data << "#{ COMMAND }#{ params.join ',' }"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ZebraZpl::Commands::FieldOrigin
|
2
|
+
|
3
|
+
COMMAND = '^FO'
|
4
|
+
|
5
|
+
def self.included base
|
6
|
+
base.send :include, InstanceMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
|
11
|
+
def origin= point
|
12
|
+
@data << "#{ COMMAND }#{ point.join ',' }"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# <b>^A - Scalable/Bitmapped Font</b>
|
2
|
+
#
|
3
|
+
# The ^A command specifies the font to use in a textfield. ^A designates the font
|
4
|
+
# for the current ^FD statement or field. The font specified by ^A is used only once
|
5
|
+
# for that ^FD entry. If a value for ^A is not specified again, the default ^CF font
|
6
|
+
# is used for the next ^FD entry.
|
7
|
+
#
|
8
|
+
# *Format*
|
9
|
+
#
|
10
|
+
# ^Afo,h,w
|
11
|
+
#
|
12
|
+
# Parameter f is required. If f is omitted it defaults to the last value of the ^CF
|
13
|
+
# command.
|
14
|
+
#
|
15
|
+
# <b>f = font name</b>
|
16
|
+
# - Accepted Values: A through Z, and 0 to 9
|
17
|
+
#
|
18
|
+
# <b>o = field orientation</b>
|
19
|
+
# - Default Value: the last accepted ^FW value or the ^FW default
|
20
|
+
# - Accepted Values:
|
21
|
+
# - *N* normal
|
22
|
+
# - *R* rotated 90 degrees (clockwise)
|
23
|
+
# - *I* inverted 180 degrees
|
24
|
+
# - *B* read from bottom up, 270 degrees
|
25
|
+
#
|
26
|
+
# <b>h = character height (in dots)</b>
|
27
|
+
# - Default Value: last accepted ^CF
|
28
|
+
# - Scalable
|
29
|
+
# - Accepted Values: 10 to 32000
|
30
|
+
# - Bitmapped
|
31
|
+
# - Accepted Values: multiples of height from 1 to 10 times the standard height, in increments of 1
|
32
|
+
#
|
33
|
+
# <b>w = width (in dots)</b>
|
34
|
+
# - Default Value: last accepted ^CF
|
35
|
+
# - Scalable
|
36
|
+
# - Accepted Values: 10 to 32000
|
37
|
+
# - Bitmapped
|
38
|
+
# - Accepted Values: multiples of width from 1 to 10 times the standard width, in increments of 1
|
39
|
+
#
|
40
|
+
# _Notes_
|
41
|
+
#
|
42
|
+
# Fonts are built using a matrix that defines standard height-to-width ratios. If you
|
43
|
+
# specify only the height or width value standard matrix for that font automatically
|
44
|
+
# determines the other value. If the value is not given or a 0 (zero) is entered,
|
45
|
+
# the height or width is determined by the standard font matrix.
|
46
|
+
module ZebraZpl::Commands::Font
|
47
|
+
|
48
|
+
COMMAND = '^A'
|
49
|
+
|
50
|
+
# Builder Usage:
|
51
|
+
# ZebraZpl::Field.build { font :a }
|
52
|
+
# ZebraZpl::Field.build { font :b, :orientation => :n }
|
53
|
+
# ZebraZpl::Field.build { font :c, height: 30 }
|
54
|
+
# ZebraZpl::Field.build { font :d, height: 15, width: 20 }
|
55
|
+
# ZebraZpl::Field.build { font :e, :orientation => :r, height: 15, width: 20 }
|
56
|
+
#
|
57
|
+
# Field Usage:
|
58
|
+
# f = ZebraZpl::Field.new
|
59
|
+
# f.font = :a
|
60
|
+
# f.font = :b, :orientation => :n
|
61
|
+
# f.font = :c, height: 30
|
62
|
+
# f.font = :d, height: 15, width: 20
|
63
|
+
# f.font = :e, :orientation => :r, height: 15, width: 20
|
64
|
+
def font= *args
|
65
|
+
name, options = args
|
66
|
+
options ||= {}
|
67
|
+
|
68
|
+
params = [options[:height], options[:width]]
|
69
|
+
|
70
|
+
data = "#{ COMMAND }#{ name }#{ options[:orientation] }".upcase
|
71
|
+
data += ",#{ params.join ',' }" if params.any?
|
72
|
+
|
73
|
+
@data << data
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ZebraZpl::Commands::Orientation
|
2
|
+
|
3
|
+
COMMAND = '^FW'
|
4
|
+
|
5
|
+
def self.included base
|
6
|
+
base.send :include, InstanceMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
|
11
|
+
def orientation= rotation
|
12
|
+
@data << "#{ COMMAND }#{ rotation.to_s.upcase }"
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ZebraZpl::Commands::PrintRate
|
2
|
+
|
3
|
+
COMMAND = '^PR'
|
4
|
+
|
5
|
+
def self.included base
|
6
|
+
base.send :include, InstanceMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
|
11
|
+
def print_rate= print_speed, slew_speed = nil, backfeed_speed = nil
|
12
|
+
rate = print_speed.to_s.upcase
|
13
|
+
params = [rate, slew_speed, backfeed_speed].compact
|
14
|
+
@data << "#{ COMMAND }#{ params.join ',' }"
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ZebraZpl::Commands::Quantity
|
2
|
+
|
3
|
+
COMMAND = '^PQ'
|
4
|
+
|
5
|
+
def self.included base
|
6
|
+
base.send :include, InstanceMethods
|
7
|
+
end
|
8
|
+
|
9
|
+
module InstanceMethods
|
10
|
+
|
11
|
+
def quantity= quantity, pause = nil, replicates = nil, override = nil
|
12
|
+
params = [quantity, pause, replicates, override].compact
|
13
|
+
@data << "#{ COMMAND }#{ params.join ',' }"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class ZebraZpl::Field
|
2
|
+
|
3
|
+
include ZebraZpl::Commands::FieldOrigin
|
4
|
+
include ZebraZpl::Commands::Font
|
5
|
+
|
6
|
+
attr_accessor :data
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@data = []
|
10
|
+
end
|
11
|
+
|
12
|
+
SUFFIX = '^FS'
|
13
|
+
|
14
|
+
def self.build &block
|
15
|
+
builder = ZebraZpl::FieldBuilder.new
|
16
|
+
builder.instance_eval &block
|
17
|
+
builder.field
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
"#{ data.join '' }#{ SUFFIX }"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class ZebraZpl::FieldBuilder
|
2
|
+
|
3
|
+
attr_accessor :field
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@field = ZebraZpl::Field.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing name, *args
|
10
|
+
return super unless field.respond_to? "#{ name }="
|
11
|
+
|
12
|
+
self.class.send :define_method, "#{ name }" do |*args|
|
13
|
+
field.send "#{ name }=", *args
|
14
|
+
end
|
15
|
+
|
16
|
+
send "#{ name }", *args
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class ZebraZpl::Label
|
2
|
+
|
3
|
+
include ZebraZpl::Commands::DefaultWidth
|
4
|
+
include ZebraZpl::Commands::Home
|
5
|
+
include ZebraZpl::Commands::Orientation
|
6
|
+
include ZebraZpl::Commands::PrintRate
|
7
|
+
include ZebraZpl::Commands::Quantity
|
8
|
+
|
9
|
+
attr_accessor :data
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@data = []
|
13
|
+
end
|
14
|
+
|
15
|
+
PREFIX = '^XA'
|
16
|
+
SUFFIX = '^XZ'
|
17
|
+
|
18
|
+
def self.build &block
|
19
|
+
builder = ZebraZpl::LabelBuilder.new
|
20
|
+
builder.instance_eval &block
|
21
|
+
builder.label
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_s
|
25
|
+
"#{ PREFIX }#{ data.join '' }#{ SUFFIX }"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class ZebraZpl::LabelBuilder
|
2
|
+
|
3
|
+
attr_accessor :label
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@label = ZebraZpl::Label.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def method_missing name, *args
|
10
|
+
return super unless label.respond_to? "#{ name }="
|
11
|
+
|
12
|
+
self.class.send :define_method, "#{ name }" do |*args|
|
13
|
+
label.send "#{ name }=", *args
|
14
|
+
end
|
15
|
+
|
16
|
+
send "#{ name }", *args
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZebraZpl::FieldBuilder do
|
4
|
+
|
5
|
+
it 'returns a field' do
|
6
|
+
ZebraZpl::Field.build {}.should be_a(ZebraZpl::Field)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#default_width' do
|
10
|
+
|
11
|
+
it 'adds an Field Origin to the field' do
|
12
|
+
ZebraZpl::Field.build { origin [46, 2] }.to_s.should =~ /\^FO46,2/
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'adds a Scalable/Bitmapped Font to the field' do
|
16
|
+
ZebraZpl::Field.build { font :a }.to_s.should =~ /\^AA/
|
17
|
+
ZebraZpl::Field.build { font :b, :orientation => :n }.to_s.should =~ /\^ABN/
|
18
|
+
ZebraZpl::Field.build { font :c, height: 30 }.to_s.should =~ /\^AC,30/
|
19
|
+
ZebraZpl::Field.build { font :d, height: 15, width: 20 }.to_s.should =~ /\^AD,15,20/
|
20
|
+
ZebraZpl::Field.build { font :e, :orientation => :r, height: 15, width: 20 }.to_s.should =~ /\^AER,15,20/
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/spec/field_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZebraZpl::Field do
|
4
|
+
|
5
|
+
describe 'constants' do
|
6
|
+
|
7
|
+
it 'SUFFIX' do
|
8
|
+
ZebraZpl::Field::SUFFIX.should == '^FS'
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'commands' do
|
14
|
+
|
15
|
+
let(:field) { ZebraZpl::Field.new }
|
16
|
+
|
17
|
+
describe '#origin=' do
|
18
|
+
|
19
|
+
it 'adds an Field Origin to the field' do
|
20
|
+
field.origin = [46, 2]
|
21
|
+
field.data.should include('^FO46,2')
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
its(:to_s) { should =~ /\^FS$/ }
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZebraZpl::LabelBuilder do
|
4
|
+
|
5
|
+
it 'returns a label' do
|
6
|
+
ZebraZpl::Label.build {}.should be_a(ZebraZpl::Label)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#default_width' do
|
10
|
+
|
11
|
+
it 'adds an Bar Code Field Default to the label' do
|
12
|
+
ZebraZpl::Label.build { default_width 3 }.to_s.should =~ /\^BY3/
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#home' do
|
18
|
+
|
19
|
+
it 'adds a Label Home command to the label' do
|
20
|
+
ZebraZpl::Label.build { home [5, 10] }.to_s.should =~ /\^LH5,10/
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#orientation' do
|
26
|
+
|
27
|
+
it 'adds a Field Orientation command to the label' do
|
28
|
+
ZebraZpl::Label.build { orientation :n }.to_s.should =~ /\^FWN/
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#print_rate' do
|
34
|
+
|
35
|
+
it 'adds an Bar Code Field Default to the label' do
|
36
|
+
ZebraZpl::Label.build { print_rate :a }.to_s.should =~ /\^PRA/
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#quantity' do
|
42
|
+
|
43
|
+
it 'adds an Bar Code Field Default to the label' do
|
44
|
+
ZebraZpl::Label.build { quantity 4 }.to_s.should =~ /\^PQ4/
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/spec/label_spec.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZebraZpl::Label do
|
4
|
+
|
5
|
+
describe 'constants' do
|
6
|
+
|
7
|
+
it 'PREFIX' do
|
8
|
+
ZebraZpl::Label::PREFIX.should == '^XA'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'SUFFIX' do
|
12
|
+
ZebraZpl::Label::SUFFIX.should == '^XZ'
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'commands' do
|
18
|
+
|
19
|
+
let(:label) { ZebraZpl::Label.new }
|
20
|
+
|
21
|
+
describe '#default_width=' do
|
22
|
+
|
23
|
+
it 'adds an Bar Code Field Default to the label' do
|
24
|
+
label.default_width = 3
|
25
|
+
label.data.should include('^BY3')
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#home=' do
|
31
|
+
|
32
|
+
it 'adds a Label Home command to the label' do
|
33
|
+
label.home = [5, 10]
|
34
|
+
label.data.should include('^LH5,10')
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#orientation=' do
|
40
|
+
|
41
|
+
it 'adds a Field Orientation command to the label' do
|
42
|
+
label.orientation = :n
|
43
|
+
label.data.should include('^FWN')
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#print_rate=' do
|
49
|
+
|
50
|
+
it 'adds an Bar Code Field Default to the label' do
|
51
|
+
label.print_rate = :a
|
52
|
+
label.data.should include('^PRA')
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#quantity=' do
|
58
|
+
|
59
|
+
it 'adds an Bar Code Field Default to the label' do
|
60
|
+
label.quantity = 4
|
61
|
+
label.data.should include('^PQ4')
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
its(:to_s) { should =~ /^\^XA/ }
|
69
|
+
its(:to_s) { should =~ /\^XZ$/ }
|
70
|
+
|
71
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
%w[ cover_me zebra_zpl pry pry-nav ].each { |lib| require lib }
|
data/zebra_zpl.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'zebra_zpl/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'zebra_zpl'
|
7
|
+
s.version = ZebraZpl::VERSION
|
8
|
+
s.authors = ['BM5k']
|
9
|
+
s.email = ['me@bm5k.com']
|
10
|
+
s.homepage = ''
|
11
|
+
s.summary = 'Create Zebra labels'
|
12
|
+
s.description = 'Use ruby to describe labels, fields, and barcodes for printing via ZPL II.'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename f }
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
|
19
|
+
%w[ cover_me zebra_zpl rspec pry pry-nav ].each { |lib| s.add_development_dependency lib }
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zebra_zpl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- BM5k
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cover_me
|
16
|
+
requirement: &70227107456120 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70227107456120
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: zebra_zpl
|
27
|
+
requirement: &70227107455700 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70227107455700
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70227107455300 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70227107455300
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: pry
|
49
|
+
requirement: &70227107454880 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70227107454880
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: pry-nav
|
60
|
+
requirement: &70227107454440 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70227107454440
|
69
|
+
description: Use ruby to describe labels, fields, and barcodes for printing via ZPL
|
70
|
+
II.
|
71
|
+
email:
|
72
|
+
- me@bm5k.com
|
73
|
+
executables: []
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .rspec
|
79
|
+
- .travis.yml
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- README.md
|
83
|
+
- Rakefile
|
84
|
+
- lib/brainstorming.rb
|
85
|
+
- lib/zebra_zpl.rb
|
86
|
+
- lib/zebra_zpl/commands.rb
|
87
|
+
- lib/zebra_zpl/commands/default_width.rb
|
88
|
+
- lib/zebra_zpl/commands/field_origin.rb
|
89
|
+
- lib/zebra_zpl/commands/font.rb
|
90
|
+
- lib/zebra_zpl/commands/home.rb
|
91
|
+
- lib/zebra_zpl/commands/orientation.rb
|
92
|
+
- lib/zebra_zpl/commands/print_rate.rb
|
93
|
+
- lib/zebra_zpl/commands/quantity.rb
|
94
|
+
- lib/zebra_zpl/field.rb
|
95
|
+
- lib/zebra_zpl/field_builder.rb
|
96
|
+
- lib/zebra_zpl/label.rb
|
97
|
+
- lib/zebra_zpl/label_builder.rb
|
98
|
+
- lib/zebra_zpl/version.rb
|
99
|
+
- spec/field_builder_spec.rb
|
100
|
+
- spec/field_spec.rb
|
101
|
+
- spec/label_builder_spec.rb
|
102
|
+
- spec/label_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
- zebra_zpl.gemspec
|
105
|
+
homepage: ''
|
106
|
+
licenses: []
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
none: false
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
none: false
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 1.8.15
|
126
|
+
signing_key:
|
127
|
+
specification_version: 3
|
128
|
+
summary: Create Zebra labels
|
129
|
+
test_files:
|
130
|
+
- spec/field_builder_spec.rb
|
131
|
+
- spec/field_spec.rb
|
132
|
+
- spec/label_builder_spec.rb
|
133
|
+
- spec/label_spec.rb
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
has_rdoc:
|