raque 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/bin/raque +20 -0
- data/lib/raque/cli.rb +15 -0
- data/lib/raque/version.rb +3 -0
- data/lib/raque.rb +39 -0
- data/raque.gemspec +21 -0
- metadata +91 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Mal Curtis
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Raque
|
2
|
+
|
3
|
+
Loading Rails is shit, don't do it. Raque lets you run Rake tasks via Resque, saving you from loading Rails.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'raque'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install raque
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
raque REDIS_CONNECTION_STRING COMMAND [LOG_FILE]
|
22
|
+
|
23
|
+
raque redis://127.0.0.1 db:migrate log/migrate.log
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/raque
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if ARGV[0] == nil || ARGV[1] == nil
|
4
|
+
STDOUT.puts <<-EOF
|
5
|
+
Please provide command name
|
6
|
+
|
7
|
+
Usage:
|
8
|
+
raque REDIS COMMAND [LOG_FILE]
|
9
|
+
EOF
|
10
|
+
exit 0
|
11
|
+
end
|
12
|
+
|
13
|
+
require 'resque'
|
14
|
+
require 'raque'
|
15
|
+
|
16
|
+
STDOUT.puts "Connecting to Redis at #{ARGV[0].inspect}"
|
17
|
+
Resque.redis = ARGV[0]
|
18
|
+
STDOUT.puts "Adding #{ARGV[1]} to Raque queue"
|
19
|
+
Resque.enqueue Raque, ARGV[1], ARGV[2]
|
20
|
+
|
data/lib/raque/cli.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'raque'
|
3
|
+
|
4
|
+
module Raque
|
5
|
+
class CLI < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
desc "COMMAND [LOG_FILE]", "Adds COMMAND to the Resque Raque queue."
|
9
|
+
def build command, log_file
|
10
|
+
say "Adding #{command} to Resque Raque queue"
|
11
|
+
|
12
|
+
Resque.enqueue Raque, command, log_file
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/raque.rb
ADDED
@@ -0,0 +1,39 @@
|
|
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
|
+
|
39
|
+
end
|
data/raque.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/raque/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Mal Curtis"]
|
6
|
+
gem.email = ["mal@mal.co.nz"]
|
7
|
+
gem.description = %q{Run Rake tasks via a Resque worker. Rails startup is slow, hence Rake is too. It's already loaded into Resque so let’s use it from there}
|
8
|
+
gem.summary = gem.description
|
9
|
+
gem.homepage = "https://github.com/snikch/raque"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "raque"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Raque::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "rake"
|
19
|
+
gem.add_dependency "thor"
|
20
|
+
gem.add_dependency "resque"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: raque
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mal Curtis
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70110187075140 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70110187075140
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thor
|
27
|
+
requirement: &70110187074240 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70110187074240
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: resque
|
38
|
+
requirement: &70110187073520 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70110187073520
|
47
|
+
description: Run Rake tasks via a Resque worker. Rails startup is slow, hence Rake
|
48
|
+
is too. It's already loaded into Resque so let’s use it from there
|
49
|
+
email:
|
50
|
+
- mal@mal.co.nz
|
51
|
+
executables:
|
52
|
+
- raque
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- Gemfile
|
58
|
+
- LICENSE
|
59
|
+
- README.md
|
60
|
+
- Rakefile
|
61
|
+
- bin/raque
|
62
|
+
- lib/raque.rb
|
63
|
+
- lib/raque/cli.rb
|
64
|
+
- lib/raque/version.rb
|
65
|
+
- raque.gemspec
|
66
|
+
homepage: https://github.com/snikch/raque
|
67
|
+
licenses: []
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.11
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Run Rake tasks via a Resque worker. Rails startup is slow, hence Rake is
|
90
|
+
too. It's already loaded into Resque so let’s use it from there
|
91
|
+
test_files: []
|