execute 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +2 -0
  4. data/lib/cmd.rb +38 -0
  5. metadata +102 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 798cb7001f37401533422316c77c6e1bc4f4aee3
4
+ data.tar.gz: 975768244e8e9784bd6c20ffdd214e9950d0075b
5
+ SHA512:
6
+ metadata.gz: 25babf483591aced7c3ad78a08cdaa39a801c97bcf662ee6d472870aa97f4c306850952d124e85827219511d30bf48df26889e68d501239d44a2d9632348ffc7
7
+ data.tar.gz: 47647de07f2ae45ac72e06955b14fdcd19ebf98c6f895449caed3dab99206907a1225629f25eaad9b02274b061153dc2b0a627ddb30d51409b6b2c8a5ddc4207
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 kevin-marshall
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,2 @@
1
+ # execute
2
+ ruby gem which executes a command line function
@@ -0,0 +1,38 @@
1
+ require 'open3'
2
+
3
+ class CMD < Hash
4
+ def initialize(cmd, options=nil)
5
+ self[:output] = ''
6
+ self[:error] = ''
7
+ self[:ignore_exit_code] = false
8
+ self[:debug] = false
9
+ self[:quiet] = false
10
+
11
+ self[:command]=cmd
12
+ options.each { |key, value| self[key] = value} unless(options.nil?)
13
+ end
14
+
15
+ def execute
16
+ begin
17
+ puts self[:command] unless(self[:quiet])
18
+ self[:output],self[:error], self[:exit_code] = Open3.capture3(self[:command])
19
+ self[:exit_code]=self[:exit_code].to_i
20
+
21
+ if(self[:debug])
22
+ puts "command: #{self[:command]}" if(self[:quiet])
23
+ puts "output: #{self[:output]}"
24
+ puts "error: #{self[:error]}"
25
+ puts "exit_code: #{self[:exit_code]}"
26
+ end
27
+ rescue Exception => e
28
+ self[:error] = "Exception: " + e.to_s
29
+ self[:exit_code]=1 unless(has_key('exit_code'))
30
+ end
31
+
32
+ if((self[:exit_code] != 0) && !self[:ignore_exit_code])
33
+ exception_text = self[:error]
34
+ exception_text = self[:output] if(self[:error].empty?)
35
+ raise exception_text
36
+ end
37
+ end
38
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: execute
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kevin Marshall
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-08-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: dev
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Class to execute system commands
70
+ email: KCCKSMarshall@gmail.com
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - LICENSE
76
+ - README.md
77
+ - lib/cmd.rb
78
+ homepage: http://rubygems.org/gems/execute
79
+ licenses:
80
+ - Apache 2.0
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.9.1
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.4.5
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Class to execute system commands
102
+ test_files: []