ro_thor 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ro_thor/sh.rb +28 -0
- data/lib/ro_thor.rb +6 -25
- data/spec/lib/core_ext/array_spec.rb +1 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76c1ed38826537b965c5b523544136fccc42198d
|
4
|
+
data.tar.gz: f5d614fe5a1ec1b659e7ea348fef84a1d321014c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d61d75addbbefd742739e4ddca3ecc1316d9a6f9bc849feeef37ba00ad79a08b9c163eb1433cd0a92d9e1a842679111538c1df23bfb87d79f28ce28be82f98ba
|
7
|
+
data.tar.gz: 0f59eae6a48e4a6e29ebcc1e4235f1ba098bf6a67de5810dac4a6f48ce06ad6a17191f99237bd7cf87a55793e49ade82a25033fbd1b765d51a405ebd781a84bc
|
data/lib/ro_thor/sh.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'thor'
|
2
|
+
class RoThor < Thor
|
3
|
+
module Sh
|
4
|
+
class ShErr < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
def sh_shutup(*args, &blk)
|
8
|
+
sh(*args, {shutup: true}, &blk)
|
9
|
+
end
|
10
|
+
|
11
|
+
def sh(*args, &blk)
|
12
|
+
opts = args.extract_options!
|
13
|
+
cmd = args.join("")
|
14
|
+
puts "run '#{cmd}'"
|
15
|
+
out, err, status = Open3.capture3(cmd)
|
16
|
+
|
17
|
+
unless opts[:shutup]
|
18
|
+
puts out
|
19
|
+
end
|
20
|
+
|
21
|
+
unless status.success?
|
22
|
+
raise ShErr, err
|
23
|
+
end
|
24
|
+
|
25
|
+
out
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/ro_thor.rb
CHANGED
@@ -3,8 +3,11 @@ $LOAD_PATH.unshift(Pathname.new(__FILE__).parent.to_s)
|
|
3
3
|
require 'ro_thor/array'
|
4
4
|
require 'thor'
|
5
5
|
require 'open3'
|
6
|
+
require 'ro_thor/sh'
|
6
7
|
|
7
8
|
class RoThor < Thor
|
9
|
+
include ::RoHelper::Sh
|
10
|
+
|
8
11
|
class << self
|
9
12
|
def usg(str, *args, &blk)
|
10
13
|
desc(str, "")
|
@@ -26,7 +29,7 @@ class RoThor < Thor
|
|
26
29
|
cmd = args.join(" ")
|
27
30
|
puts "run '#{cmd}'"
|
28
31
|
if spork?
|
29
|
-
|
32
|
+
sh cmd
|
30
33
|
else
|
31
34
|
system cmd
|
32
35
|
end
|
@@ -50,7 +53,7 @@ class RoThor < Thor
|
|
50
53
|
|
51
54
|
def read(f, *args, &blk)
|
52
55
|
if rmt?
|
53
|
-
|
56
|
+
sh "sudo cp -f #{f} #{buffer}"
|
54
57
|
File.read(buffer)
|
55
58
|
else
|
56
59
|
File.read(f)
|
@@ -79,34 +82,12 @@ class RoThor < Thor
|
|
79
82
|
if rmt?
|
80
83
|
File.binwrite(buffer, *args, &blk)
|
81
84
|
pr = Pathname.new(f).parent
|
82
|
-
|
85
|
+
sh("sudo mkdir -p #{pr}; sudo cp -f #{buffer} #{f}")
|
83
86
|
else
|
84
87
|
File.binwrite(f, *args, &blk)
|
85
88
|
end
|
86
89
|
end
|
87
90
|
|
88
|
-
class BashErr < StandardError
|
89
|
-
end
|
90
|
-
|
91
|
-
def bash_shutup(*args, &blk)
|
92
|
-
bash(*args, shutup: true, &blk)
|
93
|
-
end
|
94
|
-
|
95
|
-
def bash(*args, &blk)
|
96
|
-
opts = args.extract_options!
|
97
|
-
cmd = args.join("")
|
98
|
-
puts "run '#{cmd}'"
|
99
|
-
out, err, status = Open3.capture3(cmd)
|
100
91
|
|
101
|
-
unless opts[:shutup]
|
102
|
-
puts out
|
103
|
-
end
|
104
|
-
|
105
|
-
unless status.success?
|
106
|
-
raise BashErr, err
|
107
|
-
end
|
108
|
-
|
109
|
-
out
|
110
|
-
end
|
111
92
|
end
|
112
93
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ro_thor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03
|
11
|
+
date: 2015-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -33,6 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- lib/ro_thor.rb
|
35
35
|
- lib/ro_thor/array.rb
|
36
|
+
- lib/ro_thor/sh.rb
|
36
37
|
- spec/lib/core_ext/array_spec.rb
|
37
38
|
- spec/mysql/my.cnf
|
38
39
|
- spec/spec_helper.rb
|