runtime_command 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/example/sample.rb +1 -1
- data/lib/runtime_command/logger.rb +9 -8
- data/lib/runtime_command/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4acfdf8648af8a1fca15a5d77e385db6c3c734af
|
4
|
+
data.tar.gz: 41113e55413d7a6878b57045e2d846f52e94ab5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17afa77baaacc6e4e9e962f78fee8fef7a2c93dc48c9a72957a062e7da2c65383a8210cc211acc13379e49799da6e36949a126c2745292ed9826353c3a200369
|
7
|
+
data.tar.gz: a8bc40057ee9bce2c4c4d53ed645ac78427786ddcbd375b96715a0a8e68579089de4ac85408f538568927ef457c4747fb976dfa3855591a6688bd2d20dcbf644
|
data/example/sample.rb
CHANGED
@@ -9,12 +9,9 @@ module RuntimeCommand
|
|
9
9
|
# @return RuntimeCommand::Logger
|
10
10
|
def initialize(output = true, colors = {})
|
11
11
|
@output = output
|
12
|
+
@has_color = colors != :none
|
12
13
|
|
13
|
-
if
|
14
|
-
@stdin_color = nil
|
15
|
-
@stdout_color = nil
|
16
|
-
@stderr_color = nil
|
17
|
-
else
|
14
|
+
if @has_color
|
18
15
|
@stdin_color = colors[:stdin] || HighLine::Style.rgb(204, 204, 0)
|
19
16
|
@stdout_color = colors[:stdout] || HighLine::Style.rgb(64, 64, 64)
|
20
17
|
@stderr_color = colors[:stderr] || HighLine::Style.rgb(255, 51, 51)
|
@@ -25,7 +22,9 @@ module RuntimeCommand
|
|
25
22
|
|
26
23
|
# @param [String] line
|
27
24
|
def stdin(line)
|
28
|
-
puts HighLine.color(line, @stdin_color) if @output
|
25
|
+
puts HighLine.color(line, @stdin_color) if @output && @has_color
|
26
|
+
puts line if @output && !@has_color
|
27
|
+
|
29
28
|
@buffered_log << line + "\n"
|
30
29
|
|
31
30
|
nil
|
@@ -38,7 +37,8 @@ module RuntimeCommand
|
|
38
37
|
|
39
38
|
# @param [String] line
|
40
39
|
def stdout(line)
|
41
|
-
puts HighLine.color(line.chomp, @stdout_color) if @output
|
40
|
+
puts HighLine.color(line.chomp, @stdout_color) if @output && @has_color
|
41
|
+
puts line if @output && !@has_color
|
42
42
|
|
43
43
|
@buffered_log << line
|
44
44
|
@buffered_stdout << line
|
@@ -53,7 +53,8 @@ module RuntimeCommand
|
|
53
53
|
|
54
54
|
# @param [String] line
|
55
55
|
def stderr(line)
|
56
|
-
puts HighLine.color(line.chomp, @stderr_color) if @output
|
56
|
+
puts HighLine.color(line.chomp, @stderr_color) if @output && @has_color
|
57
|
+
puts line if @output && !@has_color
|
57
58
|
|
58
59
|
@buffered_log << line
|
59
60
|
@buffered_stderr << line
|