Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Now includes a migration for UrlJob. Version bump

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

0 comments on commit 4a382af

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