zebra_printer 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +85 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +26 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/features/ascii-text-rotation.feature +48 -0
- data/features/ascii-text-simple.feature +31 -0
- data/features/ascii-text-size.feature +44 -0
- data/features/barcode-code128.feature +59 -0
- data/features/barcode-datamatrix.feature +62 -0
- data/features/data.feature +17 -0
- data/features/position-epl2.feature +59 -0
- data/features/position-zpl2.feature +64 -0
- data/features/step_definitions/dsl_steps.rb +22 -0
- data/features/step_definitions/language_steps.rb +4 -0
- data/features/step_definitions/output_steps.rb +9 -0
- data/features/support/env.rb +1 -0
- data/lib/document_value.rb +4 -0
- data/lib/languages/epl2/barcode.rb +50 -0
- data/lib/languages/epl2/document.rb +27 -0
- data/lib/languages/epl2/font.rb +48 -0
- data/lib/languages/epl2/position.rb +11 -0
- data/lib/languages/epl2/text.rb +27 -0
- data/lib/languages/epl2.rb +78 -0
- data/lib/languages/generic/dots.rb +37 -0
- data/lib/languages/generic/integer.rb +5 -0
- data/lib/languages/generic/millimetres.rb +60 -0
- data/lib/languages/generic/position.rb +64 -0
- data/lib/languages/generic.rb +7 -0
- data/lib/languages/zpl2/barcode.rb +48 -0
- data/lib/languages/zpl2/document.rb +27 -0
- data/lib/languages/zpl2/font.rb +52 -0
- data/lib/languages/zpl2/position.rb +11 -0
- data/lib/languages/zpl2/text.rb +15 -0
- data/lib/languages/zpl2.rb +76 -0
- data/lib/languages.rb +8 -0
- data/lib/utils/array.rb +5 -0
- data/lib/zebra_printer.rb +4 -0
- data/lib/zebra_printer_document.rb +47 -0
- data/spec/lib/languages/epl2/barcode_1d_spec.rb +19 -0
- data/spec/lib/languages/epl2/barcode_2d_spec.rb +11 -0
- data/spec/lib/languages/epl2/barcode_factory_spec.rb +17 -0
- data/spec/lib/languages/epl2/document_spec.rb +23 -0
- data/spec/lib/languages/epl2/font_spec.rb +49 -0
- data/spec/lib/languages/epl2/position_spec.rb +9 -0
- data/spec/lib/languages/epl2/text_spec.rb +17 -0
- data/spec/lib/languages/generic/dots.rb +18 -0
- data/spec/lib/languages/generic/millimetres.rb +36 -0
- data/spec/lib/languages/generic/position_spec.rb +24 -0
- data/spec/lib/languages/languages.rb +18 -0
- data/spec/lib/languages/zpl2/barcode1d_spec.rb +18 -0
- data/spec/lib/languages/zpl2/barcode2d_spec.rb +11 -0
- data/spec/lib/languages/zpl2/barcode_factory_spec.rb +17 -0
- data/spec/lib/languages/zpl2/document_spec.rb +23 -0
- data/spec/lib/languages/zpl2/font_spec.rb +49 -0
- data/spec/lib/languages/zpl2/position_spec.rb +10 -0
- data/spec/lib/languages/zpl2/text_spec.rb +6 -0
- data/spec/lib/zebra_printer_document.rb +40 -0
- data/spec/spec_helper.rb +16 -0
- data/zebra_printer.gemspec +119 -0
- metadata +193 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 48aadaaf59b479fae8f2bbf2861d3687464eae1a
|
4
|
+
data.tar.gz: fffd73dc769091d64e930c2d30fda5a22e7225de
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5282e7753f3aa9365df4ecd75b37590fbaf93e93b618510e18e6d2031bd2019ba0d1ef1220b3d2c215c4652db4d794f686d0c8216b5b631b81ccbb936f1dcbeb
|
7
|
+
data.tar.gz: 079135e2935d70dca3f6966aeb350bb7d378fe72c140b54088e265f49a39348f03c6d7d1bf97eb60e884b085adff5805a3b9c1f7644ee27e160701232b9e0dc8
|
data/.document
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 2.14.0"
|
10
|
+
gem "rdoc", "~> 3.12"
|
11
|
+
gem "bundler", "~> 1.0"
|
12
|
+
gem "jeweler", "~> 2.0.1"
|
13
|
+
gem "simplecov", ">= 0"
|
14
|
+
gem "cucumber"
|
15
|
+
end
|
16
|
+
|
17
|
+
gem "codeclimate-test-reporter", group: :test, require: nil
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.3.6)
|
5
|
+
builder (3.2.2)
|
6
|
+
codeclimate-test-reporter (0.3.0)
|
7
|
+
simplecov (>= 0.7.1, < 1.0.0)
|
8
|
+
cucumber (1.3.13)
|
9
|
+
builder (>= 2.1.2)
|
10
|
+
diff-lcs (>= 1.1.3)
|
11
|
+
gherkin (~> 2.12)
|
12
|
+
multi_json (>= 1.7.5, < 2.0)
|
13
|
+
multi_test (>= 0.1.1)
|
14
|
+
descendants_tracker (0.0.3)
|
15
|
+
diff-lcs (1.2.5)
|
16
|
+
docile (1.1.3)
|
17
|
+
faraday (0.9.0)
|
18
|
+
multipart-post (>= 1.2, < 3)
|
19
|
+
gherkin (2.12.2)
|
20
|
+
multi_json (~> 1.3)
|
21
|
+
git (1.2.6)
|
22
|
+
github_api (0.11.3)
|
23
|
+
addressable (~> 2.3)
|
24
|
+
descendants_tracker (~> 0.0.1)
|
25
|
+
faraday (~> 0.8, < 0.10)
|
26
|
+
hashie (>= 1.2)
|
27
|
+
multi_json (>= 1.7.5, < 2.0)
|
28
|
+
nokogiri (~> 1.6.0)
|
29
|
+
oauth2
|
30
|
+
hashie (2.0.5)
|
31
|
+
highline (1.6.21)
|
32
|
+
jeweler (2.0.1)
|
33
|
+
builder
|
34
|
+
bundler (>= 1.0)
|
35
|
+
git (>= 1.2.5)
|
36
|
+
github_api
|
37
|
+
highline (>= 1.6.15)
|
38
|
+
nokogiri (>= 1.5.10)
|
39
|
+
rake
|
40
|
+
rdoc
|
41
|
+
json (1.8.1)
|
42
|
+
jwt (0.1.11)
|
43
|
+
multi_json (>= 1.5)
|
44
|
+
mini_portile (0.5.3)
|
45
|
+
multi_json (1.9.2)
|
46
|
+
multi_test (0.1.1)
|
47
|
+
multi_xml (0.5.5)
|
48
|
+
multipart-post (2.0.0)
|
49
|
+
nokogiri (1.6.1)
|
50
|
+
mini_portile (~> 0.5.0)
|
51
|
+
oauth2 (0.9.3)
|
52
|
+
faraday (>= 0.8, < 0.10)
|
53
|
+
jwt (~> 0.1.8)
|
54
|
+
multi_json (~> 1.3)
|
55
|
+
multi_xml (~> 0.5)
|
56
|
+
rack (~> 1.2)
|
57
|
+
rack (1.5.2)
|
58
|
+
rake (10.2.1)
|
59
|
+
rdoc (3.12.2)
|
60
|
+
json (~> 1.4)
|
61
|
+
rspec (2.14.1)
|
62
|
+
rspec-core (~> 2.14.0)
|
63
|
+
rspec-expectations (~> 2.14.0)
|
64
|
+
rspec-mocks (~> 2.14.0)
|
65
|
+
rspec-core (2.14.8)
|
66
|
+
rspec-expectations (2.14.5)
|
67
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
68
|
+
rspec-mocks (2.14.6)
|
69
|
+
simplecov (0.8.2)
|
70
|
+
docile (~> 1.1.0)
|
71
|
+
multi_json
|
72
|
+
simplecov-html (~> 0.8.0)
|
73
|
+
simplecov-html (0.8.0)
|
74
|
+
|
75
|
+
PLATFORMS
|
76
|
+
ruby
|
77
|
+
|
78
|
+
DEPENDENCIES
|
79
|
+
bundler (~> 1.0)
|
80
|
+
codeclimate-test-reporter
|
81
|
+
cucumber
|
82
|
+
jeweler (~> 2.0.1)
|
83
|
+
rdoc (~> 3.12)
|
84
|
+
rspec (~> 2.14.0)
|
85
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Paul Mitchell
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
{<img src="https://travis-ci.org/yatsura/zebra_printer.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/yatsura/zebra_printer]
|
2
|
+
{<img src="https://codeclimate.com/github/yatsura/zebra_printer.png" />}[https://codeclimate.com/github/yatsura/zebra_printer]
|
3
|
+
{<img src="https://codeclimate.com/github/yatsura/zebra_printer/coverage.png" />}[https://codeclimate.com/github/yatsura/zebra_printer]
|
4
|
+
= zebra_printer
|
5
|
+
|
6
|
+
A DSL for zebra printers which handles both EPL2 and ZPL2.
|
7
|
+
|
8
|
+
== Documentation
|
9
|
+
|
10
|
+
For just now see the cucumber output at: https://www.relishapp.com/yatsura/zebra-printer/docs
|
11
|
+
|
12
|
+
== Contributing to zebra_printer
|
13
|
+
|
14
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
15
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
16
|
+
* Fork the project.
|
17
|
+
* Start a feature/bugfix branch.
|
18
|
+
* Commit and push until you are happy with your contribution.
|
19
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
20
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
21
|
+
|
22
|
+
== Copyright
|
23
|
+
|
24
|
+
Copyright (c) 2014 Paul Mitchell. See LICENSE.txt for
|
25
|
+
further details.
|
26
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "zebra_printer"
|
18
|
+
gem.homepage = "http://github.com/yatsura/zebra_printer"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Zebra printer DSL}
|
21
|
+
gem.description = %Q{This DSL is for zebra printers and support languages ZPLII and EPLII}
|
22
|
+
gem.email = "paul.d.mitchell@ed.ac.uk"
|
23
|
+
gem.authors = ["Paul Mitchell"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Code coverage detail"
|
35
|
+
task :simplecov do
|
36
|
+
ENV['COVERAGE'] = "true"
|
37
|
+
Rake::Task['spec'].execute
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rdoc/task'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "zebra_printer #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
@@ -0,0 +1,48 @@
|
|
1
|
+
Feature: Rotation of ASCII text
|
2
|
+
|
3
|
+
Text can be rotated by 0,90,180,270 degrees.
|
4
|
+
This will affect all text that comes within the
|
5
|
+
rotation section. The rotation happens clockwise
|
6
|
+
|
7
|
+
Scenario: Rotate text 90 degrees for EPL2
|
8
|
+
Given a DSL with:
|
9
|
+
"""ruby
|
10
|
+
ZebraPrinterDocument.new do
|
11
|
+
language :epl2
|
12
|
+
rotate :by_90 do
|
13
|
+
text ''
|
14
|
+
end
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
When I execute the DSL
|
18
|
+
Then the output should include "A0,0,1,2,1,1,N,"""
|
19
|
+
|
20
|
+
Scenario: Rotate text 90 degrees for ZPL2
|
21
|
+
Given a DSL with:
|
22
|
+
"""ruby
|
23
|
+
ZebraPrinterDocument.new do
|
24
|
+
language :zpl2
|
25
|
+
rotate :by_90 do
|
26
|
+
text ''
|
27
|
+
end
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
When I execute the DSL
|
31
|
+
Then the output should be like "\^CF[A-Z]R,\d+,\d+"
|
32
|
+
|
33
|
+
Scenario: Late evaluation of rotated text
|
34
|
+
Given code:
|
35
|
+
"""ruby
|
36
|
+
a = ZebraPrinterDocument.new
|
37
|
+
a.language :zpl2
|
38
|
+
label = Proc.new do
|
39
|
+
rotate :by_90 do
|
40
|
+
text ''
|
41
|
+
end
|
42
|
+
end
|
43
|
+
a.process(&label)
|
44
|
+
a.document
|
45
|
+
"""
|
46
|
+
When I execute the code
|
47
|
+
Then the output should be like "\^CF[A-Z]R,\d+,\d+"
|
48
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
Feature: Simple ASCII text
|
2
|
+
|
3
|
+
The text option accepts a number of different arguments.
|
4
|
+
The minimum number of arguments is x,y & the text. This
|
5
|
+
will generate a label that has the default rotation, scaling,
|
6
|
+
font, horizntal and vertical multiliers and the image will be
|
7
|
+
number (not reversed)
|
8
|
+
|
9
|
+
Scenario: Basic text only DSL for EPL2
|
10
|
+
Given a DSL with:
|
11
|
+
"""ruby
|
12
|
+
ZebraPrinterDocument.new do
|
13
|
+
language :epl2
|
14
|
+
text ''
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
When I execute the DSL
|
18
|
+
Then the output should include "A0,0,0,2,1,1,N,"""
|
19
|
+
|
20
|
+
Scenario: Basic text only DSL for ZPL2
|
21
|
+
Given a DSL with:
|
22
|
+
"""ruby
|
23
|
+
ZebraPrinterDocument.new do
|
24
|
+
language :zpl2
|
25
|
+
text ''
|
26
|
+
end
|
27
|
+
"""
|
28
|
+
When I execute the DSL
|
29
|
+
Then the output should include "^FO0,0"
|
30
|
+
And the output should include "^FD^FS"
|
31
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
Feature: ASCII Text Size
|
2
|
+
The DSL provides a number of default sizes.
|
3
|
+
Due to the way sizes work across languages
|
4
|
+
size and font have been extracted out. This
|
5
|
+
means that the size will be approximate
|
6
|
+
|
7
|
+
Scenario: Normal Text on EPL2
|
8
|
+
Given a DSL with:
|
9
|
+
"""ruby
|
10
|
+
ZebraPrinterDocument.new do
|
11
|
+
language :epl2
|
12
|
+
font(:size => :normal) do
|
13
|
+
text ''
|
14
|
+
end
|
15
|
+
end
|
16
|
+
"""
|
17
|
+
When I execute the DSL
|
18
|
+
Then the output should be like "A\d,\d,\d,2,1,1,[A-Z]"
|
19
|
+
|
20
|
+
Scenario: Normal Text on EPL2
|
21
|
+
Given a DSL with:
|
22
|
+
"""ruby
|
23
|
+
ZebraPrinterDocument.new do
|
24
|
+
language :epl2
|
25
|
+
font(:size => :large) do
|
26
|
+
text ''
|
27
|
+
end
|
28
|
+
end
|
29
|
+
"""
|
30
|
+
When I execute the DSL
|
31
|
+
Then the output should be like "A\d,\d,\d,3,1,1,[A-Z]"
|
32
|
+
|
33
|
+
Scenario: Normal Text on ZPL2
|
34
|
+
Given a DSL with:
|
35
|
+
"""ruby
|
36
|
+
ZebraPrinterDocument.new do
|
37
|
+
language :zpl2
|
38
|
+
font(:size => :normal) do
|
39
|
+
text ''
|
40
|
+
end
|
41
|
+
end
|
42
|
+
"""
|
43
|
+
When I execute the DSL
|
44
|
+
Then the output should be like "\^CF0N"
|
@@ -0,0 +1,59 @@
|
|
1
|
+
Feature: CODE 128 barcode
|
2
|
+
|
3
|
+
Code 128 is a very high-density barcode symbology.
|
4
|
+
It is used for alphanumeric or numeric-only barcodes.
|
5
|
+
It can encode all 128 characters of ASCII and, by
|
6
|
+
use of an extension character (FNC4), the Latin-1
|
7
|
+
characters defined in ISO/IEC 8859-1
|
8
|
+
|
9
|
+
Code 128 is used on patient labels and tube labels
|
10
|
+
within ECMC
|
11
|
+
|
12
|
+
Scenario: Code 128 on EPL
|
13
|
+
Given a DSL with:
|
14
|
+
"""ruby
|
15
|
+
ZebraPrinterDocument.new do
|
16
|
+
language :epl2
|
17
|
+
barcode :code_128, 'hello', :at => [1,2]
|
18
|
+
end
|
19
|
+
"""
|
20
|
+
When I execute the DSL
|
21
|
+
Then the output should include "B1,2,0,1,2,2,50,B,"hello""
|
22
|
+
|
23
|
+
Scenario: Code 128 on EPL with millimetres
|
24
|
+
Given a DSL with:
|
25
|
+
"""ruby
|
26
|
+
ZebraPrinterDocument.new do
|
27
|
+
language :epl2
|
28
|
+
barcode :code_128, 'hello', :at => [1.mm,2.mm]
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
When I execute the DSL
|
32
|
+
Then the output should include "B8,16,0,1,2,2,50,B,"hello""
|
33
|
+
|
34
|
+
Scenario: Code 128 on ZPL
|
35
|
+
Given a DSL with:
|
36
|
+
"""ruby
|
37
|
+
ZebraPrinterDocument.new do
|
38
|
+
language :zpl2
|
39
|
+
barcode :code_128, 'hello', :at => [1,2]
|
40
|
+
end
|
41
|
+
"""
|
42
|
+
When I execute the DSL
|
43
|
+
Then the output should include "^BCN,30,Y,N,N"
|
44
|
+
And the output should include "^FO1,2"
|
45
|
+
And the output should include "^FDhello^FS"
|
46
|
+
|
47
|
+
Scenario: Code 128 on ZPL
|
48
|
+
Given a DSL with:
|
49
|
+
"""ruby
|
50
|
+
ZebraPrinterDocument.new do
|
51
|
+
language :zpl2
|
52
|
+
barcode :code_128, 'hello', :at => [1.mm,2.mm]
|
53
|
+
end
|
54
|
+
"""
|
55
|
+
When I execute the DSL
|
56
|
+
Then the output should include "^BCN,30,Y,N,N"
|
57
|
+
And the output should include "^FO8,16"
|
58
|
+
And the output should include "^FDhello^FS"
|
59
|
+
|
@@ -0,0 +1,62 @@
|
|
1
|
+
Feature: Data matrix barcode
|
2
|
+
|
3
|
+
A Data Matrix code is a two-dimensional matrix barcode
|
4
|
+
consisting of black and white "cells" or modules
|
5
|
+
arranged in either a square or rectangular pattern. The
|
6
|
+
information to be encoded can be text or numeric data.
|
7
|
+
Usual data size is from a few bytes up to 1556 bytes.
|
8
|
+
|
9
|
+
ECMC Uses data matrix on slides
|
10
|
+
|
11
|
+
Scenario: Data Matrix on EPL2
|
12
|
+
Given a DSL with:
|
13
|
+
"""ruby
|
14
|
+
ZebraPrinterDocument.new do
|
15
|
+
language :epl2
|
16
|
+
barcode :data_matrix, 'hello', :at => [1,2]
|
17
|
+
end
|
18
|
+
"""
|
19
|
+
When I execute the DSL
|
20
|
+
Then the output should include "b1,2,D,c16,r16,"hello""
|
21
|
+
|
22
|
+
Scenario: Data Matrix with offset on EPL2
|
23
|
+
Given a DSL with:
|
24
|
+
"""ruby
|
25
|
+
ZebraPrinterDocument.new do
|
26
|
+
language :epl2
|
27
|
+
position(10,10) do
|
28
|
+
barcode :data_matrix, 'hello', :at => [5,5]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
"""
|
32
|
+
When I execute the DSL
|
33
|
+
Then the output should include "b15,15,D,c16,r16,"hello""
|
34
|
+
|
35
|
+
Scenario: Data Matrix on ZPL2
|
36
|
+
Given a DSL with:
|
37
|
+
"""ruby
|
38
|
+
ZebraPrinterDocument.new do
|
39
|
+
language :zpl2
|
40
|
+
barcode :data_matrix, 'hello', :at => [1,2]
|
41
|
+
end
|
42
|
+
"""
|
43
|
+
When I execute the DSL
|
44
|
+
Then the output should include "^BXN,4,200,16,16"
|
45
|
+
And the output should include "^FDhello^FS"
|
46
|
+
And the output should include "^FO1,2"
|
47
|
+
|
48
|
+
|
49
|
+
Scenario: Data Matrix with offset on ZPL2
|
50
|
+
Given a DSL with:
|
51
|
+
"""ruby
|
52
|
+
ZebraPrinterDocument.new do
|
53
|
+
language :zpl2
|
54
|
+
position(10,10) do
|
55
|
+
barcode :data_matrix, 'hello', :at => [5,5]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
"""
|
59
|
+
When I execute the DSL
|
60
|
+
Then the output should include "^BXN,4,200,16,16"
|
61
|
+
And the output should include "^FDhello^FS"
|
62
|
+
And the output should include "^FO15,15"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Feature: Data
|
2
|
+
|
3
|
+
The DSL needs away of allowing data to be
|
4
|
+
referenced
|
5
|
+
|
6
|
+
|
7
|
+
Scenario: Data given in constructor
|
8
|
+
Given some array data
|
9
|
+
And a DSL with:
|
10
|
+
"""ruby
|
11
|
+
ZebraPrinterDocument.new(@data) do
|
12
|
+
language :zpl2
|
13
|
+
text data.first.text
|
14
|
+
end
|
15
|
+
"""
|
16
|
+
When I execute the DSL
|
17
|
+
Then the output should include "^FDFirst Data^FS"
|
@@ -0,0 +1,59 @@
|
|
1
|
+
Feature: Position in EPL2
|
2
|
+
|
3
|
+
position set the origin for anything with the
|
4
|
+
block or from last call. Any use of the :at
|
5
|
+
option move the location relative to the set
|
6
|
+
position
|
7
|
+
|
8
|
+
Scenario: Position block
|
9
|
+
Given a DSL with:
|
10
|
+
"""ruby
|
11
|
+
ZebraPrinterDocument.new do
|
12
|
+
language :epl2
|
13
|
+
position(12,34) do
|
14
|
+
text ''
|
15
|
+
end
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
When I execute the DSL
|
19
|
+
Then the output should include "A12,34,0,2,1,1,N,"""
|
20
|
+
|
21
|
+
Scenario: Move text relative to position
|
22
|
+
Given a DSL with:
|
23
|
+
"""ruby
|
24
|
+
ZebraPrinterDocument.new do
|
25
|
+
language :epl2
|
26
|
+
position(12,34) do
|
27
|
+
text '', :at => [10,10]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
"""
|
31
|
+
When I execute the DSL
|
32
|
+
Then the output should include "A22,44,0,2,1,1,N,"""
|
33
|
+
|
34
|
+
Scenario: Position block in mm
|
35
|
+
Given a DSL with:
|
36
|
+
"""ruby
|
37
|
+
ZebraPrinterDocument.new do
|
38
|
+
language :epl2
|
39
|
+
position(12.mm,34.mm) do
|
40
|
+
text ''
|
41
|
+
end
|
42
|
+
end
|
43
|
+
"""
|
44
|
+
When I execute the DSL
|
45
|
+
Then the output should include "A96,272,0,2,1,1,N,"""
|
46
|
+
|
47
|
+
Scenario: Move text relative to position in mm
|
48
|
+
Given a DSL with:
|
49
|
+
"""ruby
|
50
|
+
ZebraPrinterDocument.new do
|
51
|
+
language :epl2
|
52
|
+
position(6.mm,17.mm) do
|
53
|
+
text '', :at => [6.mm,17.mm]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
"""
|
57
|
+
When I execute the DSL
|
58
|
+
Then the output should include "A96,272,0,2,1,1,N,"""
|
59
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
Feature: Position
|
2
|
+
|
3
|
+
position set the origin for anything with the
|
4
|
+
block or from last call. Any use of the :at
|
5
|
+
option move the location relative to the set
|
6
|
+
position
|
7
|
+
|
8
|
+
Scenario: Position block ZPL2
|
9
|
+
Given a DSL with:
|
10
|
+
"""ruby
|
11
|
+
ZebraPrinterDocument.new do
|
12
|
+
language :zpl2
|
13
|
+
position(12,34) do
|
14
|
+
text ''
|
15
|
+
end
|
16
|
+
end
|
17
|
+
"""
|
18
|
+
When I execute the DSL
|
19
|
+
Then the output should include "^FO12,34"
|
20
|
+
And the output should include "^FD^FS"
|
21
|
+
|
22
|
+
Scenario: Position block ZPL2
|
23
|
+
Given a DSL with:
|
24
|
+
"""ruby
|
25
|
+
ZebraPrinterDocument.new do
|
26
|
+
language :zpl2
|
27
|
+
position(12,34) do
|
28
|
+
text '', :at => [10,10]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
"""
|
32
|
+
When I execute the DSL
|
33
|
+
Then the output should include "^FO22,44"
|
34
|
+
And the output should include "^FD^FS"
|
35
|
+
|
36
|
+
Scenario: Position block in mm
|
37
|
+
Given a DSL with:
|
38
|
+
"""ruby
|
39
|
+
ZebraPrinterDocument.new do
|
40
|
+
language :zpl2
|
41
|
+
position(12.mm,34.mm) do
|
42
|
+
text ''
|
43
|
+
end
|
44
|
+
end
|
45
|
+
"""
|
46
|
+
When I execute the DSL
|
47
|
+
Then the output should include "^FO96,272"
|
48
|
+
And the output should include "^FD^FS"
|
49
|
+
|
50
|
+
Scenario: Move text relative to position in mm
|
51
|
+
Given a DSL with:
|
52
|
+
"""ruby
|
53
|
+
ZebraPrinterDocument.new do
|
54
|
+
language :zpl2
|
55
|
+
position(6.mm,17.mm) do
|
56
|
+
text '', :at => [6.mm,17.mm]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
"""
|
60
|
+
When I execute the DSL
|
61
|
+
Then the output should include "^FO96,272"
|
62
|
+
And the output should include "^FD^FS"
|
63
|
+
|
64
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
Given(/^some array data$/) do
|
4
|
+
@data = [OpenStruct.new(:text => 'First Data', :barcode => '111111'),OpenStruct.new(:text => 'Last Data', :barcode => '999999')]
|
5
|
+
end
|
6
|
+
|
7
|
+
Given(/^a DSL with:$/) do |string|
|
8
|
+
@dsl = string
|
9
|
+
end
|
10
|
+
|
11
|
+
Given(/^code:$/) do |string|
|
12
|
+
@code = string
|
13
|
+
end
|
14
|
+
When(/^I execute the DSL$/) do
|
15
|
+
@dsl_document = eval @dsl
|
16
|
+
end
|
17
|
+
|
18
|
+
When(/^I execute the code$/) do
|
19
|
+
@document = eval @code
|
20
|
+
end
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Then(/^the output should include "(.*)"$/) do |arg1|
|
2
|
+
@document = @dsl_document.document unless @document
|
3
|
+
@document.should include(arg1)
|
4
|
+
end
|
5
|
+
|
6
|
+
Then(/^the output should be like "(.*?)"$/) do |arg1|
|
7
|
+
@document = @dsl_document.document unless @document
|
8
|
+
@document.should match(Regexp.new(arg1))
|
9
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '../../lib/zebra_printer'
|