jobby 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/bin/jobby CHANGED
@@ -38,7 +38,7 @@ OptionParser.new do |opts|
38
38
  end
39
39
 
40
40
  opts.on("--version", "Show version") do
41
- puts "0.1.3"
41
+ puts "0.2.0"
42
42
  exit
43
43
  end
44
44
 
data/lib/runner.rb CHANGED
@@ -32,6 +32,14 @@ module Jobby
32
32
  message "--input not supplied, reading from STDIN (use ctrl-d to end input)"
33
33
  @options[:input] = $stdin.read
34
34
  end
35
+ create_prerun_proc
36
+ end
37
+
38
+ # Makes a Proc that loads the given filepath, passing in the logger object.
39
+ def create_prerun_proc
40
+ if @options[:prerun]
41
+ @options[:prerun_proc] = Proc.new { |logger| load File.expand_path(@options[:prerun]) }
42
+ end
35
43
  end
36
44
 
37
45
  # Tries to connect a client to the server. If there isn't a server detected on
@@ -66,7 +74,7 @@ module Jobby
66
74
  exit if @options[:flush] or @options[:wipe]
67
75
  fork do
68
76
  begin
69
- Jobby::Server.new(@options[:socket], @options[:max_child_processes], @options[:log], @options[:prerun]).run(&get_proc_from_options)
77
+ Jobby::Server.new(@options[:socket], @options[:max_child_processes], @options[:log], @options[:prerun_proc]).run(&get_proc_from_options)
70
78
  rescue Exception => exception
71
79
  return error(exception.message)
72
80
  end
data/lib/server.rb CHANGED
@@ -71,7 +71,7 @@ module Jobby
71
71
  terminate
72
72
  end
73
73
  if @prerun
74
- load File.expand_path(@prerun)
74
+ @prerun.call(@logger)
75
75
  end
76
76
  start_forking_thread(block)
77
77
  loop do
data/spec/server_spec.rb CHANGED
@@ -179,7 +179,7 @@ describe Jobby::Server do
179
179
 
180
180
  it "should be able to run a Ruby file before any forking" do
181
181
  terminate_server
182
- run_server(@socket, 1, @log_filepath, "spec/file_for_prerunning.rb") do
182
+ run_server(@socket, 1, @log_filepath, Proc.new { |logger| load "spec/file_for_prerunning.rb" }) do
183
183
  sleep 2
184
184
  if defined?(Preran)
185
185
  File.open(@child_filepath, "a+") do |file|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Somerville
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-08 00:00:00 +01:00
12
+ date: 2008-07-09 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15