zebra_printer 0.1.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48aadaaf59b479fae8f2bbf2861d3687464eae1a
4
- data.tar.gz: fffd73dc769091d64e930c2d30fda5a22e7225de
3
+ metadata.gz: 88506f2ad5dd58623bf478d6fa4ccd62663e971a
4
+ data.tar.gz: 6586972601d3469f9253a9c344c87279f33ead83
5
5
  SHA512:
6
- metadata.gz: 5282e7753f3aa9365df4ecd75b37590fbaf93e93b618510e18e6d2031bd2019ba0d1ef1220b3d2c215c4652db4d794f686d0c8216b5b631b81ccbb936f1dcbeb
7
- data.tar.gz: 079135e2935d70dca3f6966aeb350bb7d378fe72c140b54088e265f49a39348f03c6d7d1bf97eb60e884b085adff5805a3b9c1f7644ee27e160701232b9e0dc8
6
+ metadata.gz: 4c77df4afffb1ed107d2c1c10cfc5559d0150ebcff80a0a4f9a3aa5c3f161011559e386758e28bc6628fba085cb2c81f62ebb2607bc6a888192b0d1310fac973
7
+ data.tar.gz: c818eeca82ddd1ba87242c30c9cca72314e15782fa53dd654b06192cef1e631f250560e50edddd1f1d465270fe85f1450eba60054ad2bd9590e438f099768fed
data/.travis.yml CHANGED
@@ -1,6 +1,4 @@
1
1
  language: ruby
2
- rvm:
3
- - "1.9.3"
4
- - jruby-19mode # JRuby in 1.9 mode
5
2
  env:
6
3
  - CODECLIMATE_REPO_TOKEN=07fea6737a63337c1660478cbea662db2d022e156f5889a75a63c230448e567f
4
+ script: bundle exec rspec && bundle exec cucumber
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
4
  # gem "activesupport", ">= 2.3.5"
@@ -6,11 +6,12 @@ source "http://rubygems.org"
6
6
  # Add dependencies to develop your gem here.
7
7
  # Include everything needed to run rake, tests, features, etc.
8
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"
9
+ gem "rspec", "~> 3.7.0"
10
+ gem 'rspec-its'
11
+ gem "rdoc", "~> 6.0.1"
12
+ gem "bundler", "~> 1.6"
13
+ gem "juwelier"
14
+ gem "simplecov", "~> 0.15.1"
14
15
  gem "cucumber"
15
16
  end
16
17
 
data/Gemfile.lock CHANGED
@@ -1,85 +1,114 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
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)
4
+ addressable (2.5.2)
5
+ public_suffix (>= 2.0.2, < 4.0)
6
+ backports (3.11.1)
7
+ builder (3.2.3)
8
+ codeclimate-test-reporter (1.0.7)
9
+ simplecov
10
+ cucumber (3.1.0)
9
11
  builder (>= 2.1.2)
10
- diff-lcs (>= 1.1.3)
11
- gherkin (~> 2.12)
12
+ cucumber-core (~> 3.1.0)
13
+ cucumber-expressions (~> 5.0.4)
14
+ cucumber-wire (~> 0.0.1)
15
+ diff-lcs (~> 1.3)
16
+ gherkin (~> 5.0)
12
17
  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
+ multi_test (>= 0.1.2)
19
+ cucumber-core (3.1.0)
20
+ backports (>= 3.8.0)
21
+ cucumber-tag_expressions (~> 1.1.0)
22
+ gherkin (>= 5.0.0)
23
+ cucumber-expressions (5.0.13)
24
+ cucumber-tag_expressions (1.1.1)
25
+ cucumber-wire (0.0.1)
26
+ descendants_tracker (0.0.4)
27
+ thread_safe (~> 0.3, >= 0.3.1)
28
+ diff-lcs (1.3)
29
+ docile (1.1.5)
30
+ faraday (0.12.2)
18
31
  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)
32
+ gherkin (5.0.0)
33
+ git (1.3.0)
34
+ github_api (0.18.2)
35
+ addressable (~> 2.4)
36
+ descendants_tracker (~> 0.0.4)
37
+ faraday (~> 0.8)
38
+ hashie (~> 3.5, >= 3.5.2)
39
+ oauth2 (~> 1.0)
40
+ hashie (3.5.7)
41
+ highline (1.7.10)
42
+ json (2.1.0)
43
+ juwelier (2.4.9)
33
44
  builder
34
- bundler (>= 1.0)
35
- git (>= 1.2.5)
45
+ bundler
46
+ git
36
47
  github_api
37
- highline (>= 1.6.15)
38
- nokogiri (>= 1.5.10)
48
+ highline
49
+ kamelcase (~> 0)
50
+ nokogiri
51
+ psych
39
52
  rake
40
53
  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)
54
+ semver2
55
+ jwt (1.5.6)
56
+ kamelcase (0.0.2)
57
+ semver2 (~> 3)
58
+ mini_portile2 (2.3.0)
59
+ multi_json (1.13.1)
60
+ multi_test (0.1.2)
61
+ multi_xml (0.6.0)
48
62
  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)
63
+ nokogiri (1.8.2)
64
+ mini_portile2 (~> 2.3.0)
65
+ oauth2 (1.4.0)
66
+ faraday (>= 0.8, < 0.13)
67
+ jwt (~> 1.0)
54
68
  multi_json (~> 1.3)
55
69
  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
+ rack (>= 1.2, < 3)
71
+ psych (3.0.2)
72
+ public_suffix (3.0.2)
73
+ rack (2.0.5)
74
+ rake (12.3.1)
75
+ rdoc (6.0.4)
76
+ rspec (3.7.0)
77
+ rspec-core (~> 3.7.0)
78
+ rspec-expectations (~> 3.7.0)
79
+ rspec-mocks (~> 3.7.0)
80
+ rspec-core (3.7.1)
81
+ rspec-support (~> 3.7.0)
82
+ rspec-expectations (3.7.0)
83
+ diff-lcs (>= 1.2.0, < 2.0)
84
+ rspec-support (~> 3.7.0)
85
+ rspec-its (1.2.0)
86
+ rspec-core (>= 3.0.0)
87
+ rspec-expectations (>= 3.0.0)
88
+ rspec-mocks (3.7.0)
89
+ diff-lcs (>= 1.2.0, < 2.0)
90
+ rspec-support (~> 3.7.0)
91
+ rspec-support (3.7.1)
92
+ semver2 (3.4.2)
93
+ simplecov (0.15.1)
70
94
  docile (~> 1.1.0)
71
- multi_json
72
- simplecov-html (~> 0.8.0)
73
- simplecov-html (0.8.0)
95
+ json (>= 1.8, < 3)
96
+ simplecov-html (~> 0.10.0)
97
+ simplecov-html (0.10.2)
98
+ thread_safe (0.3.6)
74
99
 
75
100
  PLATFORMS
76
101
  ruby
77
102
 
78
103
  DEPENDENCIES
79
- bundler (~> 1.0)
104
+ bundler (~> 1.6)
80
105
  codeclimate-test-reporter
81
106
  cucumber
82
- jeweler (~> 2.0.1)
83
- rdoc (~> 3.12)
84
- rspec (~> 2.14.0)
85
- simplecov
107
+ juwelier
108
+ rdoc (~> 6.0.1)
109
+ rspec (~> 3.7.0)
110
+ rspec-its
111
+ simplecov (~> 0.15.1)
112
+
113
+ BUNDLED WITH
114
+ 1.16.1
data/Rakefile CHANGED
@@ -11,8 +11,8 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
  require 'rake'
13
13
 
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
14
+ require 'juwelier'
15
+ Juwelier::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
17
  gem.name = "zebra_printer"
18
18
  gem.homepage = "http://github.com/yatsura/zebra_printer"
@@ -23,7 +23,7 @@ Jeweler::Tasks.new do |gem|
23
23
  gem.authors = ["Paul Mitchell"]
24
24
  # dependencies defined in Gemfile
25
25
  end
26
- Jeweler::RubygemsDotOrgTasks.new
26
+ Juwelier::RubygemsDotOrgTasks.new
27
27
 
28
28
  require 'rspec/core'
29
29
  require 'rspec/core/rake_task'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.8.0
@@ -0,0 +1,43 @@
1
+ Feature: ASCII Text Font
2
+ The DSL support the change of fonts
3
+
4
+ Scenario: Font A Text on ZPL2
5
+ Given a DSL with:
6
+ """ruby
7
+ ZebraPrinterDocument.new do
8
+ language :zpl2
9
+ font(:size => :large, :name => 'A') do
10
+ text ''
11
+ end
12
+ end
13
+ """
14
+ When I execute the DSL
15
+ Then the output should be like "\^AA,N,\d+,\d+"
16
+
17
+ Scenario: Font 0 Text on ZPL2
18
+ Given a DSL with:
19
+ """ruby
20
+ ZebraPrinterDocument.new do
21
+ language :zpl2
22
+ font(:size => :large, :name => '0') do
23
+ text ''
24
+ end
25
+ end
26
+ """
27
+ When I execute the DSL
28
+ Then the output should be like "\^A0,N,\d+,\d+"
29
+
30
+ Scenario: Font A Text on ZPL2 out of order
31
+ Given a DSL with:
32
+ """ruby
33
+ ZebraPrinterDocument.new do
34
+ language :zpl2
35
+ font(:name => 'A') do
36
+ font(:size => :x_large) do
37
+ text ''
38
+ end
39
+ end
40
+ end
41
+ """
42
+ When I execute the DSL
43
+ Then the output should include "^AA,N,60,60"
@@ -28,7 +28,7 @@ Feature: Rotation of ASCII text
28
28
  end
29
29
  """
30
30
  When I execute the DSL
31
- Then the output should be like "\^CF[A-Z]R,\d+,\d+"
31
+ Then the output should be like "A[A-Z0-9],R"
32
32
 
33
33
  Scenario: Late evaluation of rotated text
34
34
  Given code:
@@ -44,5 +44,5 @@ Feature: Rotation of ASCII text
44
44
  a.document
45
45
  """
46
46
  When I execute the code
47
- Then the output should be like "\^CF[A-Z]R,\d+,\d+"
47
+ Then the output should be like "A[A-Z0-9],R"
48
48
 
@@ -41,4 +41,18 @@ Feature: ASCII Text Size
41
41
  end
42
42
  """
43
43
  When I execute the DSL
44
- Then the output should be like "\^CF0N"
44
+ Then the output should be like "\^A[A-Z0-9],N,\d+,\d+"
45
+
46
+ Scenario: Array as size
47
+ Given a DSL with:
48
+ """ruby
49
+ ZebraPrinterDocument.new do
50
+ language :zpl2
51
+ font(:size => [0,160,160]) do
52
+ text ''
53
+ end
54
+ end
55
+ """
56
+ When I execute the DSL
57
+ Then the output should be like "\^A0,N,160,160"
58
+
@@ -57,3 +57,15 @@ Feature: CODE 128 barcode
57
57
  And the output should include "^FO8,16"
58
58
  And the output should include "^FDhello^FS"
59
59
 
60
+ Scenario: Code 128 on ZPL
61
+ Given a DSL with:
62
+ """ruby
63
+ ZebraPrinterDocument.new do
64
+ language :zpl2
65
+ barcode :code_128, 'hello', :height => 100
66
+ end
67
+ """
68
+ When I execute the DSL
69
+ Then the output should include "^BCN,100,Y,N,N"
70
+ And the output should include "^FDhello^FS"
71
+
@@ -15,3 +15,21 @@ Feature: Data
15
15
  """
16
16
  When I execute the DSL
17
17
  Then the output should include "^FDFirst Data^FS"
18
+
19
+ Scenario: Data nested in document
20
+ Given some array data
21
+ And a DSL with:
22
+ """ruby
23
+ ZebraPrinterDocument.new(@data) do
24
+ language :zpl2
25
+ rotate :by_90 do
26
+ font(:name => 'H', :size => :normal) do
27
+ position(730,50) do
28
+ barcode :code_128, data.first.barcode, :height => 100
29
+ end
30
+ end
31
+ end
32
+ end
33
+ """
34
+ When I execute the DSL
35
+ Then the output should include "^FD111111^FS"
@@ -0,0 +1,45 @@
1
+ Feature: Print speed
2
+ The DSL support to change the print spead
3
+ it supports: slow, normal, fast
4
+
5
+ Scenario: Fast speed
6
+ Given a DSL with:
7
+ """ruby
8
+ ZebraPrinterDocument.new do
9
+ language :zpl2
10
+ speed :fast
11
+ font(:size => :large, :name => 'A') do
12
+ text ''
13
+ end
14
+ end
15
+ """
16
+ When I execute the DSL
17
+ Then the output should be like "\^PRC,[A-Z0-9],[A-Z0-9]"
18
+
19
+ Scenario: Normal speed
20
+ Given a DSL with:
21
+ """ruby
22
+ ZebraPrinterDocument.new do
23
+ language :zpl2
24
+ speed :normal
25
+ font(:size => :large, :name => 'A') do
26
+ text ''
27
+ end
28
+ end
29
+ """
30
+ When I execute the DSL
31
+ Then the output should be like "\^PRA,[A-Z0-9],[A-Z0-9]"
32
+
33
+ Scenario: Slow speed
34
+ Given a DSL with:
35
+ """ruby
36
+ ZebraPrinterDocument.new do
37
+ language :zpl2
38
+ speed :slow
39
+ font(:size => :large, :name => 'A') do
40
+ text ''
41
+ end
42
+ end
43
+ """
44
+ When I execute the DSL
45
+ Then the output should be like "\^PR1,[A-Z0-9],[A-Z0-9]"
@@ -8,7 +8,8 @@ require_relative '../utils/array'
8
8
 
9
9
  module Languages
10
10
  class Epl2
11
- def initialize
11
+ def initialize(data=nil)
12
+ @data = data
12
13
  @document = Epl2::Document.new
13
14
  #defaults
14
15
  @font = Epl2::Font.new
@@ -54,12 +55,12 @@ module Languages
54
55
  def barcode(*args)
55
56
  opts = args.extract_options!
56
57
  code,text = args.pop 2
57
-
58
+
58
59
  opts = opts.merge({:font => font,:text =>text})
59
60
  if opts.include? :at
60
61
  opts[:at] = (@position + Epl2::Position.from_array(opts[:at])).to_a
61
62
  end
62
-
63
+
63
64
  b = Epl2::BarcodeFactory.create_barcode code,opts
64
65
  @document << b.render
65
66
  end
@@ -74,5 +75,9 @@ module Languages
74
75
  @position = Epl2::Position[x,y]
75
76
  end
76
77
  end
78
+
79
+ def data
80
+ @data
81
+ end
77
82
  end
78
83
  end
@@ -22,10 +22,11 @@ module Languages
22
22
  @font = opts[:font] || Font.new
23
23
  @human_readable = opts[:human_readable] || "Y"
24
24
  @text = opts[:text] || ""
25
+ @height = opts[:height] || @font.height*2
25
26
  end
26
27
 
27
28
  def render
28
- "^#{@code}#{@font.rotation},#{@font.height*2},#{@human_readable},N,N^FD#{@text}^FS"
29
+ "^#{@code}#{@font.rotation},#{@height},#{@human_readable},N,N^FD#{@text}^FS"
29
30
  end
30
31
  end
31
32
 
@@ -39,7 +40,7 @@ module Languages
39
40
  @code, @symbol_height, @columns_encode, @rows_encode = BarcodeClasses[code_type]
40
41
  @text = opts[:text] || ""
41
42
  end
42
-
43
+
43
44
  def render
44
45
  "^B#{@code}#{@font.rotation},#{@symbol_height},200,#{@columns_encode},#{@rows_encode}^FD#{@text}^FS"
45
46
  end
@@ -2,10 +2,10 @@ module Languages
2
2
  class Zpl2
3
3
  class Font
4
4
  attr_reader :name, :rotation, :height, :width
5
-
5
+
6
6
  def initialize(opts = {})
7
7
  # defaults
8
- @name = opts[:name] || "B"
8
+ @name = opts[:name] || "0"
9
9
  @rotation = opts.include?(:rotation) ? font_rotation(opts[:rotation]) : font_rotation(:by_0)
10
10
  @height = opts[:height] || 15
11
11
  @width = opts[:width] || 12
@@ -18,18 +18,7 @@ module Languages
18
18
  end
19
19
 
20
20
  def font_size(val)
21
- case val
22
- when :normal
23
- ["0",25,25]
24
- when :small
25
- ["0",20,20]
26
- when :large
27
- ["0",40,40]
28
- when :x_large
29
- ["0",60,60]
30
- else
31
- ["0",25,25]
32
- end
21
+ val.is_a?(Array) ? val : name_size(val)
33
22
  end
34
23
 
35
24
  def font_rotation(amount)
@@ -42,10 +31,37 @@ module Languages
42
31
  "B"
43
32
  else
44
33
  "N"
45
- end
34
+ end
35
+ end
36
+ def block!
37
+ @is_block = true
46
38
  end
39
+
47
40
  def render
48
- "^CF#{@name}#{@rotation},#{@height},#{@width}\n"
41
+ "^A#{@name},#{@rotation},#{@height},#{@width}\n#{set_default}"
42
+ end
43
+
44
+ private
45
+ def set_default
46
+ if @is_block
47
+ "^FW#{@rotation}^CF#{@name},#{@height},#{@width}\n"
48
+ else
49
+ ""
50
+ end
51
+ end
52
+ def name_size(val)
53
+ case val
54
+ when :normal
55
+ [self.name,25,25]
56
+ when :small
57
+ [self.name,20,20]
58
+ when :large
59
+ [self.name,40,40]
60
+ when :x_large
61
+ [self.name,60,60]
62
+ else
63
+ [self.name,25,25]
64
+ end
49
65
  end
50
66
  end
51
67
  end
@@ -0,0 +1,27 @@
1
+ module Languages
2
+ class Zpl2
3
+ class MergeFont
4
+ def initialize
5
+ @font_opts = []
6
+ end
7
+
8
+ def add(opts)
9
+ font = Zpl2::Font.new(merge(opts))
10
+ font.block!
11
+ @font_opts.push(opts)
12
+ font
13
+ end
14
+
15
+ def remove
16
+ @font_opts.pop
17
+ Zpl2::Font.new(merge({}))
18
+ end
19
+
20
+ private
21
+ def merge(opts)
22
+ r = @font_opts.reduce({},:merge) || {}
23
+ r.merge(opts)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ module Languages
2
+ class Zpl2
3
+ class Speed
4
+ def initialize(amount)
5
+ set(amount)
6
+ end
7
+
8
+ def render
9
+ "^PR#{@amount},D,A"
10
+ end
11
+ private
12
+ def set(amount)
13
+ @amount = case(amount)
14
+ when :slow
15
+ '1'
16
+ when :normal
17
+ 'A'
18
+ when :fast
19
+ 'C'
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -3,16 +3,21 @@ require_relative 'zpl2/document'
3
3
  require_relative 'zpl2/text'
4
4
  require_relative 'zpl2/position'
5
5
  require_relative 'zpl2/barcode'
6
+ require_relative 'zpl2/merge_font'
7
+ require_relative 'zpl2/speed'
6
8
 
7
9
  module Languages
8
10
  class Zpl2
9
- def initialize
11
+ def initialize(data=nil)
12
+ @data = data
10
13
  @document = Zpl2::Document.new
11
14
  @font = Zpl2::Font.new
15
+ @merge_font = MergeFont.new
12
16
  @position = Zpl2::Position[0,0]
13
17
  @document << @position
18
+ @document << @merge_font.add({:name => 'B', :height => 15, :width => 15})
14
19
  end
15
-
20
+
16
21
  def text(text,opts={})
17
22
  if opts.include? :at
18
23
  @document << (@position + Zpl2::Position.from_array(opts[:at]))
@@ -23,8 +28,10 @@ module Languages
23
28
 
24
29
  def rotate(amount, &block)
25
30
  if block_given?
26
- @document << Zpl2::Font.new(:rotation => amount)
31
+ @font = @merge_font.add({:rotation => amount})
32
+ @document << @font
27
33
  self.instance_eval &block
34
+ @font = @merge_font.remove
28
35
  @document << @font
29
36
  else
30
37
  @font.font_rotation amount
@@ -34,8 +41,10 @@ module Languages
34
41
 
35
42
  def font(opts={},&block)
36
43
  if block_given?
37
- @document << Zpl2::Font.new(opts)
44
+ @font = @merge_font.add(opts)
45
+ @document << @font
38
46
  self.instance_eval &block
47
+ @font = @merge_font.remove
39
48
  @document << @font
40
49
  else
41
50
  @font = Zpl2::Font.new(opts)
@@ -68,7 +77,15 @@ module Languages
68
77
  end
69
78
  @document << @position
70
79
  end
71
-
80
+
81
+ def speed(amount)
82
+ @document << Zpl2::Speed.new(amount)
83
+ end
84
+
85
+ def data
86
+ @data
87
+ end
88
+
72
89
  def document
73
90
  @document.render
74
91
  end
@@ -13,14 +13,14 @@ class ZebraPrinterDocument
13
13
  end
14
14
 
15
15
  def language_processor
16
- @language_processor ||= Languages.const_get(@language.to_s.capitalize).new
16
+ @language_processor ||= Languages.const_get(@language.to_s.capitalize).new data
17
17
  end
18
18
 
19
19
  def process(&block)
20
20
  instance_eval(&block)
21
21
  self
22
22
  end
23
-
23
+
24
24
  def document
25
25
  language_processor.document
26
26
  end
@@ -28,7 +28,7 @@ class ZebraPrinterDocument
28
28
  def data
29
29
  @data
30
30
  end
31
-
31
+
32
32
  def method_missing(method,*args,&block)
33
33
  if language_processor.respond_to? method
34
34
  if block_given?
@@ -2,14 +2,14 @@ require 'spec_helper'
2
2
 
3
3
  describe "Languages support DSL" do
4
4
  context "EPL2" do
5
- [:text, :barcode, :position, :font, :rotate].each do |method|
5
+ [:text, :barcode, :position, :font, :rotate, :data].each do |method|
6
6
  it "##{method.to_s}" do
7
7
  expect(Languages::Epl2.instance_methods).to include(method)
8
8
  end
9
9
  end
10
10
  end
11
11
  context "ZPL2" do
12
- [:text, :barcode, :position, :font, :rotate].each do |method|
12
+ [:text, :barcode, :position, :font, :rotate, :data].each do |method|
13
13
  it "##{method.to_s}" do
14
14
  expect(Languages::Zpl2.instance_methods).to include(method)
15
15
  end
@@ -6,28 +6,36 @@ describe Languages::Zpl2::Font do
6
6
  its(:name) { should eq "0" }
7
7
  its(:rotation) { should eq "N" }
8
8
  its(:height) { should eq 25 }
9
- its(:width) { should eq 25 }
9
+ its(:width) { should eq 25 }
10
10
  end
11
11
  context "#font_size :small" do
12
12
  subject { Languages::Zpl2::Font.new :size => :small}
13
13
  its(:name) { should eq "0" }
14
14
  its(:rotation) { should eq "N" }
15
15
  its(:height) { should eq 20 }
16
- its(:width) { should eq 20 }
16
+ its(:width) { should eq 20 }
17
17
  end
18
18
  context "#font_size :large" do
19
19
  subject { Languages::Zpl2::Font.new :size => :large}
20
20
  its(:name) { should eq "0" }
21
21
  its(:rotation) { should eq "N" }
22
22
  its(:height) { should eq 40 }
23
- its(:width) { should eq 40 }
23
+ its(:width) { should eq 40 }
24
24
  end
25
25
  context "#font_size :x_large" do
26
26
  subject { Languages::Zpl2::Font.new :size => :x_large}
27
27
  its(:name) { should eq "0" }
28
28
  its(:rotation) { should eq "N" }
29
29
  its(:height) { should eq 60 }
30
- its(:width) { should eq 60 }
30
+ its(:width) { should eq 60 }
31
+ end
32
+
33
+ context "#font_size [0,160,160]" do
34
+ subject { Languages::Zpl2::Font.new :size => ["0",160,160]}
35
+ its(:name) { should eq "0" }
36
+ its(:rotation) { should eq "N" }
37
+ its(:height) { should eq 160 }
38
+ its(:width) { should eq 160 }
31
39
  end
32
40
 
33
41
  context "#font_rotation" do
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ describe Languages::Zpl2::Speed do
4
+ context "normal" do
5
+ subject { Languages::Zpl2::Speed.new :normal}
6
+ its(:render) { should start_with("^PRA")}
7
+ end
8
+ context "fast" do
9
+ subject { Languages::Zpl2::Speed.new :fast}
10
+ its(:render) { should start_with("^PRC")}
11
+ end
12
+ context "slow" do
13
+ subject { Languages::Zpl2::Speed.new :slow}
14
+ its(:render) { should start_with("^PR1")}
15
+ end
16
+
17
+ end
@@ -5,7 +5,7 @@ describe ZebraPrinterDocument do
5
5
  before :each do
6
6
  subject.language :epl2
7
7
  end
8
-
8
+
9
9
  it "language_processor is correct" do
10
10
  expect(subject.language_processor).to be_a Languages::Epl2
11
11
  end
@@ -24,7 +24,7 @@ describe ZebraPrinterDocument do
24
24
  before :each do
25
25
  subject.language :zpl2
26
26
  end
27
-
27
+
28
28
  it "language_processor is correct" do
29
29
  expect(subject.language_processor).to be_a Languages::Zpl2
30
30
  end
@@ -37,4 +37,15 @@ describe ZebraPrinterDocument do
37
37
  end
38
38
  end
39
39
  end
40
+
41
+ context "with data" do
42
+ before :each do
43
+ data = { :data_item_1 => 'data_item_1_value' }
44
+ subject = ZebraPrinterDocument.new data
45
+ end
46
+
47
+ it "allows the data access as data" do
48
+ expect(subject).to respond_to :data
49
+ end
50
+ end
40
51
  end
data/spec/spec_helper.rb CHANGED
@@ -1,10 +1,11 @@
1
- require "codeclimate-test-reporter"
2
- CodeClimate::TestReporter.start
1
+ require 'simplecov'
2
+ SimpleCov.start
3
3
 
4
4
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
5
  $LOAD_PATH.unshift(File.dirname(__FILE__))
6
6
 
7
7
  require 'rspec'
8
+ require 'rspec/its'
8
9
  require 'zebra_printer'
9
10
 
10
11
  # Requires supporting files with custom matchers and macros, etc,
@@ -1,19 +1,19 @@
1
- # Generated by jeweler
1
+ # Generated by juwelier
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
3
+ # Instead, edit Juwelier::Tasks in rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: zebra_printer 0.1.1 ruby lib
5
+ # stub: zebra_printer 0.8.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
- s.name = "zebra_printer"
9
- s.version = "0.1.1"
8
+ s.name = "zebra_printer".freeze
9
+ s.version = "0.8.0"
10
10
 
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.require_paths = ["lib"]
13
- s.authors = ["Paul Mitchell"]
14
- s.date = "2014-10-17"
15
- s.description = "This DSL is for zebra printers and support languages ZPLII and EPLII"
16
- s.email = "paul.d.mitchell@ed.ac.uk"
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib".freeze]
13
+ s.authors = ["Paul Mitchell".freeze]
14
+ s.date = "2018-06-07"
15
+ s.description = "This DSL is for zebra printers and support languages ZPLII and EPLII".freeze
16
+ s.email = "paul.d.mitchell@ed.ac.uk".freeze
17
17
  s.extra_rdoc_files = [
18
18
  "LICENSE.txt",
19
19
  "README.rdoc"
@@ -28,6 +28,7 @@ Gem::Specification.new do |s|
28
28
  "README.rdoc",
29
29
  "Rakefile",
30
30
  "VERSION",
31
+ "features/ascii-text-font.feature",
31
32
  "features/ascii-text-rotation.feature",
32
33
  "features/ascii-text-simple.feature",
33
34
  "features/ascii-text-size.feature",
@@ -36,6 +37,7 @@ Gem::Specification.new do |s|
36
37
  "features/data.feature",
37
38
  "features/position-epl2.feature",
38
39
  "features/position-zpl2.feature",
40
+ "features/print-speed.feature",
39
41
  "features/step_definitions/dsl_steps.rb",
40
42
  "features/step_definitions/language_steps.rb",
41
43
  "features/step_definitions/output_steps.rb",
@@ -57,7 +59,9 @@ Gem::Specification.new do |s|
57
59
  "lib/languages/zpl2/barcode.rb",
58
60
  "lib/languages/zpl2/document.rb",
59
61
  "lib/languages/zpl2/font.rb",
62
+ "lib/languages/zpl2/merge_font.rb",
60
63
  "lib/languages/zpl2/position.rb",
64
+ "lib/languages/zpl2/speed.rb",
61
65
  "lib/languages/zpl2/text.rb",
62
66
  "lib/utils/array.rb",
63
67
  "lib/zebra_printer.rb",
@@ -69,51 +73,55 @@ Gem::Specification.new do |s|
69
73
  "spec/lib/languages/epl2/font_spec.rb",
70
74
  "spec/lib/languages/epl2/position_spec.rb",
71
75
  "spec/lib/languages/epl2/text_spec.rb",
72
- "spec/lib/languages/generic/dots.rb",
73
- "spec/lib/languages/generic/millimetres.rb",
76
+ "spec/lib/languages/generic/dots_spec.rb",
77
+ "spec/lib/languages/generic/millimetres_spec.rb",
74
78
  "spec/lib/languages/generic/position_spec.rb",
75
- "spec/lib/languages/languages.rb",
79
+ "spec/lib/languages/languages_spec.rb",
76
80
  "spec/lib/languages/zpl2/barcode1d_spec.rb",
77
81
  "spec/lib/languages/zpl2/barcode2d_spec.rb",
78
82
  "spec/lib/languages/zpl2/barcode_factory_spec.rb",
79
83
  "spec/lib/languages/zpl2/document_spec.rb",
80
84
  "spec/lib/languages/zpl2/font_spec.rb",
81
85
  "spec/lib/languages/zpl2/position_spec.rb",
86
+ "spec/lib/languages/zpl2/speed_spec.rb",
82
87
  "spec/lib/languages/zpl2/text_spec.rb",
83
- "spec/lib/zebra_printer_document.rb",
88
+ "spec/lib/zebra_printer_document_spec.rb",
84
89
  "spec/spec_helper.rb",
85
90
  "zebra_printer.gemspec"
86
91
  ]
87
- s.homepage = "http://github.com/yatsura/zebra_printer"
88
- s.licenses = ["MIT"]
89
- s.rubygems_version = "2.2.2"
90
- s.summary = "Zebra printer DSL"
92
+ s.homepage = "http://github.com/yatsura/zebra_printer".freeze
93
+ s.licenses = ["MIT".freeze]
94
+ s.rubygems_version = "2.5.2.3".freeze
95
+ s.summary = "Zebra printer DSL".freeze
91
96
 
92
97
  if s.respond_to? :specification_version then
93
98
  s.specification_version = 4
94
99
 
95
100
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
96
- s.add_development_dependency(%q<rspec>, ["~> 2.14.0"])
97
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
98
- s.add_development_dependency(%q<bundler>, ["~> 1.0"])
99
- s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
100
- s.add_development_dependency(%q<simplecov>, [">= 0"])
101
- s.add_development_dependency(%q<cucumber>, [">= 0"])
101
+ s.add_development_dependency(%q<rspec>.freeze, ["~> 3.7.0"])
102
+ s.add_development_dependency(%q<rspec-its>.freeze, [">= 0"])
103
+ s.add_development_dependency(%q<rdoc>.freeze, ["~> 6.0.1"])
104
+ s.add_development_dependency(%q<bundler>.freeze, ["~> 1.6"])
105
+ s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
106
+ s.add_development_dependency(%q<simplecov>.freeze, ["~> 0.15.1"])
107
+ s.add_development_dependency(%q<cucumber>.freeze, [">= 0"])
102
108
  else
103
- s.add_dependency(%q<rspec>, ["~> 2.14.0"])
104
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
105
- s.add_dependency(%q<bundler>, ["~> 1.0"])
106
- s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
107
- s.add_dependency(%q<simplecov>, [">= 0"])
108
- s.add_dependency(%q<cucumber>, [">= 0"])
109
+ s.add_dependency(%q<rspec>.freeze, ["~> 3.7.0"])
110
+ s.add_dependency(%q<rspec-its>.freeze, [">= 0"])
111
+ s.add_dependency(%q<rdoc>.freeze, ["~> 6.0.1"])
112
+ s.add_dependency(%q<bundler>.freeze, ["~> 1.6"])
113
+ s.add_dependency(%q<juwelier>.freeze, [">= 0"])
114
+ s.add_dependency(%q<simplecov>.freeze, ["~> 0.15.1"])
115
+ s.add_dependency(%q<cucumber>.freeze, [">= 0"])
109
116
  end
110
117
  else
111
- s.add_dependency(%q<rspec>, ["~> 2.14.0"])
112
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
113
- s.add_dependency(%q<bundler>, ["~> 1.0"])
114
- s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
115
- s.add_dependency(%q<simplecov>, [">= 0"])
116
- s.add_dependency(%q<cucumber>, [">= 0"])
118
+ s.add_dependency(%q<rspec>.freeze, ["~> 3.7.0"])
119
+ s.add_dependency(%q<rspec-its>.freeze, [">= 0"])
120
+ s.add_dependency(%q<rdoc>.freeze, ["~> 6.0.1"])
121
+ s.add_dependency(%q<bundler>.freeze, ["~> 1.6"])
122
+ s.add_dependency(%q<juwelier>.freeze, [">= 0"])
123
+ s.add_dependency(%q<simplecov>.freeze, ["~> 0.15.1"])
124
+ s.add_dependency(%q<cucumber>.freeze, [">= 0"])
117
125
  end
118
126
  end
119
127
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zebra_printer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Mitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-29 00:00:00.000000000 Z
11
+ date: 2018-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,58 +16,58 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.14.0
19
+ version: 3.7.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.14.0
26
+ version: 3.7.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: rdoc
28
+ name: rspec-its
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '3.12'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '3.12'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bundler
42
+ name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.0'
47
+ version: 6.0.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.0'
54
+ version: 6.0.1
55
55
  - !ruby/object:Gem::Dependency
56
- name: jeweler
56
+ name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.0.1
61
+ version: '1.6'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.0.1
68
+ version: '1.6'
69
69
  - !ruby/object:Gem::Dependency
70
- name: simplecov
70
+ name: juwelier
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.15.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.15.1
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: cucumber
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -111,6 +125,7 @@ files:
111
125
  - README.rdoc
112
126
  - Rakefile
113
127
  - VERSION
128
+ - features/ascii-text-font.feature
114
129
  - features/ascii-text-rotation.feature
115
130
  - features/ascii-text-simple.feature
116
131
  - features/ascii-text-size.feature
@@ -119,6 +134,7 @@ files:
119
134
  - features/data.feature
120
135
  - features/position-epl2.feature
121
136
  - features/position-zpl2.feature
137
+ - features/print-speed.feature
122
138
  - features/step_definitions/dsl_steps.rb
123
139
  - features/step_definitions/language_steps.rb
124
140
  - features/step_definitions/output_steps.rb
@@ -140,7 +156,9 @@ files:
140
156
  - lib/languages/zpl2/barcode.rb
141
157
  - lib/languages/zpl2/document.rb
142
158
  - lib/languages/zpl2/font.rb
159
+ - lib/languages/zpl2/merge_font.rb
143
160
  - lib/languages/zpl2/position.rb
161
+ - lib/languages/zpl2/speed.rb
144
162
  - lib/languages/zpl2/text.rb
145
163
  - lib/utils/array.rb
146
164
  - lib/zebra_printer.rb
@@ -152,18 +170,19 @@ files:
152
170
  - spec/lib/languages/epl2/font_spec.rb
153
171
  - spec/lib/languages/epl2/position_spec.rb
154
172
  - spec/lib/languages/epl2/text_spec.rb
155
- - spec/lib/languages/generic/dots.rb
156
- - spec/lib/languages/generic/millimetres.rb
173
+ - spec/lib/languages/generic/dots_spec.rb
174
+ - spec/lib/languages/generic/millimetres_spec.rb
157
175
  - spec/lib/languages/generic/position_spec.rb
158
- - spec/lib/languages/languages.rb
176
+ - spec/lib/languages/languages_spec.rb
159
177
  - spec/lib/languages/zpl2/barcode1d_spec.rb
160
178
  - spec/lib/languages/zpl2/barcode2d_spec.rb
161
179
  - spec/lib/languages/zpl2/barcode_factory_spec.rb
162
180
  - spec/lib/languages/zpl2/document_spec.rb
163
181
  - spec/lib/languages/zpl2/font_spec.rb
164
182
  - spec/lib/languages/zpl2/position_spec.rb
183
+ - spec/lib/languages/zpl2/speed_spec.rb
165
184
  - spec/lib/languages/zpl2/text_spec.rb
166
- - spec/lib/zebra_printer_document.rb
185
+ - spec/lib/zebra_printer_document_spec.rb
167
186
  - spec/spec_helper.rb
168
187
  - zebra_printer.gemspec
169
188
  homepage: http://github.com/yatsura/zebra_printer
@@ -186,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
205
  version: '0'
187
206
  requirements: []
188
207
  rubyforge_project:
189
- rubygems_version: 2.4.6
208
+ rubygems_version: 2.5.2.3
190
209
  signing_key:
191
210
  specification_version: 4
192
211
  summary: Zebra printer DSL