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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da5acc910d347224eb5475ab363724f73c3f5d22
4
- data.tar.gz: cb5e734ad108c39c63cc23f3114c1be631587f62
3
+ metadata.gz: 4acfdf8648af8a1fca15a5d77e385db6c3c734af
4
+ data.tar.gz: 41113e55413d7a6878b57045e2d846f52e94ab5b
5
5
  SHA512:
6
- metadata.gz: d1fcf0fef50ac5fa936845aa486b50688b0a0c893fb992fe93501f9343ed67be4187c44e828d5266d043d2528954cee5ebb73ef0aa13fea8ae4614f515e40200
7
- data.tar.gz: db2f57c135c8b88535218f4bf4ce31068688134bdc6528a16930964c88fbfc61764df03b3d8eb499a3dc3e38a742f71fee814d1e32f2744cc997317fe35a8cab
6
+ metadata.gz: 17afa77baaacc6e4e9e962f78fee8fef7a2c93dc48c9a72957a062e7da2c65383a8210cc211acc13379e49799da6e36949a126c2745292ed9826353c3a200369
7
+ data.tar.gz: a8bc40057ee9bce2c4c4d53ed645ac78427786ddcbd375b96715a0a8e68579089de4ac85408f538568927ef457c4747fb976dfa3855591a6688bd2d20dcbf644
data/example/sample.rb CHANGED
@@ -2,7 +2,7 @@ require 'bundler/setup'
2
2
  require 'runtime_command'
3
3
 
4
4
  command = RuntimeCommand::Builder.new
5
- # command.colors = :default_colors
5
+ # command.colors = :none
6
6
  command.exec('echo "wait 3" sec; sleep 3; echo "hello world!"')
7
7
 
8
8
  # command.output = false
@@ -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 colors == :default_colors
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
@@ -1,3 +1,3 @@
1
1
  module RuntimeCommand
2
- VERSION = '1.0.1'.freeze
2
+ VERSION = '1.0.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runtime_command
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - naomichi-y