escpos 0.0.7 → 0.0.8
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 +4 -4
- data/.gitlab-ci.yml +1 -1
- data/.ruby-version +1 -0
- data/README.md +24 -2
- data/examples/report.erb +7 -1
- data/examples/report.rb +7 -1
- data/lib/escpos/report.rb +4 -1
- data/lib/escpos/version.rb +1 -1
- data/test/fixtures/report.erb +2 -0
- data/test/lib/escpos/report_test.rb +7 -2
- data/test/results/test_report.txt +0 -0
- data/test/results/test_styles.txt +0 -0
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a5a4ab7452b36d984ed17128e3a9b452b54108db7e173b4c0b1dfe4c10dc684
|
4
|
+
data.tar.gz: 67f724b2193209f7f4a6cc317f9eae6bfd4b33f346af87c65d48064fdc064926
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c188461fafe8f0a15a5291fa9d59b1958e1830a314cc75122cd90f840e010dd2a31d6d82546e114c8cda8a5806ae1b2761ecad5cfcceaf6be10129a76e9ccf7
|
7
|
+
data.tar.gz: 47fbf1a5a6ae7e064de78f31a74832b7ee8fcb6f72ad67311a5cb3f7590ce547f4a4c3fbb30557cdf972e523ce0aaca85ed1d8eea600077edeea073c1704784b
|
data/.gitlab-ci.yml
CHANGED
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
|
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
|

|
@@ -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
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
|
-
|
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)
|
data/lib/escpos/version.rb
CHANGED
data/test/fixtures/report.erb
CHANGED
@@ -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
|
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, '
|
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.
|
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
|