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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a9dea87fd5ed46f6476a07e75be72f244c1c837d
4
- data.tar.gz: 4c2cf776cfcdacbfe3db7bc3d52347869dc5afda
3
+ metadata.gz: c3e24eeda8c2029070bed4387b494bc429221362
4
+ data.tar.gz: 7effcba2a48407bc159a0cba1405f9a0705eea58
5
5
  SHA512:
6
- metadata.gz: 28bcca367027743454fafe3618969975ff2786710c56dc2a60a94c1f6c4f0643f40d1bdf8807ed38fbe5f5e233a333a6bdf563a60987027856b84fde8c319836
7
- data.tar.gz: d35a1575f541ee3c8ed31888eb3c17cdf9cdab246b5e54a50fec5bd13ea8bc4f0fe6bbbb1de024b353cfbc35f14de3f4aefc3c0dc999bd4dc56e7b1f59065e2f
6
+ metadata.gz: 4f8014029e9bc069965ff6beb8cc2af326af60c9e2b450bad25c60a96b1901bb4f9d51dd3d05b16ae947b46fbc53b0531c154cb690774eecf06077163ab00114
7
+ data.tar.gz: e673562ecf9a35be40c3a23cabb6cbf29f1b5b4dbbce6ec85bbef39c0aa213ab985b8fd27083c80ba7285c654c6052ab6b9cb583e1972c6dcf55e05d5cb5f60b
data/README.md CHANGED
@@ -87,7 +87,7 @@ Another example to show off is:
87
87
  require 'fancy_command'
88
88
  include FancyCommand
89
89
 
90
- # get the date
90
+ # get the current month
91
91
 
92
92
  command = run("date") | "awk '{ print $2 }'"
93
93
  puts command.output
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, must_succeed: false, **opts)
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
@@ -1,3 +1,3 @@
1
1
  module FancyCommand
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fancy_command
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - myobie