runtime_command 0.1.6 → 0.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
  SHA1:
3
- metadata.gz: 7bd87734df7e09d934776277a2511c06694c62d2
4
- data.tar.gz: c6994818950a65dee8ae0480e1542a8ebb9b146e
3
+ metadata.gz: fc44f41a931faf6b83ccc2c9a1c3ecac48205426
4
+ data.tar.gz: 49608abc877d1fae72e6bb0ed52109aedec90d8e
5
5
  SHA512:
6
- metadata.gz: 899348bbf681fcb2f9b84fb806561211fe9c25dc1f973601d72a1c4b7c12aa4e8af0f5cf57edbd5e0e79ca07b18b6b75dcf7da57fc93ba5599931acd42694f02
7
- data.tar.gz: 7b4997df6abb7ccfd65eb8fa8dbcc7e1e3c280f500beaa82e5226c1fa560474262daafa50d1f0ff09af977850827d9e7516f7dafe3b59bfaea2fa8ee65a1e2dd
6
+ metadata.gz: fa01723fac8233d2e46e9839109fce6a4d0975366fa75d1494ab6e2ce1e24d2a72f70fb2e509c2a9afdcfa8055c0245841a336a53f6f1ca6b9a0c269203605bc
7
+ data.tar.gz: e42fc359bbe2d682fce10c0ae9d84ed989239e4dcdd288b09b1cd408ecb0f0bbcc568a9687acd4c450c911bb66f772e8d37f51c6ca114831eab6879a40e31e8b
data/README.md CHANGED
@@ -41,3 +41,10 @@ puts logger.buffered_log
41
41
  puts logger.buffered_stdout
42
42
  puts logger.buffered_stderr
43
43
  ```
44
+
45
+ Change STDOUT color.
46
+
47
+ ```
48
+ command.colors[:stdout] = HighLine::Style.rgb(255, 0, 0)
49
+ logger = command.exec('ls -la')
50
+ ```
data/example/sample.rb CHANGED
@@ -3,3 +3,9 @@ require 'runtime_command'
3
3
 
4
4
  command = RuntimeCommand::Builder.new
5
5
  command.exec('echo "wait 3" sec; sleep 3; echo "hello world!"')
6
+
7
+ # command.output = false
8
+ # puts command.exec('ls -la').buffered_stdout
9
+
10
+ # command.colors[:stdout] = HighLine::Style.rgb(255, 0, 0)
11
+ # command.exec('ls -la')
@@ -13,6 +13,7 @@ module RuntimeCommand
13
13
  @output = true
14
14
  @buffered_log = ''
15
15
  @stdin_prefix = '>'
16
+ @colors = {}
16
17
  end
17
18
 
18
19
  # @param [String] command
@@ -37,10 +38,11 @@ module RuntimeCommand
37
38
  end
38
39
  end
39
40
 
40
- @buffered_log << logger.buffered_log
41
-
41
+ rescue Interrupt
42
+ logger.stderr('Interrupt error')
42
43
  rescue => e
43
44
  logger.stderr(e.to_s)
45
+ ensure
44
46
  @buffered_log << logger.buffered_log
45
47
  end
46
48
 
@@ -7,22 +7,12 @@ module RuntimeCommand
7
7
  # @param [Boolean] output
8
8
  # @param [Hash] colors
9
9
  # @return RuntimeCommand::Logger
10
- def initialize(output = true, colors = nil)
10
+ def initialize(output = true, colors = {})
11
11
  @output = output
12
12
 
13
- stdin_rgb = [204, 204, 0]
14
- stdout_rgb = [64, 64, 64]
15
- stderr_rgb = [255, 51, 51]
16
-
17
- if colors
18
- stdin_rgb = colors[:stdin] if colors.has_key?(:stdin)
19
- stdout_rgb = colors[:stdout] if colors.has_key?(:stdout)
20
- stderr_rgb = colors[:stderr] if colors.has_key?(:stderr)
21
- end
22
-
23
- @stdin_color = HighLine::Style.rgb(*stdin_rgb)
24
- @stdout_color = HighLine::Style.rgb(*stdout_rgb)
25
- @stderr_color = HighLine::Style.rgb(*stderr_rgb)
13
+ @stdin_color = colors[:stdin] || HighLine::Style.rgb(204, 204, 0)
14
+ @stdout_color = colors[:stdout] || HighLine::Style.rgb(64, 64, 64)
15
+ @stderr_color = colors[:stderr] || HighLine::Style.rgb(255, 51, 51)
26
16
 
27
17
  flash
28
18
  end
@@ -1,3 +1,3 @@
1
1
  module RuntimeCommand
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runtime_command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - naomichi-y
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-01 00:00:00.000000000 Z
11
+ date: 2017-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline