thermal 0.1.1 โ 0.2.0
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 +7 -0
- data/LICENSE +21 -20
- data/README.md +200 -27
- data/data/db.yml +1987 -0
- data/data/original.yml +1635 -0
- data/lib/thermal/byte_buffer.rb +48 -0
- data/lib/thermal/db/charset.rb +36 -0
- data/lib/thermal/db/cjk_encoding.rb +46 -0
- data/lib/thermal/db/data.rb +77 -0
- data/lib/thermal/db/device.rb +79 -0
- data/lib/thermal/db/encoding.rb +35 -0
- data/lib/thermal/db/loader.rb +65 -0
- data/lib/thermal/db.rb +43 -0
- data/lib/thermal/dsl.rb +28 -0
- data/lib/thermal/escpos/buffer.rb +167 -0
- data/lib/thermal/escpos/cmd.rb +11 -0
- data/lib/thermal/escpos/writer.rb +93 -0
- data/lib/thermal/escpos_star/buffer.rb +38 -0
- data/lib/thermal/escpos_star/writer.rb +17 -0
- data/lib/thermal/printer.rb +56 -21
- data/lib/thermal/profile.rb +71 -0
- data/lib/thermal/stargraphic/capped_byte_buffer.rb +20 -0
- data/lib/thermal/stargraphic/chunked_byte_buffer.rb +62 -0
- data/lib/thermal/stargraphic/writer.rb +318 -0
- data/lib/thermal/starprnt/buffer.rb +46 -0
- data/lib/thermal/starprnt/writer.rb +81 -0
- data/lib/thermal/util.rb +74 -0
- data/lib/thermal/version.rb +5 -3
- data/lib/thermal/writer_base.rb +122 -0
- data/lib/thermal.rb +81 -8
- metadata +59 -57
- data/.gitignore +0 -3
- data/.rspec +0 -2
- data/.travis.yml +0 -6
- data/Gemfile +0 -3
- data/Rakefile +0 -1
- data/lib/devices/btpr880.rb +0 -33
- data/lib/devices/html.rb +0 -14
- data/lib/thermal/parser.rb +0 -30
- data/spec/btpr880_spec.rb +0 -36
- data/spec/fixtures/receipt.html +0 -6
- data/spec/printer_spec.rb +0 -29
- data/spec/spec_helper.rb +0 -3
- data/spec/thermal_spec.rb +0 -7
- data/tasks/console.rake +0 -9
- data/tasks/spec.rake +0 -3
- data/thermal.gemspec +0 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b18797f5189d89f1f7326ab9eb8a131c1c0a98f37fc76b10469e4a67bddf5c47
|
4
|
+
data.tar.gz: 509efa5bfc9b51dd736b30c9f215d36e8f15fc2a578c7039b9bcd60915929554
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ecef3e5aba6e5d6b296762f53f6b809a2d4950c32232790138cff89ad8beb49439147cd5da89635f1002664c12fb9b9e4595a453a344ce8db148a0c330e2b0d7
|
7
|
+
data.tar.gz: cfb8b73b14a9bc09ad839066f888e35574c8ec00986787f6e0c666cfddd7d2c9eaa295483867b10297ff389c4c7bfc3b67fa06d6ec8db8c4e5b42e78aa55c254
|
data/LICENSE
CHANGED
@@ -1,20 +1,21 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
the
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Johnny Shields & TableCheck
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,27 +1,200 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
1
|
+
# Thermal ๐จ๏ธ
|
2
|
+
|
3
|
+
Thermal printer support for Ruby. Used to print receipts, chits, tickets, labels, etc.
|
4
|
+
|
5
|
+
[](https://badge.fury.io/rb/thermal)
|
6
|
+
[](https://github.com/tablecheck/thermal/actions/workflows/ci.yml)
|
7
|
+
[](https://github.com/rubocop/rubocop)
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
9
|
+
|
10
|
+
## โ ๏ธ WARNING: Gem under active development
|
11
|
+
|
12
|
+
**All APIs and features should be considered unstable before 1.0.0 release.**
|
13
|
+
|
14
|
+
### โจ Features
|
15
|
+
|
16
|
+
- ๐ฏ Simple and opinionated API. **It just worksโข**
|
17
|
+
- ๐จ Generates **rich text, image, and QR codes** for thermal printers.
|
18
|
+
- ๐ญ Supports a broad range of **makers and models** (Epson, Star Micronics, Brother, PBM, Zijiang, etc.)
|
19
|
+
- ๐ Automatic **multi-lingual** codepage support, including support for **CJK extended character sets**.
|
20
|
+
- ๐ **Simple DSL** for rich text output formatting.
|
21
|
+
- ๐ฆ **Graceful degradation** of features based on printer capabilities.
|
22
|
+
|
23
|
+
### ๐ Optional Features
|
24
|
+
|
25
|
+
- **QR code generation** ๐ฑ
|
26
|
+
- Requires [rqrcode](https://github.com/whomwah/rqrcode) gem.
|
27
|
+
- Support for **Stargraphic (raster-only format)** using system-side font rendering. ๐ผ๏ธ
|
28
|
+
- See requirements below.
|
29
|
+
|
30
|
+
### ๐ค Supported Output Formats
|
31
|
+
|
32
|
+
- Epson ESC/POS
|
33
|
+
- Industry standard used by most thermal printers
|
34
|
+
- Star Micronics-specific formats
|
35
|
+
- Star Micronics Extended ESC/POS (UTF-8)
|
36
|
+
- Starprnt
|
37
|
+
- Stargraphic
|
38
|
+
|
39
|
+
### โ Non-Features & Limitations
|
40
|
+
|
41
|
+
- **HTML-to-text support** (planned, not yet released) ๐
|
42
|
+
- Requires [nokogiri](https://nokogiri.org/) gem.
|
43
|
+
- **No support for wire protocols** such as USB, Bluetooth, etc. This gem is intended
|
44
|
+
to run on a server; it only generates the instructions/bytes to be sent to the client
|
45
|
+
- (browser, iOS, etc.) which should then send it to the end device.
|
46
|
+
- **PR welcome** if someone wants to add USB/Bluetooth support.
|
47
|
+
- **Pixel-only printer support (Stargraphic) is rudimentary and slow** ๐ข, because
|
48
|
+
it uses system-side font rendering ([Pango](https://www.pango.org/)) to generate
|
49
|
+
the image data.
|
50
|
+
- **PR welcome** to use a different approach and/or make it faster.
|
51
|
+
- Table formatting support not yet added. **PR welcome**.
|
52
|
+
- Indian ISCII encoding for Escpos is not yet supported. **PR welcome**.
|
53
|
+
|
54
|
+
## ๐ How to Use
|
55
|
+
|
56
|
+
### ๐ฆ Installation
|
57
|
+
|
58
|
+
Add this line to your application's Gemfile:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
gem 'thermal'
|
62
|
+
```
|
63
|
+
|
64
|
+
### ๐จ๏ธ Formatting your Output
|
65
|
+
|
66
|
+
#### โจ๏ธ Procedural code
|
67
|
+
|
68
|
+
Intended API: (needs to be further extracted)
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
printer = Thermal::Printer.new(device: :espon_tm_t88v)
|
72
|
+
printer.text('Contra felicem vix deus vires habet')
|
73
|
+
printer.align_center
|
74
|
+
printer.text('Quam vellem nescire litteras!')
|
75
|
+
printer.flush # todo: #print!?
|
76
|
+
```
|
77
|
+
|
78
|
+
#### ๐งฉ DSL
|
79
|
+
|
80
|
+
You can also use it as a DSL:
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
# TODO: Example text should look like an actual receipt
|
84
|
+
class MyChitPrinter
|
85
|
+
include Thermal::Dsl
|
86
|
+
|
87
|
+
def initialize
|
88
|
+
@printer = Thermal::Printer.new(device: :espon_tm_t88v)
|
89
|
+
end
|
90
|
+
|
91
|
+
def print
|
92
|
+
thermal_print do # TODO: does this flush automatically?
|
93
|
+
bold do
|
94
|
+
text('Contra felicem vix deus vires habet')
|
95
|
+
align(:center) do
|
96
|
+
text('Quam vellem nescire litteras!')
|
97
|
+
end
|
98
|
+
# html do
|
99
|
+
#
|
100
|
+
# end
|
101
|
+
# html('<b>foo</b>')
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
#### ๐ HTML Conversion
|
109
|
+
|
110
|
+
```ruby
|
111
|
+
# TODO: float/tables?
|
112
|
+
# h1
|
113
|
+
# h2
|
114
|
+
# h3
|
115
|
+
#
|
116
|
+
```
|
117
|
+
|
118
|
+
### ๐ข Integrating Thermal into your App
|
119
|
+
|
120
|
+
- Add details of how to implement a thermal printer config.
|
121
|
+
|
122
|
+
|
123
|
+
### ๐ ๏ธ Advanced Considerations
|
124
|
+
|
125
|
+
#### ๐งต Thread-Safety
|
126
|
+
|
127
|
+
- Thermal's internals are thread-safe in principle.
|
128
|
+
- However, don't use the same `Thermal::Printer` object from multiple threads.
|
129
|
+
You're gonna have a bad time. ๐ต
|
130
|
+
|
131
|
+
### ๐ TODOs
|
132
|
+
|
133
|
+
#### โ
Required before 1.0.0 release
|
134
|
+
|
135
|
+
- [ ] Add render method instead of flush
|
136
|
+
- [ ] Add task to import config from escpos-printer-db
|
137
|
+
- [ ] Rename CjkEncoding to RubyEncoding, rename CharmapEncoding, CharsetEncoding, also add IconvEncoding
|
138
|
+
- [ ] Encoding classes themselves should validate missing char (move from Escpos::Buffer class)
|
139
|
+
- [ ] Iconv config generator rake task.
|
140
|
+
- [ ] Set output format for thermal_print (default, base64, bytes, etc.)
|
141
|
+
- [ ] Params for escpos: :codepages, escpos: charsets
|
142
|
+
- [ ] Copy in Escpos and EscposImage gems (get rid of dependency)
|
143
|
+
- [ ] Param pass-thru to EscposImage
|
144
|
+
- [ ] Configurability of tmp path -- specific to stargraphic (?) -- Should use Tempfile
|
145
|
+
- [ ] Write Readme
|
146
|
+
- [ ] DslMixin should include protocol (?), ipp_uri (?) -- why??
|
147
|
+
- [ ] Specs for all classes, including base.
|
148
|
+
- [ ] StarGraphic needs multiple message buffering. ???
|
149
|
+
- [ ] Add QR to DSL
|
150
|
+
|
151
|
+
#### โจ Nice to haves
|
152
|
+
|
153
|
+
- [ ] font support. col_width should be dynamic in the printer (currently depends on font 0)
|
154
|
+
- [ ] Copy "Available methods" from https://github.com/escpos/escpos-php
|
155
|
+
- [ ] Add HTML command in addition to text. Should be done as an AST (HtmlAst) like [[:text, 'ddd'], [:underline, 2, [[:text, 'foo']]]]
|
156
|
+
- [ ] Optional HTML image support
|
157
|
+
- [ ] Copy TestReport
|
158
|
+
- [ ] Stargraphic needs much better buffer support, including line break splitting + multiple buffers.
|
159
|
+
- [ ] Allow pass-in of codepage object.
|
160
|
+
- [ ] Allow pass-in of charset object.
|
161
|
+
- [ ] Indian ISCII encoding for Escpos (separate gem?).
|
162
|
+
|
163
|
+
# ๐ Contributing
|
164
|
+
|
165
|
+
To add support for additional Thermal printers.
|
166
|
+
- escpos-printer-db
|
167
|
+
- Add new code in `lib/thermal/printer/escpos.rb`
|
168
|
+
- Add new code in `lib/thermal/printer/starprnt.rb`
|
169
|
+
|
170
|
+
# ๐ Acknowledgements
|
171
|
+
|
172
|
+
### ๐จโ๐ป Maintainers
|
173
|
+
|
174
|
+
Thermal is maintained and battle-tested by the team at [TableCheck](https://www.tablecheck.com/en/join/)
|
175
|
+
based in Tokyo, Japan. ๐ผ We use Thermal to help our restaurant users print chits, receipts, and
|
176
|
+
QR codes to serve their guests' reservations. If you are seeking your next career adventure,
|
177
|
+
[we're hiring](https://careers.tablecheck.com/)!
|
178
|
+
|
179
|
+
### ๐ Data Sources
|
180
|
+
|
181
|
+
This gem relies on the community-maintained
|
182
|
+
[escpos-printer-db](https://github.com/receipt-print-hq/escpos-printer-db)
|
183
|
+
to provide a comprehensive list of thermal printers.
|
184
|
+
|
185
|
+
### ๐ Special Thanks
|
186
|
+
|
187
|
+
This gem draws inspiration from the following libraries.
|
188
|
+
Thank you to the authors for their hard work.
|
189
|
+
- [escpos-php](https://github.com/escpos/escpos-php)
|
190
|
+
- [escpos-printer-db](https://github.com/receipt-print-hq/escpos-printer-db)
|
191
|
+
- [EscPosEncoder JS](https://github.com/NielsLeenheer/EscPosEncoder/blob/master/src/esc-pos-encoder.js)
|
192
|
+
|
193
|
+
### ยฉ๏ธ Copyright Attribution
|
194
|
+
|
195
|
+
The vendor manuals in the `doc/vendor` directory are the property of their respective owners.
|
196
|
+
They are included here for references purposes only under the fair use doctrine.
|
197
|
+
|
198
|
+
### ๐ License
|
199
|
+
|
200
|
+
This gem is released under the MIT License. Please see the [LICENSE](LICENSE) file for details.
|