escpos 0.0.6 → 0.0.7
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 +5 -5
- data/.gitlab-ci.yml +20 -0
- data/Rakefile +7 -1
- data/escpos.gemspec +1 -2
- data/lib/escpos/helpers.rb +14 -4
- data/lib/escpos/printer.rb +3 -3
- data/lib/escpos/version.rb +1 -1
- data/test/lib/escpos/printer_test.rb +3 -2
- data/test/lib/escpos/report_test.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bebd823020897ffaca8dae65448de8ebdc7ccddc64445be40bc7fb115ce9d414
|
4
|
+
data.tar.gz: c8042557b8ed30039561aca6400f9d0eb6e1681e1a3e508e163007306d2df05d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f70c056ffa76a4b88ed6649565ede35ccbe48286015fee301f09ce32206a222608a49571f9ffcf4c16930843e21528548d3e5492f02fce48bc6051629b466c0a
|
7
|
+
data.tar.gz: 1031e581f6f227cf973975744d3ddb40bea12c12f697a142f24de61a0d052b15d554004ec01f9a4cbfffa123ab987e8b410436b7d51b5342b7bea6e1cbecb9d6
|
data/.gitlab-ci.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
image: ruby:2.5
|
2
|
+
|
3
|
+
cache:
|
4
|
+
paths:
|
5
|
+
- vendor/ruby
|
6
|
+
|
7
|
+
stages:
|
8
|
+
- test
|
9
|
+
|
10
|
+
before_script:
|
11
|
+
- ruby -v
|
12
|
+
- bundle -v
|
13
|
+
- bundle install --jobs $(nproc) --path vendor
|
14
|
+
|
15
|
+
test:
|
16
|
+
stage: test
|
17
|
+
script:
|
18
|
+
- bundle exec rake test
|
19
|
+
environment:
|
20
|
+
name: test
|
data/Rakefile
CHANGED
data/escpos.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'escpos/version'
|
@@ -23,5 +22,5 @@ Gem::Specification.new do |spec|
|
|
23
22
|
spec.add_development_dependency "bundler"
|
24
23
|
spec.add_development_dependency "rake"
|
25
24
|
|
26
|
-
spec.add_development_dependency "minitest", "~> 5.4
|
25
|
+
spec.add_development_dependency "minitest", "~> 5.4"
|
27
26
|
end
|
data/lib/escpos/helpers.rb
CHANGED
@@ -145,13 +145,23 @@ module Escpos
|
|
145
145
|
|
146
146
|
def barcode(data, opts = {})
|
147
147
|
text_position = opts.fetch(:text_position, Escpos::BARCODE_TXT_OFF)
|
148
|
-
|
149
|
-
|
148
|
+
possible_text_positions = [
|
149
|
+
Escpos::BARCODE_TXT_OFF,
|
150
|
+
Escpos::BARCODE_TXT_ABV,
|
151
|
+
Escpos::BARCODE_TXT_BLW,
|
152
|
+
Escpos::BARCODE_TXT_BTH
|
153
|
+
]
|
154
|
+
unless possible_text_positions.include?(text_position)
|
155
|
+
raise ArgumentError("Wrong text position.")
|
150
156
|
end
|
151
157
|
height = opts.fetch(:height, 50)
|
152
|
-
|
158
|
+
if height && (height < 1 || height > 255)
|
159
|
+
raise ArgumentError("Height must be in range from 1 to 255.")
|
160
|
+
end
|
153
161
|
width = opts.fetch(:width, 3)
|
154
|
-
|
162
|
+
if width && (width < 2 || width > 6)
|
163
|
+
raise ArgumentError("Width must be in range from 2 to 6.")
|
164
|
+
end
|
155
165
|
[
|
156
166
|
Escpos.sequence(text_position),
|
157
167
|
Escpos.sequence(Escpos::BARCODE_WIDTH),
|
data/lib/escpos/printer.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "base64"
|
2
2
|
|
3
3
|
module Escpos
|
4
|
-
|
5
4
|
class Printer
|
6
5
|
|
7
6
|
def initialize
|
@@ -11,7 +10,8 @@ module Escpos
|
|
11
10
|
end
|
12
11
|
|
13
12
|
def write(data)
|
14
|
-
|
13
|
+
escpos_data = data.respond_to?(:to_escpos) ? data.to_escpos : data
|
14
|
+
@data << escpos_data.force_encoding("ASCII-8BIT")
|
15
15
|
end
|
16
16
|
|
17
17
|
def partial_cut!
|
data/lib/escpos/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative '../../test_helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class PrinterTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
@printer = Escpos::Printer.new
|
6
6
|
end
|
@@ -8,7 +8,8 @@ class TestPrinter < Minitest::Test
|
|
8
8
|
def test_styles
|
9
9
|
require 'erb'
|
10
10
|
template = ERB.new(File.open(File.join(__dir__, '../../fixtures/styles.erb')).read)
|
11
|
-
|
11
|
+
result = template.result(Class.new { include Escpos::Helpers }.new.instance_eval { binding })
|
12
|
+
@printer.write result
|
12
13
|
@printer.cut!
|
13
14
|
#pp @printer.to_base64
|
14
15
|
assert_equal @printer.to_base64, 'G0BVbmZvcm1hdHRlZCB0ZXh0CgobdBYKClVURi04IHRvIElTTy04ODU5LTIgdGV4dDogKOy56Pi+/eHt6fr5KQoKGyEATm9ybWFsIHRleHQbIQAKChshEERvdWJsZSBoZWlnaHQgdGV4dBshAAoKGyEgRG91YmxlIHdpZHRoIHRleHQbIQAKChshMFF1YWQgYXJlYSB0ZXh0GyEACgobLQFVbmRlcmxpbmVkIHRleHQbLQAKChstAlVuZGVybGluZWQgdGV4dCAoMikbLQAKChtFAUJvbGQgdGV4dBtFAAoKG2EATGVmdCBhbGlnbmVkIHRleHQbYQAKChthAlJpZ2h0IGFsaWduZWQgdGV4dBthAAoKG2EBQ2VudGVyZWQgdGV4dBthAAoKG2EAG2EACgodQgFJbnZlcnRlZCBjb2xvciB0ZXh0HUIACgodSAAddwMdaDIdawI4NTk0NDA0MDAwNTcyCgoKCgodVgA='
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: escpos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Svoboda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 5.4
|
47
|
+
version: '5.4'
|
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: 5.4
|
54
|
+
version: '5.4'
|
55
55
|
description: A ruby implementation of ESC/POS (thermal) printer command specification.
|
56
56
|
email:
|
57
57
|
- jan@mluv.cz
|
@@ -62,6 +62,7 @@ extensions: []
|
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
64
|
- ".gitignore"
|
65
|
+
- ".gitlab-ci.yml"
|
65
66
|
- Gemfile
|
66
67
|
- README.md
|
67
68
|
- Rakefile
|
@@ -103,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
104
|
- !ruby/object:Gem::Version
|
104
105
|
version: '0'
|
105
106
|
requirements: []
|
106
|
-
|
107
|
-
rubygems_version: 2.6.4
|
107
|
+
rubygems_version: 3.0.2
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: A ruby implementation of ESC/POS (thermal) printer command specification.
|
@@ -114,4 +114,3 @@ test_files:
|
|
114
114
|
- test/lib/escpos/printer_test.rb
|
115
115
|
- test/lib/escpos/report_test.rb
|
116
116
|
- test/test_helper.rb
|
117
|
-
has_rdoc:
|