system_command_helper 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/system_command_helper.rb +11 -7
- data/lib/system_command_helper/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 094be426f33bd1b99456c42d10f910de289754c8
|
4
|
+
data.tar.gz: 7df1f2601254348b60b3c26cd1f8f4a09cd39597
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c09d24440cf28ddca0247082f840b66348853a1ddec24b8c1ab0a13f6a27941a6ddc6d6700163cd3925e986014c9ad5c9b6c342655555d9416c28fcd98fadc0
|
7
|
+
data.tar.gz: 4d0f2eec67667d907951fb528bfad02c1bb8638abb02917211908fdb8bc23d496cfa439f1175bd035dcaf861842a9d9410c35d1dab0b9912543928e11f625660
|
@@ -3,29 +3,33 @@ require "system_command_helper/version"
|
|
3
3
|
module SystemCommandHelper
|
4
4
|
attr_accessor :no_exec, :quiet
|
5
5
|
|
6
|
+
@@no_exec = false
|
7
|
+
@@quiet = false
|
8
|
+
@@on_error = nil
|
9
|
+
|
6
10
|
def sys(cmd)
|
7
|
-
unless
|
11
|
+
unless @@quiet
|
8
12
|
puts "\e[35m#{Dir.pwd}$\e[0m #{cmd}"
|
9
13
|
end
|
10
|
-
unless
|
14
|
+
unless @@no_exec
|
11
15
|
result = system cmd
|
12
|
-
if !result &&
|
13
|
-
|
16
|
+
if !result && @@on_error
|
17
|
+
@@on_error.call(cmd, result)
|
14
18
|
end
|
15
19
|
result
|
16
20
|
end
|
17
21
|
end
|
18
22
|
|
19
23
|
def cap(cmd)
|
20
|
-
unless
|
24
|
+
unless @@quiet
|
21
25
|
puts "\e[35m#{Dir.pwd}$\e[0m `#{cmd}`"
|
22
26
|
end
|
23
|
-
unless
|
27
|
+
unless @@no_exec
|
24
28
|
`#{cmd}`
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
32
|
def on_error(&block)
|
29
|
-
|
33
|
+
@@on_error = block
|
30
34
|
end
|
31
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: system_command_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Narazaka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|