commonthread-rails 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -0
- data/VERSION +1 -1
- data/commonthread-rails.gemspec +3 -2
- data/lib/bj/mixin/async.rb +50 -0
- data/lib/resque/mixin/async.rb +3 -3
- metadata +5 -4
data/Rakefile
CHANGED
@@ -44,6 +44,8 @@ task :test => :check_dependencies
|
|
44
44
|
task :default => :test
|
45
45
|
|
46
46
|
require 'rake/rdoctask'
|
47
|
+
gem 'darkfish-rdoc'
|
48
|
+
|
47
49
|
Rake::RDocTask.new do |rdoc|
|
48
50
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
51
|
|
@@ -51,4 +53,7 @@ Rake::RDocTask.new do |rdoc|
|
|
51
53
|
rdoc.title = "commonthread-rails #{version}"
|
52
54
|
rdoc.rdoc_files.include('README*')
|
53
55
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
56
|
+
rdoc.options += [
|
57
|
+
'-f', 'darkfish'
|
58
|
+
]
|
54
59
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/commonthread-rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{commonthread-rails}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["CommonThread"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-14}
|
13
13
|
s.description = %q{commonthread-rails is a collection of things that make rails development better for us. It includes date formats, monkey patches to String, Array and NilClass to make things nicer. An Encrypter using blowfish. Also, some rails filters}
|
14
14
|
s.email = %q{hello@commonthread.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"Rakefile",
|
25
25
|
"VERSION",
|
26
26
|
"commonthread-rails.gemspec",
|
27
|
+
"lib/bj/mixin/async.rb",
|
27
28
|
"lib/commonthread-rails.rb",
|
28
29
|
"lib/commonthread/date_formats.rb",
|
29
30
|
"lib/commonthread/encrypter.rb",
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class Bj
|
2
|
+
module Mixin
|
3
|
+
# Module that provides easy queueing of jobs.
|
4
|
+
# Transparently handles instance and class methods.
|
5
|
+
#
|
6
|
+
# If you consider this class:
|
7
|
+
#
|
8
|
+
# class Repository < ActiveRecord::Base
|
9
|
+
# include Bj::Mixin::Async
|
10
|
+
#
|
11
|
+
# def self.create_index
|
12
|
+
# # code
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# def notify_watchers
|
16
|
+
# # code
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# you can queue new jobs on both the class and an instance like this:
|
21
|
+
#
|
22
|
+
# @repository.async(:notify_watchers)
|
23
|
+
# Repository.async(:create_index)
|
24
|
+
#
|
25
|
+
module Async
|
26
|
+
def self.included(base)
|
27
|
+
base.extend(ClassMethods)
|
28
|
+
end
|
29
|
+
|
30
|
+
def async(method, *args)
|
31
|
+
Bj.submit "CACHE_CLASSES=true ./script/runner '#{self.class.name}.perform(#{id}, #{method.inspect})'", :stdin => args.to_yaml, :is_restartable => false
|
32
|
+
end
|
33
|
+
|
34
|
+
module ClassMethods
|
35
|
+
def async(method, *args)
|
36
|
+
Bj.submit "CACHE_CLASSES=true ./script/runner '#{self.name}.perform(nil, #{method.inspect})'", :stdin => args.to_yaml, :is_restartable => false
|
37
|
+
end
|
38
|
+
|
39
|
+
# Performs a class method if id is nil or
|
40
|
+
# an instance method if id has a value.
|
41
|
+
def perform(id, method)
|
42
|
+
args = YAML.load(STDIN)
|
43
|
+
|
44
|
+
obj = id ? find(id) : self
|
45
|
+
obj.send(method, *args)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/resque/mixin/async.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 3
|
8
|
+
- 0
|
9
|
+
version: 0.3.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- CommonThread
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-09-14 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- Rakefile
|
59
59
|
- VERSION
|
60
60
|
- commonthread-rails.gemspec
|
61
|
+
- lib/bj/mixin/async.rb
|
61
62
|
- lib/commonthread-rails.rb
|
62
63
|
- lib/commonthread/date_formats.rb
|
63
64
|
- lib/commonthread/encrypter.rb
|