ro_thor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +5 -0
  3. data/lib/ro_thor.rb +67 -0
  4. metadata +59 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 86bcef0b87b70e17aaf53e3bdb89fadd8d2e9bd6
4
+ data.tar.gz: 9d5775fbfcdbcc0e4408153cc01ae3d4b56a4b9e
5
+ SHA512:
6
+ metadata.gz: 68d0f23cf5c45a99d5fec901800d9cf21a67e2baadbcc211bcc7a2aa077d0e7917bd10de4c914426f6e2881be3da3a5e4735dd84aaaefcfbf729604ecf67645e
7
+ data.tar.gz: 524af07b894d036cff2241e5c5ae5ef0a5543374adc1ee7cf3b198bb25218d553b2e360ef03eeaf958088e1167c124b02fd68d510aa69568b08e71c7467e6196
data/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # RoThor
2
+ mk thor more simple for writing
3
+
4
+ ## License
5
+ [MIT License](http://www.opensource.org/licenses/MIT)
data/lib/ro_thor.rb ADDED
@@ -0,0 +1,67 @@
1
+ require 'thor'
2
+ require 'open3'
3
+ require 'active_support/core_ext/array'
4
+
5
+ class RoThor < Thor
6
+ class << self
7
+ def usg(str, *args, &blk)
8
+ desc(str, "")
9
+ end
10
+
11
+ def create_command(*args, &blk)
12
+ if @usage.nil?
13
+ return
14
+ end
15
+ super
16
+ end
17
+
18
+ def st(*args, &blk)
19
+ start(*args, &blk)
20
+ end
21
+ end
22
+
23
+ def sys(*args, &blk)
24
+ cmd = args.join(" ")
25
+ puts "run '#{cmd}'"
26
+ system cmd
27
+ end
28
+
29
+ def read(f, *args, &blk)
30
+ bash "sudo mv #{f} #{buffer}"
31
+ RoFile.read(buffer)
32
+ end
33
+
34
+ def buffer(*args, &blk)
35
+ "/tmp/ro_thor_buffer"
36
+ end
37
+
38
+ def write(f, *args, &blk)
39
+ File.write(buffer, *args, &blk)
40
+ pr = Pathname.new(f).parent
41
+ bash("mkdir -p #{pr}; mv #{buffer} #{f}")
42
+ end
43
+
44
+ class BashErr < StandardError
45
+ end
46
+
47
+ def bash_shutup(*args, &blk)
48
+ bash(*args, shutup: true, &blk)
49
+ end
50
+
51
+ def bash(*args, &blk)
52
+ opts = args.extract_options!
53
+ cmd = args.join("")
54
+ puts "run '#{cmd}'"
55
+ out, err, status = Open3.capture3(cmd)
56
+
57
+ unless opts[:shutup]
58
+ puts out
59
+ end
60
+
61
+ unless status.success?
62
+ raise BashErr, err
63
+ end
64
+
65
+ out
66
+ end
67
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ro_thor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - ''
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: ''
28
+ email:
29
+ - ''
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - README.md
35
+ - lib/ro_thor.rb
36
+ homepage: ''
37
+ licenses: []
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.4.5
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: ''
59
+ test_files: []