Skip to content
Browse files

Now includes a migration for UrlJob. Version bump

  • Loading branch information...
1 parent 905cc78 commit 4a382aff97e15ba5f88a34d313a0debefe205efa @frison committed Feb 22, 2011
Showing with 58 additions and 7 deletions.
  1. +7 −0 CHANGELOG
  2. +0 −3 NOTES
  3. +3 −0 README.rdoc
  4. +17 −0 lib/generators/templates/migration.rb
  5. +29 −0 lib/generators/url_job_generator.rb
  6. +1 −3 lib/url_job/job.rb
  7. +1 −1 lib/url_job/version.rb
View
7 CHANGELOG
@@ -0,0 +1,7 @@
+0.0.2
+ - Give credit to delayed_job
+ - Change description
+ - Can now generate migrations
+0.0.1
+ - Ability to create jobs
+ - Url redirects / render (text)
View
3 NOTES
@@ -1,3 +0,0 @@
-0.1.0
- - Ability to create jobs
- - Url redirects / render (text)
View
3 README.rdoc
@@ -63,6 +63,9 @@ And embed a image tag like:
Inside some emails to track some email opens
+== Thanks
+UrlJob::Job almost exactly a stripped down version of Delayed::Job.
+
== Licence
Copyright (c) 2011 Timothy Frison
View
17 lib/generators/templates/migration.rb
@@ -0,0 +1,17 @@
+class CreateUrlJobs < ActiveRecord::Migration
+ def self.up
+ create_table :url_jobs, :force => true do |t|
+ t.string :token, :limit => 60 # The unique token for looking up this entry.
+ t.integer :action_limit, :default => 0 # The number of times the action can be executed when url visited.
+ t.integer :action_count, :default => 0 # The number of times the action has been executed when url visited.
+ t.text :handler # YAML-encoded string of the object that will do work
+ t.timestamps
+ end
+
+ add_index :url_jobs, [:token]
+ end
+
+ def self.down
+ drop_table :url_jobs
+ end
+end
View
29 lib/generators/url_job_generator.rb
@@ -0,0 +1,29 @@
+require 'rails/generators'
+require 'rails/generators/migration'
+
+class UrlJobGenerator < Rails::Generators::Base
+
+ include Rails::Generators::Migration
+
+ def self.source_root
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
+ end
+
+ # Implement the required interface for Rails::Generators::Migration.
+ #
+ def self.next_migration_number(dirname) #:nodoc:
+ next_migration_number = current_migration_number(dirname) + 1
+ if ActiveRecord::Base.timestamped_migrations
+ [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
+ else
+ "%.3d" % next_migration_number
+ end
+ end
+
+ def create_migration_file
+ if defined?(ActiveRecord)
+ migration_template 'migration.rb', 'db/migrate/create_url_jobs.rb'
+ end
+ end
+
+end
View
4 lib/url_job/job.rb
@@ -8,8 +8,6 @@ class Job < ActiveRecord::Base
SecureRandom.hex(40)
end
-
-
validates :handler, :presence => true
class << self
@@ -53,4 +51,4 @@ def payload_object
end
end
-end
+end
View
2 lib/url_job/version.rb
@@ -1,3 +1,3 @@
module UrlJob
- VERSION = "0.0.1".freeze
+ VERSION = "0.0.2".freeze
end

0 comments on commit 4a382af

Please sign in to comment.
Something went wrong with that request. Please try again.