fancy_command 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/fancy_command.rb +8 -0
- data/lib/fancy_command/command.rb +5 -3
- data/lib/fancy_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: c3e24eeda8c2029070bed4387b494bc429221362
|
4
|
+
data.tar.gz: 7effcba2a48407bc159a0cba1405f9a0705eea58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f8014029e9bc069965ff6beb8cc2af326af60c9e2b450bad25c60a96b1901bb4f9d51dd3d05b16ae947b46fbc53b0531c154cb690774eecf06077163ab00114
|
7
|
+
data.tar.gz: e673562ecf9a35be40c3a23cabb6cbf29f1b5b4dbbce6ec85bbef39c0aa213ab985b8fd27083c80ba7285c654c6052ab6b9cb583e1972c6dcf55e05d5cb5f60b
|
data/README.md
CHANGED
data/lib/fancy_command.rb
CHANGED
@@ -6,6 +6,14 @@ module FancyCommand
|
|
6
6
|
Command.new(string, **opts, &blk)
|
7
7
|
end
|
8
8
|
|
9
|
+
def self.defaults
|
10
|
+
@defaults ||= {}.freeze
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.defaults=(new_defaults)
|
14
|
+
@defaults = new_defaults.freeze
|
15
|
+
end
|
16
|
+
|
9
17
|
def run(string, **opts, &blk)
|
10
18
|
command(string, **opts, &blk).()
|
11
19
|
end
|
@@ -16,18 +16,20 @@ module FancyCommand
|
|
16
16
|
|
17
17
|
attr_reader :string, :accum, :in, :out, :err, :output, :status, :pid
|
18
18
|
|
19
|
-
def initialize(string,
|
19
|
+
def initialize(string, **opts)
|
20
|
+
opts = FancyCommand.defaults.merge(opts)
|
21
|
+
|
20
22
|
@string = string
|
21
23
|
@verbose = opts.fetch(:verbose, false)
|
24
|
+
@must_succeed = opts.fetch(:must_succeed, false)
|
22
25
|
@accum = opts.fetch(:accum) { [] }
|
23
26
|
@in = opts[:in]
|
24
27
|
@output = ""
|
28
|
+
@output_mutex = Mutex.new
|
25
29
|
@out = nil
|
26
30
|
@err = nil
|
27
31
|
@status = nil
|
28
32
|
@pid = nil
|
29
|
-
@must_succeed = must_succeed
|
30
|
-
@output_mutex = Mutex.new
|
31
33
|
|
32
34
|
if block_given?
|
33
35
|
append_in yield
|