url_job 0.0.2 → 0.0.3
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/CHANGELOG +2 -0
- data/README.rdoc +7 -4
- data/config/routes.rb +2 -2
- data/lib/url_job/job.rb +14 -1
- data/lib/url_job/version.rb +1 -1
- metadata +5 -14
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
@@ -13,7 +13,10 @@ This is a rails gem that provides an engine which allows for creating urls that
|
|
13
13
|
|
14
14
|
== Usage
|
15
15
|
|
16
|
-
|
16
|
+
rails g url_job
|
17
|
+
rake db:migrate
|
18
|
+
|
19
|
+
Now lets assume you have a class like:
|
17
20
|
|
18
21
|
class Redirector < Struct.new(:redirect_to)
|
19
22
|
def initialize(redirect)
|
@@ -29,10 +32,10 @@ By creating a UrlJob using the following:
|
|
29
32
|
uj = UrlJob::Job.from_object(Redirector.new("http://frison.ca"))
|
30
33
|
|
31
34
|
And visiting:
|
32
|
-
http://localhost:3000/uj/#{uj.token}
|
35
|
+
http://localhost:3000/uj/#{uj.token} or http://localhost:3000/uj/#{uj.path} or #{uj.url} (assuming default_url_options[:host] is setup for ActionMailer)
|
33
36
|
|
34
37
|
The result will be deserializing the Redirector job, and calling it's perform method.
|
35
|
-
The perform method
|
38
|
+
The perform method must return an object that responds to either: 'redirect_to' or 'render', and the corresponding action will occur. The perform method will be passed in a dictionary with the following keys:
|
36
39
|
:ip_address => The ip address of the url visitor
|
37
40
|
:user_agent => The user agent of the url visitor
|
38
41
|
:referrer => The referrer of the url visitor
|
@@ -64,7 +67,7 @@ And embed a image tag like:
|
|
64
67
|
Inside some emails to track some email opens
|
65
68
|
|
66
69
|
== Thanks
|
67
|
-
UrlJob::Job almost exactly a stripped down version of Delayed::Job
|
70
|
+
UrlJob::Job almost exactly a stripped down version of Delayed::Job with a controller
|
68
71
|
|
69
72
|
== Licence
|
70
73
|
|
data/config/routes.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
Rails.application.routes.draw do |map|
|
2
|
-
match '/uj/:token', :action => 'perform', :controller => "UrlJob/UrlJob"
|
3
|
-
end
|
2
|
+
match '/uj/:token', :action => 'perform', :controller => "UrlJob/UrlJob", :as => 'url_job'
|
3
|
+
end
|
data/lib/url_job/job.rb
CHANGED
@@ -2,6 +2,8 @@ module UrlJob
|
|
2
2
|
require 'uniquify'
|
3
3
|
|
4
4
|
class Job < ActiveRecord::Base
|
5
|
+
include ActionController::UrlWriter
|
6
|
+
|
5
7
|
set_table_name :url_jobs
|
6
8
|
|
7
9
|
uniquify :token do
|
@@ -20,6 +22,18 @@ module UrlJob
|
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
25
|
+
def path
|
26
|
+
url_job_path(:token => self.token)
|
27
|
+
end
|
28
|
+
|
29
|
+
def url
|
30
|
+
url_job_url(:token => self.token, :host => host)
|
31
|
+
end
|
32
|
+
|
33
|
+
def host
|
34
|
+
ActionMailer::Base.default_url_options[:host]
|
35
|
+
end
|
36
|
+
|
23
37
|
def limit_reached?
|
24
38
|
return false if no_limit?
|
25
39
|
action_count >= action_limit
|
@@ -49,6 +63,5 @@ module UrlJob
|
|
49
63
|
raise DeserializationError,
|
50
64
|
"UrlJob failed to load: #{e.message}. Handler: #{handler.inspect}"
|
51
65
|
end
|
52
|
-
|
53
66
|
end
|
54
67
|
end
|
data/lib/url_job/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: url_job
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Timothy Frison
|
@@ -15,18 +14,16 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-
|
17
|
+
date: 2011-04-03 00:00:00 -06:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: uniquify
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
24
|
requirements:
|
27
25
|
- - ">="
|
28
26
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 27
|
30
27
|
segments:
|
31
28
|
- 0
|
32
29
|
- 1
|
@@ -38,11 +35,9 @@ dependencies:
|
|
38
35
|
name: rails
|
39
36
|
prerelease: false
|
40
37
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
38
|
requirements:
|
43
39
|
- - ">="
|
44
40
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 7
|
46
41
|
segments:
|
47
42
|
- 3
|
48
43
|
- 0
|
@@ -85,27 +80,23 @@ rdoc_options: []
|
|
85
80
|
require_paths:
|
86
81
|
- lib
|
87
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
-
none: false
|
89
83
|
requirements:
|
90
84
|
- - ">="
|
91
85
|
- !ruby/object:Gem::Version
|
92
|
-
hash: 3
|
93
86
|
segments:
|
94
87
|
- 0
|
95
88
|
version: "0"
|
96
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
90
|
requirements:
|
99
91
|
- - ">="
|
100
92
|
- !ruby/object:Gem::Version
|
101
|
-
hash: 3
|
102
93
|
segments:
|
103
94
|
- 0
|
104
95
|
version: "0"
|
105
96
|
requirements: []
|
106
97
|
|
107
98
|
rubyforge_project: url_job
|
108
|
-
rubygems_version: 1.
|
99
|
+
rubygems_version: 1.3.6
|
109
100
|
signing_key:
|
110
101
|
specification_version: 3
|
111
102
|
summary: A rails engine for creating urls that run jobs
|