background_lite 0.3.2 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,7 @@
1
1
  === BackgroundLite
2
2
 
3
- This Rails plugin supersedes the background plugin, available here:
4
-
5
- http://github.com/imedo/background/tree/master
6
-
7
- It allows you to execute methods in a background task with a very intuitive and
8
- easy syntax. It is as easy as that:
3
+ This gem allows you to execute methods in a background task with a very
4
+ intuitive and easy syntax. It is as easy as that:
9
5
 
10
6
  class MyModel
11
7
  def complex_operation(argument)
@@ -19,16 +15,16 @@ background process.
19
15
 
20
16
  Refer to the Class#background_method documentation for details.
21
17
 
22
- === What this plugin is
18
+ === What this gem is
23
19
 
24
- This plugin is an easy-to-use interface for background processing frameworks.
20
+ This gem is an easy-to-use interface for background processing frameworks.
25
21
  Theoretically, you can use it in combination with any of the messaging /
26
22
  background processing frameworks out there, though there are not many handlers
27
23
  implemented yet. However, implementing a handler is very easy.
28
24
 
29
- === What this plugin is NOT
25
+ === What this gem is NOT
30
26
 
31
- This plugin is NOT a background processing framework. To make it work
27
+ This gem is NOT a background processing framework. To make it work
32
28
  efficiently, you need an existing framework installed and configured. Right now,
33
29
  support for the ActiveMessaging framework is implemented.
34
30
 
@@ -58,7 +54,7 @@ background tasks, as well as forking.
58
54
  * Resque
59
55
  * script/runner.
60
56
  * fork (works only on Unix-like environments).
61
- * DRb with an example runner in scripts/background_queue (not really suitable for production use)
57
+ * DRb with an example runner executable "background_queue" (not really suitable for production use)
62
58
  * others might follow (it's really easy to write a handler).
63
59
  * Easy configuration, depending on the environment, in config/background.yml.
64
60
  * Ability to override the configuration per method.
@@ -70,7 +66,11 @@ anyways.
70
66
 
71
67
  === Installation
72
68
 
73
- Just copy the background_lite folder into vendor/plugins, and you're good to go.
69
+ gem install background_lite
70
+
71
+ or use Bundler
72
+
73
+ gem "background_lite"
74
74
 
75
75
  === Configuration
76
76
 
@@ -78,4 +78,4 @@ Depending on the background processing framework that you are using, you might
78
78
  have to do some configuration. See the documentation of the respective
79
79
  background handler for details.
80
80
 
81
- Copyright (c) 2008-2010 imedo GmbH, released under the MIT license
81
+ Copyright (c) 2008-2013 Thomas Kadauke, released under the MIT license
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+ require 'config/environment'
3
+ require 'drb'
4
+
5
+ class BackgroundQueue
6
+ include Singleton
7
+
8
+ def initialize
9
+ @queue = []
10
+ end
11
+
12
+ delegate :push, :pop, :to => '@queue'
13
+ class << self
14
+ delegate :run, :to => :instance
15
+ end
16
+
17
+ def run
18
+ loop do
19
+ message = pop
20
+ BackgroundLite::DrbHandler.execute(message) if message
21
+ sleep 0.1
22
+ end
23
+ end
24
+ end
25
+
26
+ DRb.start_service "druby://localhost:2251", BackgroundQueue.instance
27
+
28
+ BackgroundQueue.run
@@ -14,7 +14,7 @@ module ActiveRecord
14
14
  #
15
15
  # To clean up data specific to your class, use cleanup_for_background.
16
16
  def clone_for_background
17
- returning dup do |x|
17
+ dup.tap do |x|
18
18
  x.cleanup_for_background
19
19
  x.send(:instance_variable_set, "@new_record", new_record?)
20
20
  x.send(:instance_variable_set, "@changed_attributes", instance_variable_get("@changed_attributes"))
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: background_lite
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 3
9
- - 2
10
- version: 0.3.2
8
+ - 4
9
+ version: "0.4"
11
10
  platform: ruby
12
11
  authors:
13
12
  - Thomas Kadauke
@@ -15,14 +14,14 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2012-11-14 00:00:00 +01:00
17
+ date: 2013-01-30 00:00:00 +01:00
19
18
  default_executable:
20
19
  dependencies: []
21
20
 
22
21
  description:
23
- email: tkadauke@imedo.de
24
- executables: []
25
-
22
+ email: thomas.kadauke@googlemail.com
23
+ executables:
24
+ - background_queue
26
25
  extensions: []
27
26
 
28
27
  extra_rdoc_files:
@@ -50,11 +49,10 @@ files:
50
49
  - lib/background_lite/core_ext/symbol.rb
51
50
  - lib/background_lite/rails_ext/activerecord/base.rb
52
51
  - lib/background_lite.rb
53
- - rails/init.rb
54
- - init.rb
52
+ - bin/background_queue
55
53
  - README.rdoc
56
54
  has_rdoc: true
57
- homepage: http://www.imedo.de/
55
+ homepage: https://github.com/tkadauke/background_lite
58
56
  licenses: []
59
57
 
60
58
  post_install_message:
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require File.dirname(__FILE__) + '/lib/background_lite'
@@ -1 +0,0 @@
1
- require File.dirname(__FILE__) + '/../init'