raque 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/bin/raque CHANGED
@@ -11,10 +11,10 @@ EOF
11
11
  end
12
12
 
13
13
  require 'resque'
14
- require 'raque'
14
+ require 'raque/runner'
15
15
 
16
16
  STDOUT.puts "Connecting to Redis at #{ARGV[0].inspect}"
17
17
  Resque.redis = ARGV[0]
18
18
  STDOUT.puts "Adding #{ARGV[1]} to Raque queue"
19
- Resque.enqueue Raque, ARGV[1], ARGV[2]
19
+ Resque.enqueue Raque::Runner, ARGV[1], ARGV[2]
20
20
 
@@ -0,0 +1,41 @@
1
+ require 'logger'
2
+ require 'rake'
3
+
4
+ module Raque
5
+ class Runner
6
+ @queue = :raque
7
+
8
+ def self.perform task_string, output_file = false
9
+ logger = Logger.new(output_file || STDOUT)
10
+
11
+ logger.info "[Raque] Received task string \"#{task_string}\""
12
+ args = []
13
+ if args_s = task_string.match(/\[.*\]/)
14
+ args = eval args_s.to_s
15
+ task_string.gsub! /\[.*\]/, ''
16
+ end
17
+
18
+ logger.info "[Raque] Starting Rake task \"#{task_string}\""
19
+ logger.info "[Raque] with arguments #{args.inspect}" if args.size > 0
20
+
21
+ result = capture_stdout { Rake::Task[task_string].invoke *args }
22
+
23
+ Rake::Task[task_string].reenable
24
+
25
+ logger.info result
26
+ logger.info "[Raque] Finished Rake task\n"
27
+ logger.close
28
+ end
29
+
30
+ def self.capture_stdout
31
+ s = StringIO.new
32
+ oldstdout = $stdout
33
+ $stdout = s
34
+ yield
35
+ s.string
36
+ ensure
37
+ $stdout = oldstdout
38
+ end
39
+
40
+ end
41
+ end
data/lib/raque/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Raque
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/raque.rb CHANGED
@@ -1,39 +1,2 @@
1
- require 'logger'
2
- require 'rake'
3
-
4
- class Raque
5
- @queue = :raque
6
-
7
- def self.perform task_string, output_file = false
8
- logger = Logger.new(output_file || STDOUT)
9
-
10
- logger.info "[Raque] Received task string \"#{task_string}\""
11
- args = []
12
- if args_s = task_string.match(/\[.*\]/)
13
- args = eval args_s.to_s
14
- task_string.gsub! /\[.*\]/, ''
15
- end
16
-
17
- logger.info "[Raque] Starting Rake task \"#{task_string}\""
18
- logger.info "[Raque] with arguments #{args.inspect}" if args.size > 0
19
-
20
- result = capture_stdout { Rake::Task[task_string].invoke *args }
21
-
22
- Rake::Task[task_string].reenable
23
-
24
- logger.info result
25
- logger.info "[Raque] Finished Rake task\n"
26
- logger.close
27
- end
28
-
29
- def self.capture_stdout
30
- s = StringIO.new
31
- oldstdout = $stdout
32
- $stdout = s
33
- yield
34
- s.string
35
- ensure
36
- $stdout = oldstdout
37
- end
38
-
1
+ module Raque
39
2
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raque
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
16
- requirement: &70110187075140 !ruby/object:Gem::Requirement
16
+ requirement: &70175227747700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70110187075140
24
+ version_requirements: *70175227747700
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: thor
27
- requirement: &70110187074240 !ruby/object:Gem::Requirement
27
+ requirement: &70175227746820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70110187074240
35
+ version_requirements: *70175227746820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: resque
38
- requirement: &70110187073520 !ruby/object:Gem::Requirement
38
+ requirement: &70175227745540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70110187073520
46
+ version_requirements: *70175227745540
47
47
  description: Run Rake tasks via a Resque worker. Rails startup is slow, hence Rake
48
48
  is too. It's already loaded into Resque so let’s use it from there
49
49
  email:
@@ -61,6 +61,7 @@ files:
61
61
  - bin/raque
62
62
  - lib/raque.rb
63
63
  - lib/raque/cli.rb
64
+ - lib/raque/runner.rb
64
65
  - lib/raque/version.rb
65
66
  - raque.gemspec
66
67
  homepage: https://github.com/snikch/raque