bj 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/bj +9 -4
- data/lib/bj.rb +1 -1
- data/lib/bj/api.rb +5 -1
- data/lib/bj/table.rb +9 -2
- metadata +1 -1
data/bin/bj
CHANGED
@@ -52,12 +52,11 @@ Main {
|
|
52
52
|
Bj can be installed two ways: as a gem or as a plugin.
|
53
53
|
|
54
54
|
gem:
|
55
|
-
|
56
55
|
1) $sudo gem install bj
|
57
|
-
2) bj
|
56
|
+
2) add "require 'bj'" to config/environment.rb
|
57
|
+
3) bj setup
|
58
58
|
|
59
59
|
plugin:
|
60
|
-
|
61
60
|
1) ./script/plugin install http://codeforpeople.rubyforge.org/svn/rails/plugins/bj
|
62
61
|
2) ./script/bj setup
|
63
62
|
|
@@ -86,9 +85,15 @@ Main {
|
|
86
85
|
|
87
86
|
jobs = Bj.submit 'echo foobar', :tag => 'simple job'
|
88
87
|
|
89
|
-
jobs = Bj.submit '/bin/cat', :stdin => 'in the hat'
|
88
|
+
jobs = Bj.submit '/bin/cat', :stdin => 'in the hat', :priority => 42
|
90
89
|
|
91
90
|
jobs = Bj.submit './script/runner ./scripts/a.rb', :rails_env => 'production'
|
91
|
+
|
92
|
+
jobs = Bj.submit './script/runner /dev/stdin',
|
93
|
+
:stdin => 'p RAILS_ENV',
|
94
|
+
:tag => 'dynamic ruby code'
|
95
|
+
|
96
|
+
jobs Bj.submit array_of_commands, :priority => 451
|
92
97
|
|
93
98
|
when jobs are run, they are run in RAILS_ROOT. various attributes are
|
94
99
|
available *only* once the job has finished. you can check whether or not a
|
data/lib/bj.rb
CHANGED
data/lib/bj/api.rb
CHANGED
@@ -30,10 +30,14 @@ class Bj
|
|
30
30
|
#
|
31
31
|
# jobs = Bj.submit 'echo foobar', :tag => 'simple job'
|
32
32
|
#
|
33
|
-
# jobs = Bj.submit '/bin/cat', :stdin => 'in the hat'
|
33
|
+
# jobs = Bj.submit '/bin/cat', :stdin => 'in the hat', :priority => 42
|
34
34
|
#
|
35
35
|
# jobs = Bj.submit './script/runner ./scripts/a.rb', :rails_env => 'production'
|
36
36
|
#
|
37
|
+
# jobs = Bj.submit './script/runner /dev/stdin', :stdin => 'p RAILS_ENV', :tag => 'dynamic ruby code'
|
38
|
+
#
|
39
|
+
# jobs = Bj.submit array_of_commands, :priority => 451
|
40
|
+
#
|
37
41
|
# when jobs are run, they are run in RAILS_ROOT. various attributes are
|
38
42
|
# available *only* once the job has finished. you can check whether or not
|
39
43
|
# a job is finished by using the #finished method, which simple does a
|
data/lib/bj/table.rb
CHANGED
@@ -226,11 +226,18 @@ class Bj
|
|
226
226
|
t.column "cast" , :text
|
227
227
|
end
|
228
228
|
|
229
|
-
|
229
|
+
begin
|
230
|
+
add_index table.table_name, %w[ hostname key ], :unique => true
|
231
|
+
rescue Exception
|
232
|
+
STDERR.puts "WARNING: your database does not support unique indexes on text fields!?"
|
233
|
+
end
|
230
234
|
end
|
231
235
|
|
232
236
|
define_method(:down) do
|
233
|
-
|
237
|
+
begin
|
238
|
+
remove_index table.table_name, :column => %w[ hostname key ]
|
239
|
+
rescue Exception
|
240
|
+
end
|
234
241
|
drop_table table.table_name
|
235
242
|
end
|
236
243
|
}
|