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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9a89eaec74757ed5b7d6f6dfbc19ecf07cfd06eb
4
- data.tar.gz: a7888146d0c8e14f640a6dde8f7c1df53f370a82
3
+ metadata.gz: 76c1ed38826537b965c5b523544136fccc42198d
4
+ data.tar.gz: f5d614fe5a1ec1b659e7ea348fef84a1d321014c
5
5
  SHA512:
6
- metadata.gz: a9451328b5f0455ec365b8ee272015920ed5edd970a5f6cc84159bb34952a26e15f9814e46cbfb49483c231e45a5ac39b2dcddc4c5c2a56f7f3559567f28c84d
7
- data.tar.gz: 2eb253567f3be13468eba74f8f19465350d4c2af4c993bd83a15f155c36d7e8f40c0f6f4377125a6b1b828430a2f024eccf59491ce01d1bc898ffb4b5a3c382c
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
- bash cmd
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
- bash "sudo cp -f #{f} #{buffer}"
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
- bash("sudo mkdir -p #{pr}; sudo cp -f #{buffer} #{f}")
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
 
@@ -3,9 +3,8 @@ require 'spec_helper'
3
3
  class TryArr < RoThor
4
4
  def opts(*args, &blk)
5
5
  args, opts = args.ro_opts
6
- return opts
6
+ opts
7
7
  end
8
-
9
8
  end
10
9
 
11
10
  describe "RoThor.new" do
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.8
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-06 00:00:00.000000000 Z
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