escpos 0.0.7 → 0.0.8

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
  SHA256:
3
- metadata.gz: bebd823020897ffaca8dae65448de8ebdc7ccddc64445be40bc7fb115ce9d414
4
- data.tar.gz: c8042557b8ed30039561aca6400f9d0eb6e1681e1a3e508e163007306d2df05d
3
+ metadata.gz: 8a5a4ab7452b36d984ed17128e3a9b452b54108db7e173b4c0b1dfe4c10dc684
4
+ data.tar.gz: 67f724b2193209f7f4a6cc317f9eae6bfd4b33f346af87c65d48064fdc064926
5
5
  SHA512:
6
- metadata.gz: f70c056ffa76a4b88ed6649565ede35ccbe48286015fee301f09ce32206a222608a49571f9ffcf4c16930843e21528548d3e5492f02fce48bc6051629b466c0a
7
- data.tar.gz: 1031e581f6f227cf973975744d3ddb40bea12c12f697a142f24de61a0d052b15d554004ec01f9a4cbfffa123ab987e8b410436b7d51b5342b7bea6e1cbecb9d6
6
+ metadata.gz: 7c188461fafe8f0a15a5291fa9d59b1958e1830a314cc75122cd90f840e010dd2a31d6d82546e114c8cda8a5806ae1b2761ecad5cfcceaf6be10129a76e9ccf7
7
+ data.tar.gz: 47fbf1a5a6ae7e064de78f31a74832b7ee8fcb6f72ad67311a5cb3f7590ce547f4a4c3fbb30557cdf972e523ce0aaca85ed1d8eea600077edeea073c1704784b
data/.gitlab-ci.yml CHANGED
@@ -1,4 +1,4 @@
1
- image: ruby:2.5
1
+ image: ruby:2.6
2
2
 
3
3
  cache:
4
4
  paths:
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.0
data/README.md CHANGED
@@ -10,7 +10,7 @@ Add this line to your application's Gemfile:
10
10
  gem 'escpos'
11
11
 
12
12
  # see https://github.com/escpos/escpos-image
13
- gem 'escpos-image' # add this if you want to print PNG images
13
+ gem 'escpos-image' # add this if you want to print images
14
14
  ```
15
15
 
16
16
  And then execute:
@@ -21,6 +21,21 @@ Or install it yourself as:
21
21
 
22
22
  $ gem install escpos
23
23
 
24
+ ## Image support
25
+
26
+ To keep this gem lightweight and modular image support was implemented in another gem:
27
+
28
+ https://github.com/escpos/escpos-image
29
+
30
+ ```ruby
31
+ # Add this line to your application's Gemfile if you want to print images
32
+ gem 'escpos-image'
33
+ ```
34
+ Or install it yourself as:
35
+ ```
36
+ gem install escpos-image
37
+ ```
38
+
24
39
  ## Examples
25
40
 
26
41
  ![](https://github.com/escpos/escpos/blob/master/examples/IMG_20160608_001339_HDR.jpg)
@@ -50,12 +65,17 @@ class MyReport < Escpos::Report
50
65
  @count += 1
51
66
  quad_text "#{@count}. #{text}"
52
67
  end
68
+
69
+ def order
70
+ options[:order]
71
+ end
53
72
  end
54
73
 
55
74
  ```
56
75
 
57
76
  ```erb
58
77
  <% # my_report.erb: %>
78
+ Order number <%= order[:number] %>
59
79
  <%= item "First item" %>
60
80
  <%= item "Second item" %>
61
81
  <%= item "Third item" %>
@@ -64,7 +84,9 @@ end
64
84
  ```ruby
65
85
  # usage:
66
86
 
67
- report = MyReport.new 'path/to/my_report.erb'
87
+ report = MyReport.new 'path/to/my_report.erb', {
88
+ order: { number: 123 }
89
+ }
68
90
  @printer.write report.render
69
91
  @printer.cut!
70
92
  # @printer.to_escpos or @printer.to_base64 contains resulting ESC/POS data
data/examples/report.erb CHANGED
@@ -1,3 +1,9 @@
1
+ Order number <%= order[:number] %>
2
+
1
3
  <%= item "First item" %>
2
4
  <%= item "Second item" %>
3
- <%= item "Third item" %>
5
+ <%= item "Third item" %>
6
+
7
+
8
+
9
+
data/examples/report.rb CHANGED
@@ -6,9 +6,15 @@ class MyReport < Escpos::Report
6
6
  @count += 1
7
7
  quad_text "#{@count}. #{text}"
8
8
  end
9
+
10
+ def order
11
+ options[:order]
12
+ end
9
13
  end
10
14
 
11
- report = MyReport.new File.join(__dir__, 'report.erb')
15
+ report = MyReport.new File.join(__dir__, 'report.erb'), {
16
+ order: { number: 123 }
17
+ }
12
18
  @printer.write report.render
13
19
  @printer.cut!
14
20
 
data/lib/escpos/report.rb CHANGED
@@ -5,7 +5,10 @@ module Escpos
5
5
  include ERB::Util
6
6
  include Helpers
7
7
 
8
- def initialize(file_or_path, optr = {})
8
+ attr_reader :options
9
+
10
+ def initialize(file_or_path, options = {})
11
+ @options = options
9
12
  if file_or_path.is_a?(String)
10
13
  @template = ERB.new(File.open(file_or_path).read)
11
14
  elsif file_or_path.is_a?(File)
@@ -1,3 +1,3 @@
1
1
  module Escpos
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -1,3 +1,5 @@
1
+ Order number <%= order[:number] %>
2
+
1
3
  <%= item "First item" %>
2
4
  <%= item "Second item" %>
3
5
  <%= item "Third item" %>
@@ -13,13 +13,18 @@ class TestReport < Minitest::Test
13
13
  @count += 1
14
14
  quad_text "#{@count}. #{text}"
15
15
  end
16
+ def order
17
+ options[:order]
18
+ end
16
19
  end
17
- report = report_klass.new(File.join(__dir__, '../../fixtures/report.erb'))
20
+ report = report_klass.new File.join(__dir__, '../../fixtures/report.erb'), {
21
+ order: { number: 123 }
22
+ }
18
23
 
19
24
  @printer.write report.render
20
25
  @printer.cut!
21
26
  #pp @printer.to_base64
22
- assert_equal @printer.to_base64, 'G0AbITAxLiBGaXJzdCBpdGVtGyEAChshMDIuIFNlY29uZCBpdGVtGyEAChshMDMuIFRoaXJkIGl0ZW0bIQAKCgoKCh1WAA=='
27
+ assert_equal @printer.to_base64, 'G0BPcmRlciBudW1iZXIgMTIzCgobITAxLiBGaXJzdCBpdGVtGyEAChshMDIuIFNlY29uZCBpdGVtGyEAChshMDMuIFRoaXJkIGl0ZW0bIQAKCgoKCh1WAA=='
23
28
  end
24
29
 
25
30
  end
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: escpos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Svoboda
@@ -63,6 +63,7 @@ extra_rdoc_files: []
63
63
  files:
64
64
  - ".gitignore"
65
65
  - ".gitlab-ci.yml"
66
+ - ".ruby-version"
66
67
  - Gemfile
67
68
  - README.md
68
69
  - Rakefile
@@ -84,6 +85,8 @@ files:
84
85
  - test/fixtures/styles.erb
85
86
  - test/lib/escpos/printer_test.rb
86
87
  - test/lib/escpos/report_test.rb
88
+ - test/results/test_report.txt
89
+ - test/results/test_styles.txt
87
90
  - test/test_helper.rb
88
91
  homepage: https://github.com/escpos/escpos
89
92
  licenses:
@@ -113,4 +116,6 @@ test_files:
113
116
  - test/fixtures/styles.erb
114
117
  - test/lib/escpos/printer_test.rb
115
118
  - test/lib/escpos/report_test.rb
119
+ - test/results/test_report.txt
120
+ - test/results/test_styles.txt
116
121
  - test/test_helper.rb