thecore_print_commons 2.1.6 → 2.1.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
2
  SHA256:
3
- metadata.gz: 9ea66f408d04dee9a18484a617f170c16ca1e74ce5011b87b2063b25cfd86c0b
4
- data.tar.gz: 85566448eaa20b0601a4b82e17f5d668bfefdb1e3b565c099d91bf066e463228
3
+ metadata.gz: ff7cb53138fab8c991338c6f585d2bc547ea34dd6c4458ce4d2fda798980db9b
4
+ data.tar.gz: b3d1a389e3019373b61c5776747909ccacd309294b0b3ed3e9fa94a850845237
5
5
  SHA512:
6
- metadata.gz: a4ee226bad981af3220ba0eb1dda3a4699c1967c45278a2e18fccfdca5494bbcced4a0f6f0cedaa608badb5702db4164bbddc9cfd23989c80df9a2ac9c84606a
7
- data.tar.gz: 4abcbc5eea0f199b71696b2075ef3b23c4af111c1d9d51bb2c636fa7928f302f860c4494212dbb74def14d89e50713fb33c6cbd09d738dd73a3c3af78aaf4d43
6
+ metadata.gz: cecd2553a802eb1cf908730bc636e3987c651bdbbf1cda33e0c521c26ff9e40c4397101688c1ee331b7faf2946d21b2d4687f614a3348ede4a705039a8654518
7
+ data.tar.gz: 0f9b85e7ea6019c63a5115f2e53d9a335710b796b539155e5354933b4792c55340b8883388640f09bf98026081e17aa531c18001ff6664eb6566cb4efd998927
@@ -34,11 +34,14 @@ module Api::Printer
34
34
  # single_text = "#{printer.print_template.template.gsub("%DESCRIPTION%", item.description)}"
35
35
  # text = single_text * params[:quantity].to_i
36
36
  # # Preso l'ordine mi recupero l'item e ne stampo la quantità richiesta
37
- # ::PrintWorker.perform_async(printer.ip, text)
37
+ # ::PrintWorker.perform_async('192.168.0.1', 9100, "We all love DJ")
38
38
 
39
39
  printer = Printer.find(params[:id])
40
- text = printer.print_template.template.gsub(printer.print_template.translation_matrix.lines.first, params[:barcode])
41
- ::PrintWorker.perform_async(printer.ip, printer.port, text)
40
+ base_template = printer.print_template.template.dup
41
+ result = printer.print_template.translation_matrix.lines.map(&:strip).inject(base_template) do |base_template, replacement|
42
+ base_template.gsub("$#{replacement}", params[replacement]) unless replacement.blank? && params[replacement].blank?
43
+ end
44
+ ::PrintWorker.perform_async(printer.ip, printer.port, result)
42
45
  { info: "Print job sent in background to #{printer.ip} on port #{printer.port}" }
43
46
  end
44
47
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_print_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
4
+ version: 2.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_background_jobs