Skip to content
Commits on Mar 1, 2010
  1. bonus features are included again

    jrwest committed
  2. moved job files into lib directory

    jrwest committed
    This breaks support for installing background-fu directly into vendor plugins. It should always be installed as a gem and then add it to your Gemfile. 
    Worker's now must be contained in files ending in _worker.rb. Since Rails expects this for autoloading this should not cause any issues.
Commits on Feb 28, 2010
  1. put basic logging back into background script. this commit breaks sup…

    jrwest committed
    …port for some previous versions of rails
    use 1-0-stable branch for versions of Rails prior to Rails 2.3.
Commits on Feb 27, 2010
  1. no longer using daemons gem.

    jrwest committed
    instead of using the old: 
        ./script/daemons start
        ruby script/background
    If you refer the ./script method just make script/background executable.
    Currently, script/background is missing some of its original features. For examle it logs to the console when run as opposed to the Rails logs. The original functionality will be restored. The script now recognizes the file config/background.yml as its config file.
  2. Background-Fu config file is now config/background.rb instead of conf…

    jrwest committed
    …ig/daemons.rb. No longer use the rails initialization process load workers.
    The workers are just required if included in lib/workers. There is no reason to add the the load path when lib dir is already in it. Also, this will automatically require workers in the background script.  
    The Railtie at this point is empty and could be done away with but since we will be using Rails::Engine soon I have just left the file.
Commits on Feb 26, 2010
  1. rails generate background [--skip-migration] [--skip-examples]

    jrwest committed
    conversion of original background-fu generator to Rails 3 style generator. Does everything the same as original one with exception of copying the Jobs Admin scaffold.
Commits on Feb 25, 2010
  1. added necessary requires to Railtie

    jrwest committed
    Rails 3 requires developers to explicitly require any pieces of Rails they use as well as including the lib itselft. This is why b-fu and rails are required in the Railtie. rails/engine is required because the Railtie hooks into set_load_path which is an initializer defined in rails/engine.
  2. added version file necessary for jeweler

    jrwest committed
  3. only load railtie if Rails 3

    jrwest committed
  4. BackgroundFu::Railtie basics

    jrwest committed
    only run rails/init.rb if Rails version <= 2. If not BackgroundFu::Railtie is loaded and should perform same actions as original rails/init.rb
  5. convert to jeweler

    jrwest committed
Commits on Feb 23, 2010
  1. Job run chain callbacks complete

    jrwest committed
    added before_ensure and after_ensure. these work in similar fashion to before_invoke and other callbacks. Methods registered with before_ensure or after_ensure are guarunteed to be called if the worker errors. If you opened a file for some reason in before_invoke then you should close the file in a before_ensure or after_ensure based on your needs.
Commits on Feb 22, 2010
  1. before_rescue and after_rescue callbacks

    jrwest committed
    before_rescue and after_rescue let you hook into your Job when something goes wrong. Background-Fu stores the error caused by your Job in its result and sets the state to failing. before_rescue lets you hook into the Job process before these two actions are taken. If you store any data in the result or state of the Job using a before_rescue callback it will be overriden. However, if you would like to override the result and state stored by B-Fu you  can use after_rescue :).
  2. simple magic (worker) callbacks

    jrwest committed
    this is the beginning of work on magic callbacks or worker callbacks. In the first use case (working as of this commit) you simply want to call one method before and after the method your worker runs when called by a Job. Say you have a worker, ExampleWorker with a method add and you enqueue a job with, Job.enqueue!(ExampleWorker, :add, 1, 2). When the Job is run if the instance methods before_add or after_add are defined in Example worker they will be called in the logical places. Use these magic callbacks to perform tasks such as logging or modifying the state of an object prior to using it in a long running Job. This first use case is really a simplification of the second.
    The second use case (not currently implemented) is wanting to call multiple methods before the worker method. This will be possible in similar fashion to Job callbacks. Extending the example above it will be possible to use the class macros before_add/after_add passing them a list of method names to call at the appropriate times.  
    Also looking into adding hooks like rescue_add and ensure_add.
  3. after_init callback executes given methods after initializing Job

    jrwest committed
    seeing as there are many callbacks to add should probably dynamically call alias_method_chain and define methods like invoke_worker_with_callbacks using cb_points hash. This wont be as simple as the dynamic class method and callers/checkers generation however
    Added a "stub" ExampleWorker class to the top of the callbacks_spec. This way background-fu files need not be generated to run specs. Had to make some changes in places where the use of ExampleWorker#add was not stubbed.
  4. finished writing specs for invocation of job

    jrwest committed
    still need to add specs for:
    	* predicates (finished?, pending?,etc...)
    	* rescuing run
    	* ensuring run
    	* #get_done!
    	* bonus features
    	* logging
    above is incomplete list.
Commits on Feb 21, 2010
  1. implemented specs for Job#enqueue! and initialization

    jrwest committed
    Still need to implement the invocation specs and write many others
  2. all parts of callbacks (class macros, checkers, and callers) are dyna…

    jrwest committed
    …mically gernated when including Job::Callbacks
    to add a callback point add the befores and afters arrays at the top of self.included in Job::Callbacks.
  3. added after_invoke callback

    jrwest committed
    switched callback macros to be dynamically generated as opposed to explicitly defined. Make it easier to add more callback points in the future
  4. shared examples for any callback point

    jrwest committed
    Any callback point needs to conform to a certain spec of behaviors. To make this process painless use it_should_behave_like "Any CB Point" when describing a callback point. This shared example group assumes that a let block defining :callback_point precedes it. See before_invoke in spec/lib/job/callbacks.rb for an example.
  5. the basics of callbacks (before_invoke)

    jrwest committed
    before_invoke callback allows methods in the Job class to be called right before it is run. Use the macro before_invoke(*do_methods) to specify which methods to call. The callback chain does not interrupt the running of the job. It is arrogant of the results returned by each before_invoke method. Methods are called in the order they are added so
    	before_invoke :method1, :method2, :method3
    is the same as
    	before_invoke :method1
    	before_invoke :method2
    	before_invoke :method3
Commits on Feb 20, 2010
  1. no longer using Test::Unit and using RSpec

    jrwest committed
    all existing tests have been converted to specs. 
    A little note on the TODO in spec/job_spec.rb for some reason in describe block I cannot get the shoulda macros "should_validate_presence_of" and "should_require_readonly_attributes" to work. Spent a bit of time trying to figure this out but havent gotten it working. Since this part of the spec really isn't as important as the behavior of the Job API I'm going to go back and adress it later.
  2. starting callbacks

    jrwest committed
    to keep callbacks an extension similar to job bonus features the Job::Callbacks module allows callback functionality to be easily switched off (see rails/init.rb).
  3. getting ready to spec

    jrwest committed
    copied spec_helper pretty much verbatim from its generated counterpart (see note at top of file). This way all the rspec-rails functionality is available when writing
Commits on May 18, 2009
  1. patched bonus include depending on rails version

    sk committed with
    Signed-off-by: Jacek Becela <>
Commits on Apr 29, 2009
  1. @kurowski

    Fix for non-existent config file

    kurowski committed with
    Signed-off-by: Jacek Becela <>
Commits on Mar 25, 2009
  1. Modified Job.find to use instead of for compat…

    Corey committed with
    …ibility with Rails 2.1+ (which stores dates and times in UTC).
    Signed-off-by: Jacek Becela <>
  2. Modified Job.find to use instead of for compat…

    Corey committed with
    …ibility with Rails 2.1+ (which stores dates and times in UTC).
    Signed-off-by: Jacek Becela <>
Commits on Mar 5, 2009
  1. Added ability to configure job check and job cleanup intervals throug…

    Corey committed with
    …h settings in config/daemons.yml. Updated README.txt includes instructions for overriding these defaults. Judicious use of these settings allows for reduction in number of ongoing database calls.
    Signed-off-by: Jacek Becela <>
Commits on Feb 7, 2009
  1. Merged some changes from beloved contributors :), bumped version to 1…

    ….0.10 and added TODO if you ever wonder what to do with your free evening
  2. @infused

    Start test suite

    infused committed with
    Signed-off-by: Jacek Becela <>
Something went wrong with that request. Please try again.