ambethia-bj 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +80 -0
- data/LICENSE +1 -0
- data/README +318 -0
- data/Rakefile +20 -0
- data/TODO +53 -0
- data/VERSION +1 -0
- data/bin/bj +692 -0
- data/bj.gemspec +150 -0
- data/init.rb +1 -0
- data/install.rb +214 -0
- data/lib/bj.rb +85 -0
- data/lib/bj/api.rb +164 -0
- data/lib/bj/bj.rb +72 -0
- data/lib/bj/errors.rb +4 -0
- data/lib/bj/joblist.rb +112 -0
- data/lib/bj/logger.rb +50 -0
- data/lib/bj/runner.rb +330 -0
- data/lib/bj/stdext.rb +86 -0
- data/lib/bj/table.rb +426 -0
- data/lib/bj/util.rb +133 -0
- data/plugin/HISTORY +3 -0
- data/plugin/README +142 -0
- data/plugin/Rakefile +22 -0
- data/plugin/init.rb +33 -0
- data/plugin/install.rb +95 -0
- data/plugin/script/bj +55 -0
- data/plugin/tasks/bj_tasks.rake +4 -0
- data/plugin/test/bj_test.rb +8 -0
- data/plugin/uninstall.rb +1 -0
- data/spec/bj.rb +80 -0
- data/spec/helper.rb +85 -0
- data/spec/rails_root/README +256 -0
- data/spec/rails_root/Rakefile +10 -0
- data/spec/rails_root/app/controllers/application.rb +15 -0
- data/spec/rails_root/app/helpers/application_helper.rb +3 -0
- data/spec/rails_root/config/boot.rb +109 -0
- data/spec/rails_root/config/database.yml +23 -0
- data/spec/rails_root/config/environment.rb +67 -0
- data/spec/rails_root/config/environments/development.rb +17 -0
- data/spec/rails_root/config/environments/production.rb +22 -0
- data/spec/rails_root/config/environments/test.rb +22 -0
- data/spec/rails_root/config/initializers/inflections.rb +10 -0
- data/spec/rails_root/config/initializers/mime_types.rb +5 -0
- data/spec/rails_root/config/initializers/new_rails_defaults.rb +15 -0
- data/spec/rails_root/config/routes.rb +41 -0
- data/spec/rails_root/db/development.sqlite3 +0 -0
- data/spec/rails_root/db/migrate/20080909151517_bj_migration0.rb +8 -0
- data/spec/rails_root/db/schema.rb +62 -0
- data/spec/rails_root/doc/README_FOR_APP +2 -0
- data/spec/rails_root/log/development.log +141 -0
- data/spec/rails_root/log/production.log +0 -0
- data/spec/rails_root/log/server.log +0 -0
- data/spec/rails_root/log/test.log +0 -0
- data/spec/rails_root/public/404.html +30 -0
- data/spec/rails_root/public/422.html +30 -0
- data/spec/rails_root/public/500.html +30 -0
- data/spec/rails_root/public/dispatch.cgi +10 -0
- data/spec/rails_root/public/dispatch.fcgi +24 -0
- data/spec/rails_root/public/dispatch.rb +10 -0
- data/spec/rails_root/public/favicon.ico +0 -0
- data/spec/rails_root/public/images/rails.png +0 -0
- data/spec/rails_root/public/index.html +274 -0
- data/spec/rails_root/public/javascripts/application.js +2 -0
- data/spec/rails_root/public/javascripts/controls.js +963 -0
- data/spec/rails_root/public/javascripts/dragdrop.js +972 -0
- data/spec/rails_root/public/javascripts/effects.js +1120 -0
- data/spec/rails_root/public/javascripts/prototype.js +4225 -0
- data/spec/rails_root/public/robots.txt +5 -0
- data/spec/rails_root/script/about +3 -0
- data/spec/rails_root/script/bj +679 -0
- data/spec/rails_root/script/console +3 -0
- data/spec/rails_root/script/dbconsole +3 -0
- data/spec/rails_root/script/destroy +3 -0
- data/spec/rails_root/script/generate +3 -0
- data/spec/rails_root/script/performance/benchmarker +3 -0
- data/spec/rails_root/script/performance/profiler +3 -0
- data/spec/rails_root/script/performance/request +3 -0
- data/spec/rails_root/script/plugin +3 -0
- data/spec/rails_root/script/process/inspector +3 -0
- data/spec/rails_root/script/process/reaper +3 -0
- data/spec/rails_root/script/process/spawner +3 -0
- data/spec/rails_root/script/runner +3 -0
- data/spec/rails_root/script/server +3 -0
- data/spec/rails_root/test/test_helper.rb +38 -0
- data/todo.yml +23 -0
- metadata +184 -0
data/bj.gemspec
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{bj}
|
8
|
+
s.version = "1.2.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Ara T. Howard"]
|
12
|
+
s.date = %q{2009-09-23}
|
13
|
+
s.default_executable = %q{bj}
|
14
|
+
s.description = %q{Backgroundjob (Bj) is a brain dead simple, zero admin, background priority queue for Rails.}
|
15
|
+
s.email = %q{ara.t.howard@gmail.com}
|
16
|
+
s.executables = ["bj"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
"HISTORY",
|
23
|
+
"LICENSE",
|
24
|
+
"README",
|
25
|
+
"Rakefile",
|
26
|
+
"TODO",
|
27
|
+
"VERSION",
|
28
|
+
"bin/bj",
|
29
|
+
"bj.gemspec",
|
30
|
+
"init.rb",
|
31
|
+
"install.rb",
|
32
|
+
"lib/bj.rb",
|
33
|
+
"lib/bj/api.rb",
|
34
|
+
"lib/bj/bj.rb",
|
35
|
+
"lib/bj/errors.rb",
|
36
|
+
"lib/bj/joblist.rb",
|
37
|
+
"lib/bj/logger.rb",
|
38
|
+
"lib/bj/runner.rb",
|
39
|
+
"lib/bj/stdext.rb",
|
40
|
+
"lib/bj/table.rb",
|
41
|
+
"lib/bj/util.rb",
|
42
|
+
"plugin/HISTORY",
|
43
|
+
"plugin/README",
|
44
|
+
"plugin/Rakefile",
|
45
|
+
"plugin/init.rb",
|
46
|
+
"plugin/install.rb",
|
47
|
+
"plugin/script/bj",
|
48
|
+
"plugin/tasks/bj_tasks.rake",
|
49
|
+
"plugin/test/bj_test.rb",
|
50
|
+
"plugin/uninstall.rb",
|
51
|
+
"spec/bj.rb",
|
52
|
+
"spec/helper.rb",
|
53
|
+
"spec/rails_root/README",
|
54
|
+
"spec/rails_root/Rakefile",
|
55
|
+
"spec/rails_root/app/controllers/application.rb",
|
56
|
+
"spec/rails_root/app/helpers/application_helper.rb",
|
57
|
+
"spec/rails_root/config/boot.rb",
|
58
|
+
"spec/rails_root/config/database.yml",
|
59
|
+
"spec/rails_root/config/environment.rb",
|
60
|
+
"spec/rails_root/config/environments/development.rb",
|
61
|
+
"spec/rails_root/config/environments/production.rb",
|
62
|
+
"spec/rails_root/config/environments/test.rb",
|
63
|
+
"spec/rails_root/config/initializers/inflections.rb",
|
64
|
+
"spec/rails_root/config/initializers/mime_types.rb",
|
65
|
+
"spec/rails_root/config/initializers/new_rails_defaults.rb",
|
66
|
+
"spec/rails_root/config/routes.rb",
|
67
|
+
"spec/rails_root/db/development.sqlite3",
|
68
|
+
"spec/rails_root/db/migrate/20080909151517_bj_migration0.rb",
|
69
|
+
"spec/rails_root/db/schema.rb",
|
70
|
+
"spec/rails_root/doc/README_FOR_APP",
|
71
|
+
"spec/rails_root/log/development.log",
|
72
|
+
"spec/rails_root/log/production.log",
|
73
|
+
"spec/rails_root/log/server.log",
|
74
|
+
"spec/rails_root/log/test.log",
|
75
|
+
"spec/rails_root/public/404.html",
|
76
|
+
"spec/rails_root/public/422.html",
|
77
|
+
"spec/rails_root/public/500.html",
|
78
|
+
"spec/rails_root/public/dispatch.cgi",
|
79
|
+
"spec/rails_root/public/dispatch.fcgi",
|
80
|
+
"spec/rails_root/public/dispatch.rb",
|
81
|
+
"spec/rails_root/public/favicon.ico",
|
82
|
+
"spec/rails_root/public/images/rails.png",
|
83
|
+
"spec/rails_root/public/index.html",
|
84
|
+
"spec/rails_root/public/javascripts/application.js",
|
85
|
+
"spec/rails_root/public/javascripts/controls.js",
|
86
|
+
"spec/rails_root/public/javascripts/dragdrop.js",
|
87
|
+
"spec/rails_root/public/javascripts/effects.js",
|
88
|
+
"spec/rails_root/public/javascripts/prototype.js",
|
89
|
+
"spec/rails_root/public/robots.txt",
|
90
|
+
"spec/rails_root/script/about",
|
91
|
+
"spec/rails_root/script/bj",
|
92
|
+
"spec/rails_root/script/console",
|
93
|
+
"spec/rails_root/script/dbconsole",
|
94
|
+
"spec/rails_root/script/destroy",
|
95
|
+
"spec/rails_root/script/generate",
|
96
|
+
"spec/rails_root/script/performance/benchmarker",
|
97
|
+
"spec/rails_root/script/performance/profiler",
|
98
|
+
"spec/rails_root/script/performance/request",
|
99
|
+
"spec/rails_root/script/plugin",
|
100
|
+
"spec/rails_root/script/process/inspector",
|
101
|
+
"spec/rails_root/script/process/reaper",
|
102
|
+
"spec/rails_root/script/process/spawner",
|
103
|
+
"spec/rails_root/script/runner",
|
104
|
+
"spec/rails_root/script/server",
|
105
|
+
"spec/rails_root/test/test_helper.rb",
|
106
|
+
"todo.yml"
|
107
|
+
]
|
108
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
109
|
+
s.require_paths = ["lib"]
|
110
|
+
s.rubygems_version = %q{1.3.5}
|
111
|
+
s.summary = %q{Backgroundjob (Bj) is a brain dead simple, zero admin, background priority queue for Rails.}
|
112
|
+
s.test_files = [
|
113
|
+
"spec/bj.rb",
|
114
|
+
"spec/helper.rb",
|
115
|
+
"spec/rails_root/app/controllers/application.rb",
|
116
|
+
"spec/rails_root/app/helpers/application_helper.rb",
|
117
|
+
"spec/rails_root/config/boot.rb",
|
118
|
+
"spec/rails_root/config/environment.rb",
|
119
|
+
"spec/rails_root/config/environments/development.rb",
|
120
|
+
"spec/rails_root/config/environments/production.rb",
|
121
|
+
"spec/rails_root/config/environments/test.rb",
|
122
|
+
"spec/rails_root/config/initializers/inflections.rb",
|
123
|
+
"spec/rails_root/config/initializers/mime_types.rb",
|
124
|
+
"spec/rails_root/config/initializers/new_rails_defaults.rb",
|
125
|
+
"spec/rails_root/config/routes.rb",
|
126
|
+
"spec/rails_root/db/migrate/20080909151517_bj_migration0.rb",
|
127
|
+
"spec/rails_root/db/schema.rb",
|
128
|
+
"spec/rails_root/public/dispatch.rb",
|
129
|
+
"spec/rails_root/test/test_helper.rb"
|
130
|
+
]
|
131
|
+
|
132
|
+
if s.respond_to? :specification_version then
|
133
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
134
|
+
s.specification_version = 3
|
135
|
+
|
136
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
137
|
+
s.add_runtime_dependency(%q<main>, [">= 2.6.0"])
|
138
|
+
s.add_runtime_dependency(%q<systemu>, [">= 1.2.0"])
|
139
|
+
s.add_runtime_dependency(%q<orderedhash>, [">= 0.0.3"])
|
140
|
+
else
|
141
|
+
s.add_dependency(%q<main>, [">= 2.6.0"])
|
142
|
+
s.add_dependency(%q<systemu>, [">= 1.2.0"])
|
143
|
+
s.add_dependency(%q<orderedhash>, [">= 0.0.3"])
|
144
|
+
end
|
145
|
+
else
|
146
|
+
s.add_dependency(%q<main>, [">= 2.6.0"])
|
147
|
+
s.add_dependency(%q<systemu>, [">= 1.2.0"])
|
148
|
+
s.add_dependency(%q<orderedhash>, [">= 0.0.3"])
|
149
|
+
end
|
150
|
+
end
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bj'
|
data/install.rb
ADDED
@@ -0,0 +1,214 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rbconfig'
|
3
|
+
require 'find'
|
4
|
+
require 'ftools'
|
5
|
+
require 'tempfile'
|
6
|
+
include Config
|
7
|
+
|
8
|
+
LIBDIR = "lib"
|
9
|
+
LIBDIR_MODE = 0644
|
10
|
+
|
11
|
+
BINDIR = "bin"
|
12
|
+
BINDIR_MODE = 0755
|
13
|
+
|
14
|
+
|
15
|
+
$srcdir = CONFIG["srcdir"]
|
16
|
+
$version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"]
|
17
|
+
$libdir = File.join(CONFIG["libdir"], "ruby", $version)
|
18
|
+
$archdir = File.join($libdir, CONFIG["arch"])
|
19
|
+
$site_libdir = $:.find {|x| x =~ /site_ruby$/}
|
20
|
+
$bindir = CONFIG["bindir"] || CONFIG['BINDIR']
|
21
|
+
$ruby_install_name = CONFIG['ruby_install_name'] || CONFIG['RUBY_INSTALL_NAME'] || 'ruby'
|
22
|
+
$ruby_ext = CONFIG['EXEEXT'] || ''
|
23
|
+
$ruby = File.join($bindir, ($ruby_install_name + $ruby_ext))
|
24
|
+
|
25
|
+
if !$site_libdir
|
26
|
+
$site_libdir = File.join($libdir, "site_ruby")
|
27
|
+
elsif $site_libdir !~ %r/#{Regexp.quote($version)}/
|
28
|
+
$site_libdir = File.join($site_libdir, $version)
|
29
|
+
end
|
30
|
+
|
31
|
+
def install_rb(srcdir=nil, destdir=nil, mode=nil, bin=nil)
|
32
|
+
#{{{
|
33
|
+
path = []
|
34
|
+
dir = []
|
35
|
+
Find.find(srcdir) do |f|
|
36
|
+
next unless FileTest.file?(f)
|
37
|
+
next if (f = f[srcdir.length+1..-1]) == nil
|
38
|
+
next if (/CVS$/ =~ File.dirname(f))
|
39
|
+
next if (/\.svn/ =~ File.dirname(f))
|
40
|
+
next if f =~ %r/\.lnk/
|
41
|
+
next if f =~ %r/\.svn/
|
42
|
+
next if f =~ %r/\.swp/
|
43
|
+
next if f =~ %r/\.svn/
|
44
|
+
path.push f
|
45
|
+
dir |= [File.dirname(f)]
|
46
|
+
end
|
47
|
+
for f in dir
|
48
|
+
next if f == "."
|
49
|
+
next if f == "CVS"
|
50
|
+
File::makedirs(File.join(destdir, f))
|
51
|
+
end
|
52
|
+
for f in path
|
53
|
+
next if (/\~$/ =~ f)
|
54
|
+
next if (/^\./ =~ File.basename(f))
|
55
|
+
unless bin
|
56
|
+
File::install(File.join(srcdir, f), File.join(destdir, f), mode, true)
|
57
|
+
else
|
58
|
+
from = File.join(srcdir, f)
|
59
|
+
to = File.join(destdir, f)
|
60
|
+
shebangify(from) do |sf|
|
61
|
+
$deferr.print from, " -> ", File::catname(from, to), "\n"
|
62
|
+
$deferr.printf "chmod %04o %s\n", mode, to
|
63
|
+
File::install(sf, to, mode, false)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
#}}}
|
68
|
+
end
|
69
|
+
def shebangify f
|
70
|
+
#{{{
|
71
|
+
open(f) do |fd|
|
72
|
+
buf = fd.read 42
|
73
|
+
if buf =~ %r/^\s*#\s*!.*ruby/o
|
74
|
+
ftmp = Tempfile::new("#{ $$ }_#{ File::basename(f) }")
|
75
|
+
begin
|
76
|
+
fd.rewind
|
77
|
+
ftmp.puts "#!#{ $ruby }"
|
78
|
+
while((buf = fd.read(8192)))
|
79
|
+
ftmp.write buf
|
80
|
+
end
|
81
|
+
ftmp.close
|
82
|
+
yield ftmp.path
|
83
|
+
ensure
|
84
|
+
ftmp.close!
|
85
|
+
end
|
86
|
+
else
|
87
|
+
yield f
|
88
|
+
end
|
89
|
+
end
|
90
|
+
#}}}
|
91
|
+
end
|
92
|
+
def ARGV.switch
|
93
|
+
#{{{
|
94
|
+
return nil if self.empty?
|
95
|
+
arg = self.shift
|
96
|
+
return nil if arg == '--'
|
97
|
+
if arg =~ /^-(.)(.*)/
|
98
|
+
return arg if $1 == '-'
|
99
|
+
raise 'unknown switch "-"' if $2.index('-')
|
100
|
+
self.unshift "-#{$2}" if $2.size > 0
|
101
|
+
"-#{$1}"
|
102
|
+
else
|
103
|
+
self.unshift arg
|
104
|
+
nil
|
105
|
+
end
|
106
|
+
#}}}
|
107
|
+
end
|
108
|
+
def ARGV.req_arg
|
109
|
+
#{{{
|
110
|
+
self.shift || raise('missing argument')
|
111
|
+
#}}}
|
112
|
+
end
|
113
|
+
def linkify d, linked = []
|
114
|
+
#--{{{
|
115
|
+
if test ?d, d
|
116
|
+
versioned = Dir[ File::join(d, "*-[0-9].[0-9].[0-9].rb") ]
|
117
|
+
versioned.each do |v|
|
118
|
+
src, dst = v, v.gsub(%r/\-[\d\.]+\.rb$/, '.rb')
|
119
|
+
lnk = nil
|
120
|
+
begin
|
121
|
+
if test ?l, dst
|
122
|
+
lnk = "#{ dst }.lnk"
|
123
|
+
puts "#{ dst } -> #{ lnk }"
|
124
|
+
File::rename dst, lnk
|
125
|
+
end
|
126
|
+
unless test ?e, dst
|
127
|
+
puts "#{ src } -> #{ dst }"
|
128
|
+
File::copy src, dst
|
129
|
+
linked << dst
|
130
|
+
end
|
131
|
+
ensure
|
132
|
+
if lnk
|
133
|
+
at_exit do
|
134
|
+
puts "#{ lnk } -> #{ dst }"
|
135
|
+
File::rename lnk, dst
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
linked
|
142
|
+
#--}}}
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
#
|
147
|
+
# main program
|
148
|
+
#
|
149
|
+
|
150
|
+
libdir = $site_libdir
|
151
|
+
bindir = $bindir
|
152
|
+
no_linkify = false
|
153
|
+
linked = nil
|
154
|
+
help = false
|
155
|
+
|
156
|
+
usage = <<-usage
|
157
|
+
#{ File::basename $0 }
|
158
|
+
-d, --destdir <destdir>
|
159
|
+
-l, --libdir <libdir>
|
160
|
+
-b, --bindir <bindir>
|
161
|
+
-r, --ruby <ruby>
|
162
|
+
-n, --no_linkify
|
163
|
+
-s, --sudo
|
164
|
+
-h, --help
|
165
|
+
usage
|
166
|
+
|
167
|
+
begin
|
168
|
+
while switch = ARGV.switch
|
169
|
+
case switch
|
170
|
+
when '-d', '--destdir'
|
171
|
+
libdir = ARGV.req_arg
|
172
|
+
when '-l', '--libdir'
|
173
|
+
libdir = ARGV.req_arg
|
174
|
+
when '-b', '--bindir'
|
175
|
+
bindir = ARGV.req_arg
|
176
|
+
when '-r', '--ruby'
|
177
|
+
$ruby = ARGV.req_arg
|
178
|
+
when '-n', '--no_linkify'
|
179
|
+
no_linkify = true
|
180
|
+
when '-s', '--sudo'
|
181
|
+
sudo = 'sudo'
|
182
|
+
when '-h', '--help'
|
183
|
+
help = true
|
184
|
+
else
|
185
|
+
raise "unknown switch #{switch.dump}"
|
186
|
+
end
|
187
|
+
end
|
188
|
+
rescue
|
189
|
+
STDERR.puts $!.to_s
|
190
|
+
STDERR.puts usage
|
191
|
+
exit 1
|
192
|
+
end
|
193
|
+
|
194
|
+
if help
|
195
|
+
STDOUT.puts usage
|
196
|
+
exit
|
197
|
+
end
|
198
|
+
|
199
|
+
system "#{ sudo } #{ $ruby } pre-install.rb" if test(?s, 'pre-install.rb')
|
200
|
+
|
201
|
+
unless no_linkify
|
202
|
+
linked = linkify('lib') + linkify('bin')
|
203
|
+
end
|
204
|
+
|
205
|
+
system "#{ $ruby } extconf.rb && make && #{ sudo } make install" if test(?s, 'extconf.rb')
|
206
|
+
|
207
|
+
install_rb(LIBDIR, libdir, LIBDIR_MODE)
|
208
|
+
install_rb(BINDIR, bindir, BINDIR_MODE, bin=true)
|
209
|
+
|
210
|
+
if linked
|
211
|
+
linked.each{|path| File::rm_f path}
|
212
|
+
end
|
213
|
+
|
214
|
+
system "#{ sudo } #{ $ruby } post-install.rb" if test(?s, 'post-install.rb')
|
data/lib/bj.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
unless defined? Bj
|
2
|
+
class Bj
|
3
|
+
#
|
4
|
+
# constants and associated attrs
|
5
|
+
#
|
6
|
+
Bj::VERSION = "1.2.1"
|
7
|
+
def self.version() Bj::VERSION end
|
8
|
+
|
9
|
+
Bj::LIBDIR = File.expand_path(File::join(File.dirname(__FILE__), "bj")) + File::SEPARATOR unless
|
10
|
+
defined? Bj::LIBDIR
|
11
|
+
def self.libdir(*value)
|
12
|
+
unless value.empty?
|
13
|
+
File.join libdir, *value
|
14
|
+
else
|
15
|
+
Bj::LIBDIR
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module EXIT
|
20
|
+
SUCCESS = 0
|
21
|
+
FAILURE = 1
|
22
|
+
WARNING = 42
|
23
|
+
end
|
24
|
+
#
|
25
|
+
# built-in
|
26
|
+
#
|
27
|
+
require "socket"
|
28
|
+
require "yaml"
|
29
|
+
require "thread"
|
30
|
+
require "rbconfig"
|
31
|
+
require "set"
|
32
|
+
require "erb"
|
33
|
+
require "tempfile"
|
34
|
+
#
|
35
|
+
# bootstrap rubygems
|
36
|
+
#
|
37
|
+
begin
|
38
|
+
require "rubygems"
|
39
|
+
rescue LoadError
|
40
|
+
42
|
41
|
+
end
|
42
|
+
#
|
43
|
+
# rubyforge/remote
|
44
|
+
#
|
45
|
+
require "active_record"
|
46
|
+
#
|
47
|
+
# rubyforge/remote or local/lib
|
48
|
+
#
|
49
|
+
%w[ systemu orderedhash fattr ].each do |lib|
|
50
|
+
begin
|
51
|
+
require lib
|
52
|
+
rescue
|
53
|
+
require libdir(lib)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
#
|
57
|
+
# local
|
58
|
+
#
|
59
|
+
load libdir("stdext.rb")
|
60
|
+
load libdir("util.rb")
|
61
|
+
load libdir("errors.rb")
|
62
|
+
load libdir("logger.rb")
|
63
|
+
load libdir("bj.rb")
|
64
|
+
load libdir("joblist.rb")
|
65
|
+
load libdir("table.rb")
|
66
|
+
load libdir("runner.rb")
|
67
|
+
load libdir("api.rb")
|
68
|
+
#
|
69
|
+
# an imperfect reloading hook - because neither rails' plugins nor gems provide one, sigh...
|
70
|
+
#
|
71
|
+
def self.reload!
|
72
|
+
background = nil
|
73
|
+
::Object.module_eval do
|
74
|
+
background = Bj.runner.background
|
75
|
+
remove_const :Bj rescue nil
|
76
|
+
remove_const :BackgroundJob rescue nil
|
77
|
+
end
|
78
|
+
returned = load __FILE__ rescue nil
|
79
|
+
Bj.runner.background = background if background
|
80
|
+
returned
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
BackgroundJob = Bj
|
85
|
+
end
|