nrser 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0613f5168e67281b8c906735f9866e32d8fd4a99
4
- data.tar.gz: dfca12ed21073bd7477b80eca9dccde08b6459a3
3
+ metadata.gz: 385b44525f971891d33ea5f79bed8bb753d56cdd
4
+ data.tar.gz: 175428eb1a8544148606e3f75813b23bb0e3b80b
5
5
  SHA512:
6
- metadata.gz: 3fc0b83a8f905dabd559fad5f403f95585f1c46186e522c1557fbc509d3bdc5c0333dcbe1e977b3bd8edb216387a5233e68ab86347e4993e1e1f7923b39b17f5
7
- data.tar.gz: 0db67a3bdf45e0e891748cf1ad1701c210f21187f9a0a16ef2ab480d9fe8edd0c96e243616bd5b708741ca0c01137459ce5401380e26fc5ee9b4934c3f05cc1f
6
+ metadata.gz: 634f88d8cb06dcb733667b1234e5e4b8a296f0f426ecd22de23d2eb19d83b713f0440ce63011fdcaf4b67a92ef333587a4f74750eca6c690b4ea578464948883
7
+ data.tar.gz: b696d80c061d3d6f570e0192636763b80f468c873f698181b3db691cd4664451dc2067cb230fca573d5d17b5d72627f6b7c4e127d02a379152ca829b39b6beae
@@ -3,6 +3,27 @@ require 'nrser'
3
3
  using NRSER
4
4
 
5
5
  module NRSER::Exec
6
+ class Result
7
+ attr_reader :cmd, :exitstatus, :output
8
+
9
+ def initialize cmd, exitstatus, output
10
+ @cmd = cmd
11
+ @exitstatus = exitstatus
12
+ @output = output
13
+ end
14
+
15
+ def raise_error
16
+ raise SystemCallError.new <<-BLOCK.unblock, @exitstatus
17
+ cmd `#{ @cmd }` failed with status #{ @exitstatus }
18
+ and output #{ @output.inspect }
19
+ BLOCK
20
+ end
21
+
22
+ def success?
23
+ @exitstatus == 0
24
+ end
25
+ end
26
+
6
27
  # substitute stuff into a shell command after escaping with
7
28
  # `Shellwords.escape`.
8
29
  #
@@ -49,5 +70,11 @@ module NRSER::Exec
49
70
  and output #{ output.inspect }
50
71
  BLOCK
51
72
  end
52
- end # ::exec
73
+ end # ::run
74
+
75
+ def self.result cmd, subs = nil
76
+ cmd = sub(cmd, subs) unless subs.nil?
77
+ output = `#{ cmd } 2>&1`
78
+ Result.new cmd, $?.exitstatus, output
79
+ end # ::result
53
80
  end
@@ -1,3 +1,3 @@
1
1
  module NRSER
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nrser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - nrser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-26 00:00:00.000000000 Z
11
+ date: 2015-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler