escpos 0.0.6 → 0.0.7

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
- SHA1:
3
- metadata.gz: aaf0a44f932f98b9336ef026f2cad0d69834f850
4
- data.tar.gz: 546b34dd03f0153cfdec9b3202a4d4acd8736fab
2
+ SHA256:
3
+ metadata.gz: bebd823020897ffaca8dae65448de8ebdc7ccddc64445be40bc7fb115ce9d414
4
+ data.tar.gz: c8042557b8ed30039561aca6400f9d0eb6e1681e1a3e508e163007306d2df05d
5
5
  SHA512:
6
- metadata.gz: a458bbeb690f35295bcead26715fa87e3f6f19a0d12f9f507d0573807d723d337a7ba3b625690424390e98df0a188b6208258e54433efe4ff39e3a7676a6b53b
7
- data.tar.gz: b5265780d6117b93873d51376ae140a641387f39f85e7e92927791a3b1b1a2cf20c09ca00616428c0912e529871d105c1655a5fbf6039c5a656fdeb49dbe17b4
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
@@ -1,2 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
- task :default => :spec
2
+ require "rake/testtask"
3
+
4
+ task default: :test
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.pattern = "test/**/*_test.rb"
8
+ end
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.2"
25
+ spec.add_development_dependency "minitest", "~> 5.4"
27
26
  end
@@ -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
- unless [Escpos::BARCODE_TXT_OFF, Escpos::BARCODE_TXT_ABV, Escpos::BARCODE_TXT_BLW, Escpos::BARCODE_TXT_BTH].include?(text_position)
149
- raise ArgumentError("Text position must be one of the following: Escpos::BARCODE_TXT_OFF, Escpos::BARCODE_TXT_ABV, Escpos::BARCODE_TXT_BLW, Escpos::BARCODE_TXT_BTH.")
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
- raise ArgumentError("Height must be in range from 1 to 255.") if height && (height < 1 || height > 255)
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
- raise ArgumentError("Width must be in range from 2 to 6.") if width && (width < 2 || width > 6)
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),
@@ -1,7 +1,6 @@
1
- require 'base64'
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
- @data << data
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!
@@ -1,3 +1,3 @@
1
1
  module Escpos
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require_relative '../../test_helper'
2
2
 
3
- class TestPrinter < Minitest::Test
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
- @printer.write template.result(Class.new { include Escpos::Helpers }.new.instance_eval { binding })
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='
@@ -5,7 +5,7 @@ class TestReport < Minitest::Test
5
5
  @printer = Escpos::Printer.new
6
6
  end
7
7
 
8
- def test_styles
8
+ def test_report
9
9
  report_klass = Class.new(Escpos::Report)
10
10
  report_klass.class_eval do
11
11
  def item(text)
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.6
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: 2016-09-03 00:00:00.000000000 Z
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.2
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.2
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
- rubyforge_project:
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: