thecore_print_commons 3.0.7 → 3.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/concerns/api/printer.rb +2 -34
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60bc6a555c26ae9c90c1b3e7821e7f2e4819d8ac1977cc89af995c36aabb6e6d
|
4
|
+
data.tar.gz: a587518ffc569541120b83300428d2eef1c8d6c25afab2f9e6d4ed4a14dbeb16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fdda61b4cf00d7c91f31c3196a10d2a0d64f4d4c28332276351c326f54ff954bf9840d90f31d8b0c9b604a070c5e7e02b74003cc54899f6a16c33b7d194c2e1
|
7
|
+
data.tar.gz: 7fcb2afaae5590bad5b489c9ed304f7afdb5dba1d2393e3e8c179c8799cab4ce6168af6e092f99ca14facfab60e5eb4298bb133a1ac397b338d9ac5cca7bbf5b
|
@@ -39,44 +39,12 @@ module Api::Printer
|
|
39
39
|
# ::PrintWorker.perform_async('192.168.0.1', 9100, "We all love DJ")
|
40
40
|
|
41
41
|
printer = Printer.find(params[:id])
|
42
|
-
base_template = printer.print_template.template.dup
|
42
|
+
result = base_template = printer.print_template.template.dup
|
43
43
|
result = printer.print_template.translation_matrix.lines.map(&:strip).inject(base_template) do |base_template, replacement|
|
44
44
|
base_template.gsub("$#{replacement}", params[replacement]) unless replacement.blank? && params[replacement].blank?
|
45
|
-
end
|
45
|
+
end if printer.print_template.translation_matrix.present?
|
46
46
|
::PrintWorker.perform_async(printer.ip, printer.port, result)
|
47
47
|
{ info: "Print job sent in background to #{printer.ip} on port #{printer.port}" }
|
48
48
|
end
|
49
|
-
|
50
|
-
def self.custom_action_printer_status params
|
51
|
-
printer = Printer.find(params[:id])
|
52
|
-
ip = printer.ip
|
53
|
-
port = printer.port
|
54
|
-
begin
|
55
|
-
s = Socket.tcp ip, port, connect_timeout: 0.5
|
56
|
-
# Must create intepolation between item and template
|
57
|
-
# Printer.template può essere anche
|
58
|
-
# una parola di comando epr chiedere lo stato della stampante, solo nel caso sia ok,
|
59
|
-
# Allora mando la stampa
|
60
|
-
s.puts("~hs")
|
61
|
-
# Attende per la risposta (si mette in wait)
|
62
|
-
response = []
|
63
|
-
while (response_text = s.gets)
|
64
|
-
response << response_text
|
65
|
-
break if response.count == 3
|
66
|
-
end
|
67
|
-
s.close
|
68
|
-
# Rails.logger.info "PrintIt: RESPONSE: #{response.inspect}"
|
69
|
-
first = response[0].split(",")
|
70
|
-
second = response[1].split(",")
|
71
|
-
return "HEAD UP" if second[2].to_i == 1
|
72
|
-
return "RIBBON OUT" if second[3].to_i == 1
|
73
|
-
return "PAPER OUT" if first[1].to_i == 1
|
74
|
-
return "PAUSE" if first[2].to_i == 1
|
75
|
-
return "OK"
|
76
|
-
rescue
|
77
|
-
Rails.logger.info "PrintIt: STATUS: UNREACHABLE"
|
78
|
-
return "UNREACHABLE"
|
79
|
-
end
|
80
|
-
end
|
81
49
|
end
|
82
50
|
end
|
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: 3.0.
|
4
|
+
version: 3.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriele Tassoni
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thecore_background_jobs
|