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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4ccdd0bfb2424e55fe11f826fda04d61d38db04
4
- data.tar.gz: 1f030b5880415acaefb2a22f8fc6d6354478d342
3
+ metadata.gz: 5f8ef2e2d96a56685f79cd9131f37a7b92b3dc80
4
+ data.tar.gz: e102f786a7ff21e2c37560b6b1eadde8be59b857
5
5
  SHA512:
6
- metadata.gz: d8e3e16899803cd30a2abcf7e874aa1a7cf0ea6a0e28261669ba887fe14d9185923b84c395f64a0c070740bcc3674502a1a1572e82f82bcbd9940a2089371e0e
7
- data.tar.gz: 5e4a3458687747e5e94c435f6d4fde640e21cd8d9730f146fcb0c313ebc86aca52f88e51f1af73c2bf29959b613a1f94a7ad182079dd2f89b6e21fa012e5936d
6
+ metadata.gz: ef8fa68bfee5b588d5b340090420d75d9cb35786e1ca695f478eb7b736ecd57b8bf2f8f2f32e0297bd30615b9aa6158343162b3f1a4959ae520f7fe13f762daa
7
+ data.tar.gz: 10fc35385fd1ab864fee4aa4f69a3bef3a506c9ad0179803d984717219e94fa9900f009cdba55de453a380b9306989ff26bbf6e6d65f2467b0669fda1bb5f48c
data/README.md CHANGED
@@ -46,6 +46,7 @@ Note: for each root_path, all files under are invoked in alphabetical order
46
46
 
47
47
 
48
48
  ### Changelog
49
+ 0.0.6 - add your own logger if you want
49
50
  0.0.5 - only set env if there are scripts to run
50
51
  0.0.4 - fixed dependency on logging
51
52
  0.0.3 - Added logging
@@ -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 = options[:log_level] || :warn
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
@@ -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
@@ -1,4 +1,4 @@
1
1
  module ScriptRunner
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
4
4
 
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: script-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - ed.eustace