command_exec 0.1.0 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +18 -13
- data/README.md +67 -4
- data/Rakefile +13 -3
- data/lib/command_exec/command.rb +1 -1
- data/lib/command_exec/version.rb +3 -2
- metadata +1 -1
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -12,6 +12,9 @@ GEM
|
|
12
12
|
Platform (>= 0.4.0)
|
13
13
|
open4
|
14
14
|
Platform (0.4.0)
|
15
|
+
activesupport (3.2.6)
|
16
|
+
i18n (~> 0.6)
|
17
|
+
multi_json (~> 1.0)
|
15
18
|
aruba (0.4.11)
|
16
19
|
childprocess (>= 0.2.3)
|
17
20
|
cucumber (>= 1.1.1)
|
@@ -34,35 +37,37 @@ GEM
|
|
34
37
|
ruby-progressbar (~> 0.0.10)
|
35
38
|
gherkin (2.11.1)
|
36
39
|
json (>= 1.4.6)
|
37
|
-
github-markup (0.7.
|
40
|
+
github-markup (0.7.4)
|
41
|
+
i18n (0.6.0)
|
38
42
|
json (1.7.3)
|
39
|
-
multi_json (1.
|
43
|
+
multi_json (1.3.6)
|
40
44
|
open4 (1.3.0)
|
41
45
|
rake (0.9.2.2)
|
42
|
-
redcarpet (1.
|
43
|
-
rspec (2.
|
44
|
-
rspec-core (~> 2.
|
45
|
-
rspec-expectations (~> 2.
|
46
|
-
rspec-mocks (~> 2.
|
47
|
-
rspec-core (2.
|
48
|
-
rspec-expectations (2.
|
46
|
+
redcarpet (2.1.1)
|
47
|
+
rspec (2.11.0)
|
48
|
+
rspec-core (~> 2.11.0)
|
49
|
+
rspec-expectations (~> 2.11.0)
|
50
|
+
rspec-mocks (~> 2.11.0)
|
51
|
+
rspec-core (2.11.1)
|
52
|
+
rspec-expectations (2.11.1)
|
49
53
|
diff-lcs (~> 1.1.3)
|
50
|
-
rspec-instafail (0.2.
|
51
|
-
rspec-mocks (2.
|
54
|
+
rspec-instafail (0.2.4)
|
55
|
+
rspec-mocks (2.11.1)
|
52
56
|
ruby-progressbar (0.0.10)
|
53
|
-
simplecov (0.6.
|
57
|
+
simplecov (0.6.4)
|
54
58
|
multi_json (~> 1.0)
|
55
59
|
simplecov-html (~> 0.5.3)
|
56
60
|
simplecov-html (0.5.3)
|
57
61
|
thor (0.15.4)
|
58
62
|
tmrb (1.2.7)
|
59
63
|
thor
|
60
|
-
yard (0.
|
64
|
+
yard (0.8.2.1)
|
61
65
|
|
62
66
|
PLATFORMS
|
63
67
|
ruby
|
64
68
|
|
65
69
|
DEPENDENCIES
|
70
|
+
activesupport
|
66
71
|
aruba
|
67
72
|
command_exec!
|
68
73
|
fuubar
|
data/README.md
CHANGED
@@ -19,18 +19,81 @@ command = CommandExec::Command.execute( 'command')
|
|
19
19
|
|
20
20
|
#full path to commadn
|
21
21
|
command = CommandExec::Command.execute( 'path/to/command')
|
22
|
+
```
|
23
|
+
|
24
|
+
## Options
|
25
|
+
|
26
|
+
* `:logger`: Logger for output of information
|
22
27
|
|
23
|
-
|
28
|
+
```ruby
|
24
29
|
command = CommandExec::Command.new(
|
25
30
|
'command',
|
26
31
|
:logger => Logger.new($stderr),
|
32
|
+
}
|
33
|
+
command.run
|
34
|
+
```
|
35
|
+
|
36
|
+
* `:options`: Commandline options for executed command
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
command = CommandExec::Command.new(
|
40
|
+
'command',
|
27
41
|
:options => '--command options',
|
28
|
-
|
42
|
+
}
|
43
|
+
command.run
|
44
|
+
```
|
45
|
+
|
46
|
+
* `error_keywords`: Keywords which indicate error(s)
|
47
|
+
|
48
|
+
Are there any keywords in stdout of the command which should be executed, which
|
49
|
+
indicate errors?
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
command = CommandExec::Command.new(
|
53
|
+
'command',
|
29
54
|
:error_keywords => ['key words in', 'stdout with indicate errors' ],
|
55
|
+
}
|
56
|
+
command.run
|
57
|
+
```
|
58
|
+
|
59
|
+
* `:working_directory`: Change working directory of command
|
60
|
+
|
61
|
+
Change working directory to given one before command execution.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
command = CommandExec::Command.new(
|
65
|
+
'command',
|
30
66
|
:working_directory => 'working/directory/where/the/command/should/be/executed/in',
|
67
|
+
}
|
68
|
+
command.run
|
69
|
+
```
|
70
|
+
|
71
|
+
* `logfile`: Logfile of command
|
72
|
+
|
73
|
+
The first 30 lines of the command-logfile will be output by logger if an error
|
74
|
+
occured.
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
command = CommandExec::Command.new(
|
78
|
+
'command',
|
79
|
+
:logfile => 'path/to/logfile.log',
|
80
|
+
}
|
81
|
+
command.run
|
82
|
+
```
|
83
|
+
|
84
|
+
* `:log_level`:
|
85
|
+
|
86
|
+
What should be put to logger? Available choices are :debug, :info, :warn,
|
87
|
+
:error, :fatal, :unkonwn, :silent. If you choose :silent nothing will be
|
88
|
+
output.
|
89
|
+
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
command = CommandExec::Command.new(
|
93
|
+
'command',
|
31
94
|
:logfile => 'path/to/logfile.log',
|
32
|
-
:
|
33
|
-
|
95
|
+
:log_level => :debug
|
96
|
+
}
|
34
97
|
command.run
|
35
98
|
```
|
36
99
|
|
data/Rakefile
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'bundler/gem_tasks'
|
3
3
|
require 'yard'
|
4
4
|
require 'rubygems/package_task'
|
5
|
+
require 'active_support/core_ext/string/strip'
|
5
6
|
|
6
7
|
YARD::Rake::YardocTask.new do |t|
|
7
8
|
t.files = ['lib/**/*.rb', 'README.md', 'LICENCE.md']
|
@@ -22,9 +23,13 @@ namespace :version do
|
|
22
23
|
|
23
24
|
new_version = ENV['VERSION']
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
raw_module_name = File.open(version_file, "r").readlines.grep(/module/).first
|
27
|
+
module_name = raw_module_name.chomp.match(/module\s+(\S+)/) {$1}
|
28
|
+
|
29
|
+
version_string = %Q{#main #{module_name}
|
30
|
+
module #{module_name}
|
31
|
+
VERSION = '#{new_version}'
|
32
|
+
end}
|
28
33
|
|
29
34
|
File.open(version_file, "w") do |f|
|
30
35
|
f.write version_string.strip_heredoc
|
@@ -46,4 +51,9 @@ namespace :version do
|
|
46
51
|
end
|
47
52
|
|
48
53
|
end
|
54
|
+
|
55
|
+
task :restore do
|
56
|
+
sh "git checkout #{version_file}"
|
57
|
+
end
|
58
|
+
|
49
59
|
end
|
data/lib/command_exec/command.rb
CHANGED
@@ -147,7 +147,7 @@ module CommandExec
|
|
147
147
|
# Read the content of the logfile
|
148
148
|
#
|
149
149
|
# @param [Path] file path to logfile
|
150
|
-
# @param [Integer num_of_lines the number of lines which should be read -- e.g. 30 lines = -30
|
150
|
+
# @param [Integer] num_of_lines the number of lines which should be read -- e.g. 30 lines = -30
|
151
151
|
def read_logfile(file, num_of_lines=-30)
|
152
152
|
content = StringIO.new
|
153
153
|
|
data/lib/command_exec/version.rb
CHANGED