script-runner 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/script-runner.rb +10 -6
- data/lib/script-runner/main.rb +2 -5
- data/lib/script-runner/version.rb +1 -1
- data/spec/main_spec.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f8ef2e2d96a56685f79cd9131f37a7b92b3dc80
|
4
|
+
data.tar.gz: e102f786a7ff21e2c37560b6b1eadde8be59b857
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef8fa68bfee5b588d5b340090420d75d9cb35786e1ca695f478eb7b736ecd57b8bf2f8f2f32e0297bd30615b9aa6158343162b3f1a4959ae520f7fe13f762daa
|
7
|
+
data.tar.gz: 10fc35385fd1ab864fee4aa4f69a3bef3a506c9ad0179803d984717219e94fa9900f009cdba55de453a380b9306989ff26bbf6e6d65f2467b0669fda1bb5f48c
|
data/README.md
CHANGED
data/lib/script-runner.rb
CHANGED
@@ -14,18 +14,22 @@ module ScriptRunner
|
|
14
14
|
# -- :log_level - one of :debug, :info, :warn, :errror
|
15
15
|
# @block - a block to handle the output of the script if non is given it is sent to the console
|
16
16
|
def self.run( paths, env_vars, options = {}, &block)
|
17
|
+
logger = options[:logger] || get_logger(options[:log_level])
|
18
|
+
runner = ScriptRunner::Main.new(logger)
|
19
|
+
error_handler = options[:error_handler]
|
20
|
+
runner.run(paths, env_vars, error_handler, &block)
|
21
|
+
end
|
17
22
|
|
23
|
+
private
|
24
|
+
def get_logger(log_level)
|
18
25
|
Logging.appenders.stdout(
|
19
26
|
:layout => Logging.layouts.pattern(:pattern => '[%c][%-5l] %m\n'),
|
20
27
|
:color_scheme => 'bright')
|
21
|
-
|
22
28
|
logger = Logging.logger['script-runner']
|
23
29
|
logger.add_appenders(Logging.appenders.stdout)
|
24
|
-
logger.level =
|
25
|
-
|
26
|
-
runner = ScriptRunner::Main.new(logger)
|
27
|
-
error_handler = options[:error_handler]
|
28
|
-
runner.run(paths, env_vars, error_handler, &block)
|
30
|
+
logger.level = log_level || :warn
|
31
|
+
logger
|
29
32
|
end
|
30
33
|
|
34
|
+
|
31
35
|
end
|
data/lib/script-runner/main.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'logging'
|
2
|
-
|
3
1
|
module ScriptRunner
|
4
2
|
|
5
3
|
class Main
|
@@ -29,13 +27,12 @@ module ScriptRunner
|
|
29
27
|
|
30
28
|
non_runnable = all_paths - runnable
|
31
29
|
|
32
|
-
@logger.debug "runnable: #{runnable}"
|
33
|
-
|
34
30
|
non_runnable.each{ |nr|
|
35
31
|
@logger.warn "#{nr} is not runnable - skipping"
|
36
32
|
}
|
37
33
|
|
38
34
|
runnable.each{ |p|
|
35
|
+
@logger.info "run => #{p}"
|
39
36
|
exec(p, error_handler, &block)
|
40
37
|
}
|
41
38
|
end
|
@@ -69,7 +66,7 @@ module ScriptRunner
|
|
69
66
|
File.readlines(p).each do |line|
|
70
67
|
if line.include? "="
|
71
68
|
key, value = line.split("=")
|
72
|
-
@logger.debug "set: #{key} -> #{value}"
|
69
|
+
@logger.debug "set: #{key.strip} -> #{value.strip}"
|
73
70
|
ENV[key.strip] = value.strip
|
74
71
|
end
|
75
72
|
end
|
data/spec/main_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'script-runner'
|
2
|
+
require 'logging'
|
2
3
|
|
3
4
|
describe ScriptRunner do
|
4
5
|
|
@@ -55,4 +56,5 @@ describe ScriptRunner do
|
|
55
56
|
p = ScriptRunner.run(scripts("non_runnable"), env("one")) { |output| @all_output << output }
|
56
57
|
@error_files.length.should eql 0
|
57
58
|
end
|
59
|
+
|
58
60
|
end
|