djinn 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +106 -9
 - data/Rakefile +4 -2
 - data/VERSION +1 -1
 - data/djinn.gemspec +3 -62
 - data/lib/djinn/base.rb +2 -0
 - metadata +5 -64
 - data/example/basic.rb +0 -27
 - data/example/em.rb +0 -58
 - data/example/event_machine_djinn.pid +0 -1
 - data/example/rails/demo/Rakefile +0 -10
 - data/example/rails/demo/app/controllers/application_controller.rb +0 -10
 - data/example/rails/demo/app/controllers/books_controller.rb +0 -2
 - data/example/rails/demo/app/helpers/application_helper.rb +0 -3
 - data/example/rails/demo/app/helpers/books_helper.rb +0 -2
 - data/example/rails/demo/app/models/book.rb +0 -7
 - data/example/rails/demo/app/views/books/_book.html.erb +0 -3
 - data/example/rails/demo/app/views/books/index.html.erb +0 -13
 - data/example/rails/demo/app/views/layouts/application.html.erb +0 -5
 - data/example/rails/demo/config/boot.rb +0 -110
 - data/example/rails/demo/config/database.yml +0 -22
 - data/example/rails/demo/config/environment.rb +0 -38
 - data/example/rails/demo/config/environments/development.rb +0 -17
 - data/example/rails/demo/config/environments/production.rb +0 -28
 - data/example/rails/demo/config/environments/test.rb +0 -28
 - data/example/rails/demo/config/initializers/backtrace_silencers.rb +0 -7
 - data/example/rails/demo/config/initializers/cookie_verification_secret.rb +0 -7
 - data/example/rails/demo/config/initializers/inflections.rb +0 -10
 - data/example/rails/demo/config/initializers/mime_types.rb +0 -5
 - data/example/rails/demo/config/initializers/new_rails_defaults.rb +0 -21
 - data/example/rails/demo/config/initializers/session_store.rb +0 -15
 - data/example/rails/demo/config/locales/en.yml +0 -5
 - data/example/rails/demo/config/routes.rb +0 -6
 - data/example/rails/demo/db/migrate/20100726151602_create_books.rb +0 -15
 - data/example/rails/demo/db/schema.rb +0 -23
 - data/example/rails/demo/db/seeds.rb +0 -15
 - data/example/rails/demo/doc/README_FOR_APP +0 -2
 - data/example/rails/demo/lib/book_djinn.rb +0 -25
 - data/example/rails/demo/public/404.html +0 -30
 - data/example/rails/demo/public/422.html +0 -30
 - data/example/rails/demo/public/500.html +0 -30
 - data/example/rails/demo/public/favicon.ico +0 -0
 - data/example/rails/demo/public/images/rails.png +0 -0
 - data/example/rails/demo/public/javascripts/application.js +0 -2
 - data/example/rails/demo/public/javascripts/controls.js +0 -963
 - data/example/rails/demo/public/javascripts/dragdrop.js +0 -973
 - data/example/rails/demo/public/javascripts/effects.js +0 -1128
 - data/example/rails/demo/public/javascripts/prototype.js +0 -4320
 - data/example/rails/demo/public/robots.txt +0 -5
 - data/example/rails/demo/script/about +0 -4
 - data/example/rails/demo/script/book_djinn +0 -7
 - data/example/rails/demo/script/console +0 -3
 - data/example/rails/demo/script/dbconsole +0 -3
 - data/example/rails/demo/script/destroy +0 -3
 - data/example/rails/demo/script/generate +0 -3
 - data/example/rails/demo/script/performance/benchmarker +0 -3
 - data/example/rails/demo/script/performance/profiler +0 -3
 - data/example/rails/demo/script/plugin +0 -3
 - data/example/rails/demo/script/runner +0 -3
 - data/example/rails/demo/script/server +0 -3
 - data/example/rails/demo/test/fixtures/books.yml +0 -11
 - data/example/rails/demo/test/functional/books_controller_test.rb +0 -8
 - data/example/rails/demo/test/performance/browsing_test.rb +0 -9
 - data/example/rails/demo/test/test_helper.rb +0 -38
 - data/example/rails/demo/test/unit/book_test.rb +0 -8
 - data/example/rails/demo/test/unit/helpers/books_helper_test.rb +0 -4
 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -1,16 +1,113 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            = djinn
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            Djinn is a very basic helper for building simple daemons
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            ==  
     | 
| 
      
 5 
     | 
    
         
            +
            == Non-Rails Example
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              require 'rubygems'
         
     | 
| 
      
 10 
     | 
    
         
            +
              require 'djinn'
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              class Basic
         
     | 
| 
      
 13 
     | 
    
         
            +
              
         
     | 
| 
      
 14 
     | 
    
         
            +
                include Djinn
         
     | 
| 
      
 15 
     | 
    
         
            +
              
         
     | 
| 
      
 16 
     | 
    
         
            +
                # Not providing a "perform" method falls back to the base method 
         
     | 
| 
      
 17 
     | 
    
         
            +
                # in Djinn, which does nothing useful. Make sure your method accepts
         
     | 
| 
      
 18 
     | 
    
         
            +
                # a config hash, even if it doesn't use it.
         
     | 
| 
      
 19 
     | 
    
         
            +
                def perform options
         
     | 
| 
      
 20 
     | 
    
         
            +
                  log "ZOMG! A Djinn?"
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
              
         
     | 
| 
      
 23 
     | 
    
         
            +
                # Strictly optional, lets you do stuff when the Djinn daemon stops.
         
     | 
| 
      
 24 
     | 
    
         
            +
                # The call to "super" is required, or your daemon will never die
         
     | 
| 
      
 25 
     | 
    
         
            +
                def handle_exit
         
     | 
| 
      
 26 
     | 
    
         
            +
                  log "Handling a nice graceful exit.."
         
     | 
| 
      
 27 
     | 
    
         
            +
                  super
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
              
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
            Run it in the foreground like this:
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              djinn = Basic.new
         
     | 
| 
      
 35 
     | 
    
         
            +
              djinn.run
         
     | 
| 
      
 36 
     | 
    
         
            +
              
         
     | 
| 
      
 37 
     | 
    
         
            +
            But running it in the background is sort of the point. A bit contrived, but
         
     | 
| 
      
 38 
     | 
    
         
            +
            this is the general idea:
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
              djinn.start
         
     | 
| 
      
 41 
     | 
    
         
            +
              sleep(10)
         
     | 
| 
      
 42 
     | 
    
         
            +
              djinn.stop
         
     | 
| 
      
 43 
     | 
    
         
            +
              
         
     | 
| 
      
 44 
     | 
    
         
            +
            == Rails Example
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            There's a nice example in the example directory if you check the code out, but
         
     | 
| 
      
 47 
     | 
    
         
            +
            here's the gist of it.
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
            Assumes a scenario where you have a Book model that keeps a count of how many
         
     | 
| 
      
 50 
     | 
    
         
            +
            times a book has been read.  
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            Create a file in RAILS_ROOT/lib or somewhere similar:
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              BOOK_WORKER_INTERVAL = 5
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
              class BookDjinn
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
                require 'djinn/rails'
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                include Djinn::Rails
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                def perform config
         
     | 
| 
      
 63 
     | 
    
         
            +
                  EM.run do
         
     | 
| 
      
 64 
     | 
    
         
            +
                    log "Workers will run every #{BOOK_WORKER_INTERVAL} secs"
         
     | 
| 
      
 65 
     | 
    
         
            +
                    EM::PeriodicTimer.new(BOOK_WORKER_INTERVAL) do
         
     | 
| 
      
 66 
     | 
    
         
            +
                      log "There are #{Book.count} book(s) in the database"
         
     | 
| 
      
 67 
     | 
    
         
            +
                      log "Updating read counts for all books.."
         
     | 
| 
      
 68 
     | 
    
         
            +
                      Book.all.each &:read!
         
     | 
| 
      
 69 
     | 
    
         
            +
                    end
         
     | 
| 
      
 70 
     | 
    
         
            +
                  end
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                def handle_exit
         
     | 
| 
      
 74 
     | 
    
         
            +
                  EM.stop
         
     | 
| 
      
 75 
     | 
    
         
            +
                  super
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            Right, now you need to start it somehow. The easiest way is to create a file 
         
     | 
| 
      
 81 
     | 
    
         
            +
            in RAILS_ROOT/scripts and pop this in it:
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
             #!/usr/bin/env ruby
         
     | 
| 
      
 84 
     | 
    
         
            +
             require 'rubygems'
         
     | 
| 
      
 85 
     | 
    
         
            +
             require File.join(File.dirname(__FILE__), '../lib/book_djinn')
         
     | 
| 
      
 86 
     | 
    
         
            +
             BookDjinn.go ARGV
         
     | 
| 
       6 
87 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
               
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 88 
     | 
    
         
            +
            Righto, now start it from RAILS_ROOT:
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              ruby script/book_djinn
         
     | 
| 
      
 91 
     | 
    
         
            +
              
         
     | 
| 
      
 92 
     | 
    
         
            +
            Okay, but that defaults to "run", which starts it in the foreground and also 
         
     | 
| 
      
 93 
     | 
    
         
            +
            uses the rails development environment by default. Try this:
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
              ruby script/book_djinn --help
         
     | 
| 
      
 96 
     | 
    
         
            +
              
         
     | 
| 
      
 97 
     | 
    
         
            +
            That should give you a better idea of what's going on, then try this:
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              ruby script/book_djinn start -e production
         
     | 
| 
      
 100 
     | 
    
         
            +
              
         
     | 
| 
      
 101 
     | 
    
         
            +
            Yay, we have a daemon running in the background! To stop it:
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
              ruby script/book_djinn stop
         
     | 
| 
      
 104 
     | 
    
         
            +
              
         
     | 
| 
      
 105 
     | 
    
         
            +
            That gives you more-or-less everything you need to build something basic
         
     | 
| 
      
 106 
     | 
    
         
            +
            and monitor it with god or a similar process monitor.
         
     | 
| 
      
 107 
     | 
    
         
            +
              
         
     | 
| 
      
 108 
     | 
    
         
            +
            == TODO
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              Lots. Keep 'em peeled.
         
     | 
| 
       14 
111 
     | 
    
         | 
| 
       15 
112 
     | 
    
         
             
            == Copyright
         
     | 
| 
       16 
113 
     | 
    
         | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -5,12 +5,14 @@ begin 
     | 
|
| 
       5 
5 
     | 
    
         
             
              require 'jeweler'
         
     | 
| 
       6 
6 
     | 
    
         
             
              Jeweler::Tasks.new do |gem|
         
     | 
| 
       7 
7 
     | 
    
         
             
                gem.name = "djinn"
         
     | 
| 
       8 
     | 
    
         
            -
                gem.summary = %Q{ 
     | 
| 
       9 
     | 
    
         
            -
                gem.description = %Q{Helper for creating custom  
     | 
| 
      
 8 
     | 
    
         
            +
                gem.summary = %Q{Helper for creating simple custom daemons}
         
     | 
| 
      
 9 
     | 
    
         
            +
                gem.description = %Q{Helper for creating simple custom daemons}
         
     | 
| 
       10 
10 
     | 
    
         
             
                gem.email = "darksavant@gmail.com"
         
     | 
| 
       11 
11 
     | 
    
         
             
                gem.homepage = "http://github.com/craigp/djinn"
         
     | 
| 
       12 
12 
     | 
    
         
             
                gem.authors = ["Craig Paterson"]
         
     | 
| 
       13 
13 
     | 
    
         
             
                gem.add_development_dependency "shoulda", ">= 2.11.1"
         
     | 
| 
      
 14 
     | 
    
         
            +
                gem.files.exclude 'example/**/*'
         
     | 
| 
      
 15 
     | 
    
         
            +
                gem.test_files.exclude 'example/**/*'
         
     | 
| 
       14 
16 
     | 
    
         
             
                # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
         
     | 
| 
       15 
17 
     | 
    
         
             
              end
         
     | 
| 
       16 
18 
     | 
    
         
             
              Jeweler::GemcutterTasks.new
         
     | 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.0. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.0.5
         
     | 
    
        data/djinn.gemspec
    CHANGED
    
    | 
         @@ -5,12 +5,12 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = %q{djinn}
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0.0. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.0.5"
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         
     | 
| 
       11 
11 
     | 
    
         
             
              s.authors = ["Craig Paterson"]
         
     | 
| 
       12 
12 
     | 
    
         
             
              s.date = %q{2010-07-27}
         
     | 
| 
       13 
     | 
    
         
            -
              s.description = %q{Helper for creating custom  
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = %q{Helper for creating simple custom daemons}
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.email = %q{darksavant@gmail.com}
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.extra_rdoc_files = [
         
     | 
| 
       16 
16 
     | 
    
         
             
                "LICENSE",
         
     | 
| 
         @@ -24,65 +24,6 @@ Gem::Specification.new do |s| 
     | 
|
| 
       24 
24 
     | 
    
         
             
                 "Rakefile",
         
     | 
| 
       25 
25 
     | 
    
         
             
                 "VERSION",
         
     | 
| 
       26 
26 
     | 
    
         
             
                 "djinn.gemspec",
         
     | 
| 
       27 
     | 
    
         
            -
                 "example/basic.rb",
         
     | 
| 
       28 
     | 
    
         
            -
                 "example/em.rb",
         
     | 
| 
       29 
     | 
    
         
            -
                 "example/event_machine_djinn.pid",
         
     | 
| 
       30 
     | 
    
         
            -
                 "example/rails/demo/Rakefile",
         
     | 
| 
       31 
     | 
    
         
            -
                 "example/rails/demo/app/controllers/application_controller.rb",
         
     | 
| 
       32 
     | 
    
         
            -
                 "example/rails/demo/app/controllers/books_controller.rb",
         
     | 
| 
       33 
     | 
    
         
            -
                 "example/rails/demo/app/helpers/application_helper.rb",
         
     | 
| 
       34 
     | 
    
         
            -
                 "example/rails/demo/app/helpers/books_helper.rb",
         
     | 
| 
       35 
     | 
    
         
            -
                 "example/rails/demo/app/models/book.rb",
         
     | 
| 
       36 
     | 
    
         
            -
                 "example/rails/demo/app/views/books/_book.html.erb",
         
     | 
| 
       37 
     | 
    
         
            -
                 "example/rails/demo/app/views/books/index.html.erb",
         
     | 
| 
       38 
     | 
    
         
            -
                 "example/rails/demo/app/views/layouts/application.html.erb",
         
     | 
| 
       39 
     | 
    
         
            -
                 "example/rails/demo/config/boot.rb",
         
     | 
| 
       40 
     | 
    
         
            -
                 "example/rails/demo/config/database.yml",
         
     | 
| 
       41 
     | 
    
         
            -
                 "example/rails/demo/config/environment.rb",
         
     | 
| 
       42 
     | 
    
         
            -
                 "example/rails/demo/config/environments/development.rb",
         
     | 
| 
       43 
     | 
    
         
            -
                 "example/rails/demo/config/environments/production.rb",
         
     | 
| 
       44 
     | 
    
         
            -
                 "example/rails/demo/config/environments/test.rb",
         
     | 
| 
       45 
     | 
    
         
            -
                 "example/rails/demo/config/initializers/backtrace_silencers.rb",
         
     | 
| 
       46 
     | 
    
         
            -
                 "example/rails/demo/config/initializers/cookie_verification_secret.rb",
         
     | 
| 
       47 
     | 
    
         
            -
                 "example/rails/demo/config/initializers/inflections.rb",
         
     | 
| 
       48 
     | 
    
         
            -
                 "example/rails/demo/config/initializers/mime_types.rb",
         
     | 
| 
       49 
     | 
    
         
            -
                 "example/rails/demo/config/initializers/new_rails_defaults.rb",
         
     | 
| 
       50 
     | 
    
         
            -
                 "example/rails/demo/config/initializers/session_store.rb",
         
     | 
| 
       51 
     | 
    
         
            -
                 "example/rails/demo/config/locales/en.yml",
         
     | 
| 
       52 
     | 
    
         
            -
                 "example/rails/demo/config/routes.rb",
         
     | 
| 
       53 
     | 
    
         
            -
                 "example/rails/demo/db/migrate/20100726151602_create_books.rb",
         
     | 
| 
       54 
     | 
    
         
            -
                 "example/rails/demo/db/schema.rb",
         
     | 
| 
       55 
     | 
    
         
            -
                 "example/rails/demo/db/seeds.rb",
         
     | 
| 
       56 
     | 
    
         
            -
                 "example/rails/demo/doc/README_FOR_APP",
         
     | 
| 
       57 
     | 
    
         
            -
                 "example/rails/demo/lib/book_djinn.rb",
         
     | 
| 
       58 
     | 
    
         
            -
                 "example/rails/demo/public/404.html",
         
     | 
| 
       59 
     | 
    
         
            -
                 "example/rails/demo/public/422.html",
         
     | 
| 
       60 
     | 
    
         
            -
                 "example/rails/demo/public/500.html",
         
     | 
| 
       61 
     | 
    
         
            -
                 "example/rails/demo/public/favicon.ico",
         
     | 
| 
       62 
     | 
    
         
            -
                 "example/rails/demo/public/images/rails.png",
         
     | 
| 
       63 
     | 
    
         
            -
                 "example/rails/demo/public/javascripts/application.js",
         
     | 
| 
       64 
     | 
    
         
            -
                 "example/rails/demo/public/javascripts/controls.js",
         
     | 
| 
       65 
     | 
    
         
            -
                 "example/rails/demo/public/javascripts/dragdrop.js",
         
     | 
| 
       66 
     | 
    
         
            -
                 "example/rails/demo/public/javascripts/effects.js",
         
     | 
| 
       67 
     | 
    
         
            -
                 "example/rails/demo/public/javascripts/prototype.js",
         
     | 
| 
       68 
     | 
    
         
            -
                 "example/rails/demo/public/robots.txt",
         
     | 
| 
       69 
     | 
    
         
            -
                 "example/rails/demo/script/about",
         
     | 
| 
       70 
     | 
    
         
            -
                 "example/rails/demo/script/book_djinn",
         
     | 
| 
       71 
     | 
    
         
            -
                 "example/rails/demo/script/console",
         
     | 
| 
       72 
     | 
    
         
            -
                 "example/rails/demo/script/dbconsole",
         
     | 
| 
       73 
     | 
    
         
            -
                 "example/rails/demo/script/destroy",
         
     | 
| 
       74 
     | 
    
         
            -
                 "example/rails/demo/script/generate",
         
     | 
| 
       75 
     | 
    
         
            -
                 "example/rails/demo/script/performance/benchmarker",
         
     | 
| 
       76 
     | 
    
         
            -
                 "example/rails/demo/script/performance/profiler",
         
     | 
| 
       77 
     | 
    
         
            -
                 "example/rails/demo/script/plugin",
         
     | 
| 
       78 
     | 
    
         
            -
                 "example/rails/demo/script/runner",
         
     | 
| 
       79 
     | 
    
         
            -
                 "example/rails/demo/script/server",
         
     | 
| 
       80 
     | 
    
         
            -
                 "example/rails/demo/test/fixtures/books.yml",
         
     | 
| 
       81 
     | 
    
         
            -
                 "example/rails/demo/test/functional/books_controller_test.rb",
         
     | 
| 
       82 
     | 
    
         
            -
                 "example/rails/demo/test/performance/browsing_test.rb",
         
     | 
| 
       83 
     | 
    
         
            -
                 "example/rails/demo/test/test_helper.rb",
         
     | 
| 
       84 
     | 
    
         
            -
                 "example/rails/demo/test/unit/book_test.rb",
         
     | 
| 
       85 
     | 
    
         
            -
                 "example/rails/demo/test/unit/helpers/books_helper_test.rb",
         
     | 
| 
       86 
27 
     | 
    
         
             
                 "lib/djinn.rb",
         
     | 
| 
       87 
28 
     | 
    
         
             
                 "lib/djinn/base.rb",
         
     | 
| 
       88 
29 
     | 
    
         
             
                 "lib/djinn/logging.rb",
         
     | 
| 
         @@ -97,7 +38,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       97 
38 
     | 
    
         
             
              s.rdoc_options = ["--charset=UTF-8"]
         
     | 
| 
       98 
39 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       99 
40 
     | 
    
         
             
              s.rubygems_version = %q{1.3.7}
         
     | 
| 
       100 
     | 
    
         
            -
              s.summary = %q{ 
     | 
| 
      
 41 
     | 
    
         
            +
              s.summary = %q{Helper for creating simple custom daemons}
         
     | 
| 
       101 
42 
     | 
    
         
             
              s.test_files = [
         
     | 
| 
       102 
43 
     | 
    
         
             
                "test/helper.rb",
         
     | 
| 
       103 
44 
     | 
    
         
             
                 "test/test_djinn.rb"
         
     | 
    
        data/lib/djinn/base.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: djinn
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 21
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 0
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 5
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.0.5
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Craig Paterson
         
     | 
| 
         @@ -34,7 +34,7 @@ dependencies: 
     | 
|
| 
       34 
34 
     | 
    
         
             
                    version: 2.11.1
         
     | 
| 
       35 
35 
     | 
    
         
             
              type: :development
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: *id001
         
     | 
| 
       37 
     | 
    
         
            -
            description: Helper for creating custom  
     | 
| 
      
 37 
     | 
    
         
            +
            description: Helper for creating simple custom daemons
         
     | 
| 
       38 
38 
     | 
    
         
             
            email: darksavant@gmail.com
         
     | 
| 
       39 
39 
     | 
    
         
             
            executables: []
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
         @@ -51,65 +51,6 @@ files: 
     | 
|
| 
       51 
51 
     | 
    
         
             
            - Rakefile
         
     | 
| 
       52 
52 
     | 
    
         
             
            - VERSION
         
     | 
| 
       53 
53 
     | 
    
         
             
            - djinn.gemspec
         
     | 
| 
       54 
     | 
    
         
            -
            - example/basic.rb
         
     | 
| 
       55 
     | 
    
         
            -
            - example/em.rb
         
     | 
| 
       56 
     | 
    
         
            -
            - example/event_machine_djinn.pid
         
     | 
| 
       57 
     | 
    
         
            -
            - example/rails/demo/Rakefile
         
     | 
| 
       58 
     | 
    
         
            -
            - example/rails/demo/app/controllers/application_controller.rb
         
     | 
| 
       59 
     | 
    
         
            -
            - example/rails/demo/app/controllers/books_controller.rb
         
     | 
| 
       60 
     | 
    
         
            -
            - example/rails/demo/app/helpers/application_helper.rb
         
     | 
| 
       61 
     | 
    
         
            -
            - example/rails/demo/app/helpers/books_helper.rb
         
     | 
| 
       62 
     | 
    
         
            -
            - example/rails/demo/app/models/book.rb
         
     | 
| 
       63 
     | 
    
         
            -
            - example/rails/demo/app/views/books/_book.html.erb
         
     | 
| 
       64 
     | 
    
         
            -
            - example/rails/demo/app/views/books/index.html.erb
         
     | 
| 
       65 
     | 
    
         
            -
            - example/rails/demo/app/views/layouts/application.html.erb
         
     | 
| 
       66 
     | 
    
         
            -
            - example/rails/demo/config/boot.rb
         
     | 
| 
       67 
     | 
    
         
            -
            - example/rails/demo/config/database.yml
         
     | 
| 
       68 
     | 
    
         
            -
            - example/rails/demo/config/environment.rb
         
     | 
| 
       69 
     | 
    
         
            -
            - example/rails/demo/config/environments/development.rb
         
     | 
| 
       70 
     | 
    
         
            -
            - example/rails/demo/config/environments/production.rb
         
     | 
| 
       71 
     | 
    
         
            -
            - example/rails/demo/config/environments/test.rb
         
     | 
| 
       72 
     | 
    
         
            -
            - example/rails/demo/config/initializers/backtrace_silencers.rb
         
     | 
| 
       73 
     | 
    
         
            -
            - example/rails/demo/config/initializers/cookie_verification_secret.rb
         
     | 
| 
       74 
     | 
    
         
            -
            - example/rails/demo/config/initializers/inflections.rb
         
     | 
| 
       75 
     | 
    
         
            -
            - example/rails/demo/config/initializers/mime_types.rb
         
     | 
| 
       76 
     | 
    
         
            -
            - example/rails/demo/config/initializers/new_rails_defaults.rb
         
     | 
| 
       77 
     | 
    
         
            -
            - example/rails/demo/config/initializers/session_store.rb
         
     | 
| 
       78 
     | 
    
         
            -
            - example/rails/demo/config/locales/en.yml
         
     | 
| 
       79 
     | 
    
         
            -
            - example/rails/demo/config/routes.rb
         
     | 
| 
       80 
     | 
    
         
            -
            - example/rails/demo/db/migrate/20100726151602_create_books.rb
         
     | 
| 
       81 
     | 
    
         
            -
            - example/rails/demo/db/schema.rb
         
     | 
| 
       82 
     | 
    
         
            -
            - example/rails/demo/db/seeds.rb
         
     | 
| 
       83 
     | 
    
         
            -
            - example/rails/demo/doc/README_FOR_APP
         
     | 
| 
       84 
     | 
    
         
            -
            - example/rails/demo/lib/book_djinn.rb
         
     | 
| 
       85 
     | 
    
         
            -
            - example/rails/demo/public/404.html
         
     | 
| 
       86 
     | 
    
         
            -
            - example/rails/demo/public/422.html
         
     | 
| 
       87 
     | 
    
         
            -
            - example/rails/demo/public/500.html
         
     | 
| 
       88 
     | 
    
         
            -
            - example/rails/demo/public/favicon.ico
         
     | 
| 
       89 
     | 
    
         
            -
            - example/rails/demo/public/images/rails.png
         
     | 
| 
       90 
     | 
    
         
            -
            - example/rails/demo/public/javascripts/application.js
         
     | 
| 
       91 
     | 
    
         
            -
            - example/rails/demo/public/javascripts/controls.js
         
     | 
| 
       92 
     | 
    
         
            -
            - example/rails/demo/public/javascripts/dragdrop.js
         
     | 
| 
       93 
     | 
    
         
            -
            - example/rails/demo/public/javascripts/effects.js
         
     | 
| 
       94 
     | 
    
         
            -
            - example/rails/demo/public/javascripts/prototype.js
         
     | 
| 
       95 
     | 
    
         
            -
            - example/rails/demo/public/robots.txt
         
     | 
| 
       96 
     | 
    
         
            -
            - example/rails/demo/script/about
         
     | 
| 
       97 
     | 
    
         
            -
            - example/rails/demo/script/book_djinn
         
     | 
| 
       98 
     | 
    
         
            -
            - example/rails/demo/script/console
         
     | 
| 
       99 
     | 
    
         
            -
            - example/rails/demo/script/dbconsole
         
     | 
| 
       100 
     | 
    
         
            -
            - example/rails/demo/script/destroy
         
     | 
| 
       101 
     | 
    
         
            -
            - example/rails/demo/script/generate
         
     | 
| 
       102 
     | 
    
         
            -
            - example/rails/demo/script/performance/benchmarker
         
     | 
| 
       103 
     | 
    
         
            -
            - example/rails/demo/script/performance/profiler
         
     | 
| 
       104 
     | 
    
         
            -
            - example/rails/demo/script/plugin
         
     | 
| 
       105 
     | 
    
         
            -
            - example/rails/demo/script/runner
         
     | 
| 
       106 
     | 
    
         
            -
            - example/rails/demo/script/server
         
     | 
| 
       107 
     | 
    
         
            -
            - example/rails/demo/test/fixtures/books.yml
         
     | 
| 
       108 
     | 
    
         
            -
            - example/rails/demo/test/functional/books_controller_test.rb
         
     | 
| 
       109 
     | 
    
         
            -
            - example/rails/demo/test/performance/browsing_test.rb
         
     | 
| 
       110 
     | 
    
         
            -
            - example/rails/demo/test/test_helper.rb
         
     | 
| 
       111 
     | 
    
         
            -
            - example/rails/demo/test/unit/book_test.rb
         
     | 
| 
       112 
     | 
    
         
            -
            - example/rails/demo/test/unit/helpers/books_helper_test.rb
         
     | 
| 
       113 
54 
     | 
    
         
             
            - lib/djinn.rb
         
     | 
| 
       114 
55 
     | 
    
         
             
            - lib/djinn/base.rb
         
     | 
| 
       115 
56 
     | 
    
         
             
            - lib/djinn/logging.rb
         
     | 
| 
         @@ -152,7 +93,7 @@ rubyforge_project: 
     | 
|
| 
       152 
93 
     | 
    
         
             
            rubygems_version: 1.3.7
         
     | 
| 
       153 
94 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       154 
95 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       155 
     | 
    
         
            -
            summary:  
     | 
| 
      
 96 
     | 
    
         
            +
            summary: Helper for creating simple custom daemons
         
     | 
| 
       156 
97 
     | 
    
         
             
            test_files: 
         
     | 
| 
       157 
98 
     | 
    
         
             
            - test/helper.rb
         
     | 
| 
       158 
99 
     | 
    
         
             
            - test/test_djinn.rb
         
     | 
    
        data/example/basic.rb
    DELETED
    
    | 
         @@ -1,27 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #!/usr/bin/env ruby
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            $:.unshift(File.join(File.dirname(__FILE__), "../lib/"))
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            require 'djinn'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            class Basic
         
     | 
| 
       8 
     | 
    
         
            -
              
         
     | 
| 
       9 
     | 
    
         
            -
              include Djinn
         
     | 
| 
       10 
     | 
    
         
            -
              
         
     | 
| 
       11 
     | 
    
         
            -
              # not providing a "perform" method falls back to the
         
     | 
| 
       12 
     | 
    
         
            -
              # base method in Djinn..
         
     | 
| 
       13 
     | 
    
         
            -
              
         
     | 
| 
       14 
     | 
    
         
            -
              def handle_exit
         
     | 
| 
       15 
     | 
    
         
            -
                puts "Handling a nice graceful exit.."
         
     | 
| 
       16 
     | 
    
         
            -
                super
         
     | 
| 
       17 
     | 
    
         
            -
              end
         
     | 
| 
       18 
     | 
    
         
            -
              
         
     | 
| 
       19 
     | 
    
         
            -
            end
         
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
            djinn = Basic.new
         
     | 
| 
       22 
     | 
    
         
            -
            djinn.run
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            # puts "Running for 10 secs in the background and then stopping.."
         
     | 
| 
       25 
     | 
    
         
            -
            # djinn.start
         
     | 
| 
       26 
     | 
    
         
            -
            # sleep(10)
         
     | 
| 
       27 
     | 
    
         
            -
            # djinn.stop
         
     | 
    
        data/example/em.rb
    DELETED
    
    | 
         @@ -1,58 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            $:.unshift(File.join(File.dirname(__FILE__), "../lib/"))
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'djinn'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'rubygems'
         
     | 
| 
       5 
     | 
    
         
            -
            require 'eventmachine'
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
            WORKER_INTERVAL = 5
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            class Worker
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
              include EM::Deferrable
         
     | 
| 
       12 
     | 
    
         
            -
              
         
     | 
| 
       13 
     | 
    
         
            -
              def do_stuff
         
     | 
| 
       14 
     | 
    
         
            -
                puts "Worker doing stuff.."
         
     | 
| 
       15 
     | 
    
         
            -
                succeed(Time.now)
         
     | 
| 
       16 
     | 
    
         
            -
              rescue => e
         
     | 
| 
       17 
     | 
    
         
            -
                fail(e)    
         
     | 
| 
       18 
     | 
    
         
            -
              end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            end
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            class EventMachineDjinn
         
     | 
| 
       23 
     | 
    
         
            -
              
         
     | 
| 
       24 
     | 
    
         
            -
              include Djinn
         
     | 
| 
       25 
     | 
    
         
            -
              
         
     | 
| 
       26 
     | 
    
         
            -
              def perform config
         
     | 
| 
       27 
     | 
    
         
            -
                
         
     | 
| 
       28 
     | 
    
         
            -
                worker = EM.spawn do
         
     | 
| 
       29 
     | 
    
         
            -
                  worker = Worker.new
         
     | 
| 
       30 
     | 
    
         
            -
                  worker.callback { |time| puts "Worker completed at: #{time}" }
         
     | 
| 
       31 
     | 
    
         
            -
                  worker.errback { |ex| puts "Twitter worker failed: #{ex}" }
         
     | 
| 
       32 
     | 
    
         
            -
                  worker.do_stuff
         
     | 
| 
       33 
     | 
    
         
            -
                end
         
     | 
| 
       34 
     | 
    
         
            -
                
         
     | 
| 
       35 
     | 
    
         
            -
                EM.run do
         
     | 
| 
       36 
     | 
    
         
            -
                  log "Workers will run every #{WORKER_INTERVAL} secs"
         
     | 
| 
       37 
     | 
    
         
            -
                  EM::PeriodicTimer.new(WORKER_INTERVAL) do
         
     | 
| 
       38 
     | 
    
         
            -
                    worker.notify
         
     | 
| 
       39 
     | 
    
         
            -
                  end
         
     | 
| 
       40 
     | 
    
         
            -
                end
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
              end
         
     | 
| 
       43 
     | 
    
         
            -
              
         
     | 
| 
       44 
     | 
    
         
            -
              def handle_exit
         
     | 
| 
       45 
     | 
    
         
            -
                EM.stop
         
     | 
| 
       46 
     | 
    
         
            -
                super
         
     | 
| 
       47 
     | 
    
         
            -
              end
         
     | 
| 
       48 
     | 
    
         
            -
              
         
     | 
| 
       49 
     | 
    
         
            -
            end
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
            puts "Running for 30 secs and then stopping.."
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
            djinn = EventMachineDjinn.new
         
     | 
| 
       54 
     | 
    
         
            -
            djinn.start
         
     | 
| 
       55 
     | 
    
         
            -
            sleep(30)
         
     | 
| 
       56 
     | 
    
         
            -
            djinn.stop
         
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            34464
         
     | 
    
        data/example/rails/demo/Rakefile
    DELETED
    
    | 
         @@ -1,10 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Add your own tasks in files placed in lib/tasks ending in .rake,
         
     | 
| 
       2 
     | 
    
         
            -
            # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            require(File.join(File.dirname(__FILE__), 'config', 'boot'))
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            require 'rake'
         
     | 
| 
       7 
     | 
    
         
            -
            require 'rake/testtask'
         
     | 
| 
       8 
     | 
    
         
            -
            require 'rake/rdoctask'
         
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            require 'tasks/rails'
         
     | 
| 
         @@ -1,10 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # Filters added to this controller apply to all controllers in the application.
         
     | 
| 
       2 
     | 
    
         
            -
            # Likewise, all the methods added will be available for all controllers.
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            class ApplicationController < ActionController::Base
         
     | 
| 
       5 
     | 
    
         
            -
              helper :all # include all helpers, all the time
         
     | 
| 
       6 
     | 
    
         
            -
              protect_from_forgery # See ActionController::RequestForgeryProtection for details
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
              # Scrub sensitive parameters from your log
         
     | 
| 
       9 
     | 
    
         
            -
              # filter_parameter_logging :password
         
     | 
| 
       10 
     | 
    
         
            -
            end
         
     |