devise_marketable 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +24 -0
- data/Rakefile +1 -0
- data/devise_marketable.gemspec +25 -0
- data/lib/devise_marketable/model.rb +8 -0
- data/lib/devise_marketable/version.rb +3 -0
- data/lib/devise_marketable.rb +57 -0
- data/lib/generators/devise_marketable/devise_marketable_generator.rb +31 -0
- data/lib/generators/devise_marketable/templates/migration.rb +11 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NDE2ZWYxNTdkOWQ1MzBkODkyMjZhN2YzZWEzYTZjYTI4NjE0ODIyOA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
M2JkMjJjNjg4MjMxNGQ0ZmEwOGZjZGZhOTkyYmEzZjBiZGY4NTliZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NGUyNGUwYWY0NzM4ZjJkNzcxMTAyYzRjZGM2NDkyYWRiMTk1YjMzZDM4NjA0
|
10
|
+
MGFiNmFmYjY5OWZjNThlMTFiZjRjMTVlYjRkMjQ1YmUzMDk3ZTg3NWJkMmJh
|
11
|
+
M2I3YWFiMTc0NDgwMWU1NTJhOGI0ZjMzZjRiMjhiODNlZWRhYzQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWMyNWQ3MTNlNzAyMzJkNTcwYzlhMWE1NzE2ZTM0NTZiNTE0MzgwZGQ5NzU1
|
14
|
+
ODhlODRlYTgzM2U1MGU5ZDQwODdiYzVlYmE2MjY3ZGY4YjZhYjFiZWZjNTZl
|
15
|
+
YWI0MzJlZDFiYmY0ZDE2ZThlOTkyY2Q4NDQwYjZjNDcxMWZlNTQ=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 nate
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Devise Marketable
|
2
|
+
===========
|
3
|
+
|
4
|
+
An easy way to store the common marketing data you need to judge the performance of marketing campaigns (e.g. referring_url and landing_url)
|
5
|
+
|
6
|
+
|
7
|
+
## Background
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
Installation
|
13
|
+
------------
|
14
|
+
|
15
|
+
1)
|
16
|
+
|
17
|
+
|
18
|
+
Feedback
|
19
|
+
--------
|
20
|
+
[Source code available on Github](https://github.com/n8/devise_marketable). Feedback and pull requests are greatly appreciated. Let me know if I can improve this.
|
21
|
+
|
22
|
+
-----------
|
23
|
+
|
24
|
+
P.S. [**I'd love to meet you on Twitter: here**](http://twitter.com/natekontny).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'devise_marketable/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "devise_marketable"
|
8
|
+
spec.version = DeviseMarketable::VERSION
|
9
|
+
spec.authors = ["nate"]
|
10
|
+
spec.email = ["nate@cityposh.com"]
|
11
|
+
spec.description = %q{A simple way to have Devise capture important marketing data.}
|
12
|
+
spec.summary = %q{A simple way to have Devise capture important marketing data.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "devise", "~> 2.2.7"
|
25
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "devise"
|
2
|
+
require "devise_marketable/version"
|
3
|
+
|
4
|
+
Devise.add_module :marketable, :model => 'devise_marketable/model', controller: :registrations
|
5
|
+
|
6
|
+
module DeviseMarketable
|
7
|
+
|
8
|
+
module Controller
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
included do
|
12
|
+
before_filter :set_tracking_cookies
|
13
|
+
end
|
14
|
+
|
15
|
+
def set_tracking_cookies
|
16
|
+
cookies[:referring_url] = { :value => request.env['HTTP_REFERER'], :expires => 90.days.from_now } if cookies[:referring_url].blank?
|
17
|
+
cookies[:landing_url] = { :value => request.url, :expires => 90.days.from_now } if cookies[:landing_url].blank?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module RegistrationsController
|
22
|
+
extend ActiveSupport::Concern
|
23
|
+
|
24
|
+
included do
|
25
|
+
alias :devise_build_resource :build_resource
|
26
|
+
def build_resource(hash = nil); custom_build_resource(hash); end
|
27
|
+
end
|
28
|
+
|
29
|
+
def custom_build_resource(hash = nil)
|
30
|
+
devise_build_resource(hash)
|
31
|
+
|
32
|
+
if devise_mapping.marketable?
|
33
|
+
add_marketing_bits
|
34
|
+
end
|
35
|
+
|
36
|
+
return self.resource
|
37
|
+
end
|
38
|
+
|
39
|
+
def add_marketing_bits
|
40
|
+
self.resource.referring_url = cookies[:referring_url]
|
41
|
+
self.resource.landing_url = cookies[:landing_url]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
class Engine < ::Rails::Engine
|
46
|
+
|
47
|
+
ActiveSupport.on_load(:action_controller) do
|
48
|
+
include DeviseMarketable::Controller
|
49
|
+
end
|
50
|
+
|
51
|
+
config.to_prepare do
|
52
|
+
Devise::RegistrationsController.send :include, DeviseMarketable::RegistrationsController
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
|
3
|
+
class DeviseMarketableGenerator < Rails::Generators::NamedBase
|
4
|
+
include Rails::Generators::Migration
|
5
|
+
|
6
|
+
def self.source_root
|
7
|
+
@_devise_source_root ||= File.expand_path("../templates", __FILE__)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.orm_has_migration?
|
11
|
+
Rails::Generators.options[:rails][:orm] == :active_record
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.next_migration_number(dirname)
|
15
|
+
if ActiveRecord::Base.timestamped_migrations
|
16
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
17
|
+
else
|
18
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class_option :orm
|
23
|
+
class_option :migration, :type => :boolean, :default => orm_has_migration?
|
24
|
+
|
25
|
+
|
26
|
+
def create_migration_file
|
27
|
+
migration_template 'migration.rb', "db/migrate/devise_add_marketable_#{name.downcase}.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class DeviseAddMarketable<%= table_name.camelize.singularize %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :<%= table_name %>, :referring_url, :text
|
4
|
+
add_column :<%= table_name %>, :landing_url, :text
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.down
|
8
|
+
remove_column :<%= table_name %>, :referring_url
|
9
|
+
remove_column :<%= table_name %>, :landing_url
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise_marketable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- nate
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: devise
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.2.7
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.2.7
|
55
|
+
description: A simple way to have Devise capture important marketing data.
|
56
|
+
email:
|
57
|
+
- nate@cityposh.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- devise_marketable.gemspec
|
68
|
+
- lib/devise_marketable.rb
|
69
|
+
- lib/devise_marketable/model.rb
|
70
|
+
- lib/devise_marketable/version.rb
|
71
|
+
- lib/generators/devise_marketable/devise_marketable_generator.rb
|
72
|
+
- lib/generators/devise_marketable/templates/migration.rb
|
73
|
+
homepage: ''
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.0.6
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: A simple way to have Devise capture important marketing data.
|
97
|
+
test_files: []
|