smartware 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -10,46 +10,31 @@ module Smartware
|
|
10
10
|
|
11
11
|
def self.error
|
12
12
|
@device.error
|
13
|
-
rescue => e
|
14
|
-
'No device'
|
15
13
|
end
|
16
14
|
|
17
15
|
def self.model
|
18
16
|
@device.model
|
19
|
-
rescue => e
|
20
|
-
'No device'
|
21
17
|
end
|
22
18
|
|
23
19
|
def self.version
|
24
20
|
@device.version
|
25
|
-
rescue => e
|
26
|
-
'No device'
|
27
21
|
end
|
28
22
|
|
29
23
|
def self.test
|
30
24
|
@device.test
|
31
|
-
rescue => e
|
32
|
-
'No device'
|
33
25
|
end
|
34
26
|
|
35
27
|
def self.print(text, max_time = 30)
|
36
28
|
@device.print text, max_time
|
37
|
-
rescue => e
|
38
|
-
'No device'
|
39
29
|
end
|
40
30
|
|
41
31
|
def self.print_text(text, max_time = 30)
|
42
32
|
@device.print_text text, max_time
|
43
|
-
rescue => e
|
44
|
-
'No device'
|
45
33
|
end
|
46
34
|
|
47
35
|
def self.print_markdown(text, max_time = 30)
|
48
36
|
@device.print_markdown text, max_time
|
49
|
-
rescue => e
|
50
|
-
'No device'
|
51
37
|
end
|
52
|
-
|
53
38
|
end
|
54
39
|
end
|
55
40
|
end
|
@@ -10,26 +10,18 @@ module Smartware
|
|
10
10
|
|
11
11
|
def self.error
|
12
12
|
@device.error
|
13
|
-
rescue => e
|
14
|
-
'No device'
|
15
13
|
end
|
16
14
|
|
17
15
|
def self.model
|
18
16
|
@device.model
|
19
|
-
rescue => e
|
20
|
-
'No device'
|
21
17
|
end
|
22
18
|
|
23
19
|
def self.version
|
24
20
|
@device.version
|
25
|
-
rescue => e
|
26
|
-
'No device'
|
27
21
|
end
|
28
22
|
|
29
23
|
def self.reboot_modem
|
30
24
|
@device.reboot_modem
|
31
|
-
rescue => e
|
32
|
-
'No device'
|
33
25
|
end
|
34
26
|
end
|
35
27
|
end
|
@@ -229,8 +229,14 @@ module Smartware
|
|
229
229
|
styled(UNDERLINE) { text }
|
230
230
|
end
|
231
231
|
|
232
|
-
def normal_text(text)
|
233
|
-
text.encode("CP866")
|
232
|
+
def normal_text(text, keep_newlines = false)
|
233
|
+
text.encode!("CP866")
|
234
|
+
|
235
|
+
unless keep_newlines
|
236
|
+
text.gsub! "\n", " "
|
237
|
+
end
|
238
|
+
|
239
|
+
text
|
234
240
|
end
|
235
241
|
|
236
242
|
def doc_header
|
@@ -12,7 +12,8 @@ module Smartware
|
|
12
12
|
|
13
13
|
@printer_mutex = Mutex.new
|
14
14
|
Thread.new &method(:poll)
|
15
|
-
@
|
15
|
+
@render = @device.new_render
|
16
|
+
@markdown = Redcarpet::Markdown.new(@render)
|
16
17
|
end
|
17
18
|
|
18
19
|
def test
|
@@ -35,10 +36,20 @@ EOS
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def print_markdown(text, max_time = 30)
|
38
|
-
|
39
|
+
do_print @markdown.render(text), max_time
|
39
40
|
end
|
40
41
|
|
41
42
|
def print_text(text, max_time = 30)
|
43
|
+
data = "".force_encoding("BINARY")
|
44
|
+
data << @render.doc_header.force_encoding("BINARY")
|
45
|
+
data << @render.normal_text(text, true).force_encoding("BINARY")
|
46
|
+
data << @render.doc_footer.force_encoding("BINARY")
|
47
|
+
|
48
|
+
do_print data, max_time
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
def do_print(text, max_time)
|
42
53
|
Smartware::Logging.logger.info "Started printing"
|
43
54
|
|
44
55
|
started = Time.now
|
@@ -75,8 +86,6 @@ EOS
|
|
75
86
|
self.error.nil? || self.error >= 1000
|
76
87
|
end
|
77
88
|
|
78
|
-
private
|
79
|
-
|
80
89
|
def query_printer
|
81
90
|
@device.query
|
82
91
|
update_status do
|
data/lib/smartware/version.rb
CHANGED