touchstone 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.markdown +84 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/touchstone/application.js +15 -0
  5. data/app/assets/stylesheets/touchstone/application.css +13 -0
  6. data/app/assets/stylesheets/touchstone/touchstone.css +113 -0
  7. data/app/controllers/touchstone/application_controller.rb +4 -0
  8. data/app/controllers/touchstone/campaigns_controller.rb +28 -0
  9. data/app/helpers/touchstone/application_helper.rb +4 -0
  10. data/app/models/campaign.rb +44 -0
  11. data/app/models/campaign_signup.rb +8 -0
  12. data/app/models/campaign_visit.rb +7 -0
  13. data/app/views/layouts/touchstone/application.html.erb +14 -0
  14. data/app/views/layouts/touchstone/touchstone.html.erb +22 -0
  15. data/app/views/touchstone/campaigns/index.html.erb +26 -0
  16. data/app/views/touchstone/campaigns/new.html.erb +29 -0
  17. data/app/views/touchstone/campaigns/show.html.erb +43 -0
  18. data/config/routes.rb +5 -0
  19. data/db/migrate/001_create_touchstone_campaigns.rb +14 -0
  20. data/db/migrate/002_create_touchstone_campaign_signups.rb +11 -0
  21. data/db/migrate/003_create_touchstone_campaign_visits.rb +13 -0
  22. data/lib/tasks/touchstone_tasks.rake +10 -0
  23. data/lib/touchstone/configuration.rb +18 -0
  24. data/lib/touchstone/engine.rb +6 -0
  25. data/lib/touchstone/version.rb +3 -0
  26. data/lib/touchstone.rb +16 -0
  27. data/test/dummy/README.rdoc +261 -0
  28. data/test/dummy/Rakefile +7 -0
  29. data/test/dummy/app/assets/javascripts/application.js +15 -0
  30. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  31. data/test/dummy/app/controllers/application_controller.rb +3 -0
  32. data/test/dummy/app/helpers/application_helper.rb +2 -0
  33. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  34. data/test/dummy/config/application.rb +56 -0
  35. data/test/dummy/config/boot.rb +10 -0
  36. data/test/dummy/config/database.yml +42 -0
  37. data/test/dummy/config/environment.rb +5 -0
  38. data/test/dummy/config/environments/development.rb +37 -0
  39. data/test/dummy/config/environments/production.rb +67 -0
  40. data/test/dummy/config/environments/test.rb +37 -0
  41. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  42. data/test/dummy/config/initializers/inflections.rb +15 -0
  43. data/test/dummy/config/initializers/mime_types.rb +5 -0
  44. data/test/dummy/config/initializers/secret_token.rb +7 -0
  45. data/test/dummy/config/initializers/session_store.rb +8 -0
  46. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  47. data/test/dummy/config/locales/en.yml +5 -0
  48. data/test/dummy/config/routes.rb +4 -0
  49. data/test/dummy/config.ru +4 -0
  50. data/test/dummy/public/404.html +26 -0
  51. data/test/dummy/public/422.html +26 -0
  52. data/test/dummy/public/500.html +25 -0
  53. data/test/dummy/public/favicon.ico +0 -0
  54. data/test/dummy/script/rails +6 -0
  55. data/test/integration/navigation_test.rb +10 -0
  56. data/test/test_helper.rb +15 -0
  57. data/test/touchstone_test.rb +7 -0
  58. metadata +172 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,84 @@
1
+ Touchstone is a Rails Engine that adds the ability to track advanced metrics for your web app. It is inspired by [this post on the Think Vitamin blog](http://thinkvitamin.com/business/marketing/how-to-get-more-customers/).
2
+
3
+ Touchstone consists of 3 elements:
4
+
5
+ ## Campaigns
6
+ A campaign records the details of a source from which visitors will sign up to your website. It can be a Google Adwords campaign or a link on your homepage.
7
+
8
+ ## Campaign Visits
9
+ By adding the parameter ?cid= to each link, the visit will be recorded.
10
+
11
+ ## Campaign Signups
12
+ When a visitor visits your website via a link containing ?cid= and then signs up, the sign up is tied back to that visit and that campaign. You can then track the revenue obtained from each visitor against the cost of a particular campaign.
13
+
14
+ ## Installation
15
+ Add the following line to your Gemfile:
16
+
17
+ gem 'touchstone'
18
+
19
+ Then run `bundle install`
20
+
21
+ Copy the migrations across to your application by running `touchstone:install:migrations`. This will add a models for the 3 elements set out above.
22
+
23
+ You will need to mount Touchstone in your application by adding the following line to your `routes.rb` file:
24
+
25
+ mount Touchstone::Engine, :at => "/touchstone/"
26
+
27
+ Finally, add the following to your `application_controller.rb` file:
28
+
29
+ before_filter :set_cookie_and_record_visit
30
+
31
+ private
32
+
33
+ def set_cookie_and_record_visit
34
+ if params[:cid] && Campaign.find_by_id(params[:cid]) && !CampaignVisit.find_by_request_ip(request.remote_ip)
35
+ if !cookies['touchstone_campaign_id']
36
+ cookies['touchstone_campaign_id'] = "#{params[:cid]}"
37
+ CampaignVisit.create(:campaign_id => params[:cid], :request_ip => request.remote_ip)
38
+ end
39
+ end
40
+ end
41
+
42
+ ## Usage
43
+ Usage is very simple. Assume you are running a Google Adwords campaign for 1 week at a cost of $100. Create this campaign in Touchstone and it will return a campaign ID. Make sure all your links on Adwords contain the parameter at the end `?cid={campaign_id}` where `campaign_id` is the id generated by Touchstone. Please note:
44
+
45
+ * Campaigns don't need to be paid campaigns, it can be as simple as a link from your homepage or multiple links if A/B testing
46
+ * You can update the campaign cost at any time. All calculations are "on the fly" so you're metrics will update automatically
47
+
48
+ The installation steps described above will get you going with tracking visits from particular campaigns but you still have some work to do in linking this to your users. Touchstone only really provides a benefit when you track how much revenue your users bring in and then it will compare that to the cost of your campaigns. By way of examples only, you could adopt the following pattern to record a campaign signup:
49
+
50
+ class UsersController < ApplicationController
51
+ ...
52
+ def create
53
+ @user = User.new(params[:user])
54
+ if @user.save
55
+ unless cookies['touchstone_campaign_id'].nil?
56
+ campaign_id = cookies['touchstone_campaign_id']
57
+ CampaignSignup.create(:user_id => @user.id, :campaign_id => campaign_id)
58
+ end
59
+ flash["notice"] = "Successfully signed up"
60
+ ...
61
+ end
62
+ end
63
+ end
64
+
65
+ Tracking a user's lifetime value will depend on your transactional logic but assuming a common pattern of a user having a subscription and that subscription containing many transactions, the following could be used:
66
+
67
+ class User < ActiveRecord::Base
68
+ ...
69
+ def lifetime_value
70
+ total = Array.new
71
+ self.subscription.transactions.each do |t|
72
+ total << t.amount
73
+ end
74
+ total.inject{|sum,x| sum + x}
75
+ end
76
+ ...
77
+ end
78
+
79
+ ## Todo
80
+
81
+ * Don't constrain Touchstone to an application that only has a Users table. Allow this as a configuration option
82
+ * Automatically load routes and application controller content
83
+ * Improve design
84
+ * Add some tests
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Touchstone'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+
27
+
28
+ Bundler::GemHelper.install_tasks
29
+
30
+ require 'rake/testtask'
31
+
32
+ Rake::TestTask.new(:test) do |t|
33
+ t.libs << 'lib'
34
+ t.libs << 'test'
35
+ t.pattern = 'test/**/*_test.rb'
36
+ t.verbose = false
37
+ end
38
+
39
+
40
+ task :default => :test
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,113 @@
1
+ .touchstone {
2
+ font: 62.5% "Helvetica Neue", "Lucida Grande", "Trebuchet MS", Verdana, sans-serif;
3
+ font-weight: normal;
4
+ -webkit-text-shadow: 0px -1px 0px rgb(68,68,68);
5
+ }
6
+
7
+ .touchstone .wrapper {
8
+ width: 960px;
9
+ margin: 10px auto;
10
+ }
11
+
12
+ .touchstone h1 {
13
+ font-size: 3em;
14
+ margin-bottom: 1em;
15
+ }
16
+
17
+ .touchstone h2 {
18
+ font-size: 2.4em;
19
+ margin-bottom: 1em;
20
+ }
21
+
22
+ .touchstone h3 {
23
+ font-size: 2em;
24
+ margin-bottom: 1em;
25
+ }
26
+
27
+ .touchstone label {
28
+ float: left;
29
+ width: 120px;
30
+ margin-top: 2px;
31
+ font-weight: bold;
32
+ }
33
+
34
+ .touchstone p {
35
+ font-size: 1.4em;
36
+ margin-bottom: 1em;
37
+ }
38
+
39
+ .touchstone table {
40
+ font-size: 1.4em;
41
+ border: 1px solid rgb(153,178,183);
42
+ border-spacing: 0px 0px;
43
+ width: 100%;
44
+ }
45
+
46
+ .touchstone thead th {
47
+ padding: 8px 5px;
48
+ vertical-align: middle;
49
+ text-align: left;
50
+ text-transform: uppercase;
51
+ border-bottom: 1px solid rgb(153,178,183);
52
+ border-right: 1px solid rgb(153,178,183);
53
+ background-color: rgb(213,222,217);
54
+ }
55
+
56
+ .touchstone td {
57
+ font-size: 1.2em;
58
+ padding: 5px;
59
+ border-bottom: 1px solid rgb(153,178,183);
60
+ border-right: 1px solid rgb(153,178,183);
61
+ }
62
+
63
+ .touchstone #new-campaign {
64
+ float: right;
65
+ margin-top: 10px;
66
+ }
67
+
68
+ .touchstone #flash_notice {
69
+ background-color: #65ce6f;
70
+ border: 1px solid #00cf13;
71
+ font-weight: bold;
72
+ text-align: center;
73
+ padding: 5px 0;
74
+ margin: 0 200px 10px 200px;
75
+ }
76
+
77
+ .touchstone #flash_error {
78
+ background-color: #ff7272;
79
+ border: 1px solid #ff1515;
80
+ font-weight: bold;
81
+ text-align: center;
82
+ padding: 5px 0;
83
+ margin: 0 200px 10px 200px;
84
+ }
85
+
86
+ .touchstone #campaign-info {
87
+ margin: -3em 0 0 0;
88
+ font-size: 0.8em;
89
+ }
90
+
91
+ .touchstone #campaign-info p {
92
+ margin-top: -1em;
93
+ }
94
+
95
+ .touchstone #financials {
96
+ margin-bottom: 10px;
97
+ }
98
+
99
+ .touchstone .stats h3 {
100
+ display: inline;
101
+ }
102
+
103
+ .touchstone .stats span {
104
+ color: rgb(153,178,183);
105
+ }
106
+
107
+ .touchstone .stats h3:not(:first-of-type) {
108
+ margin-left: 15px;
109
+ }
110
+
111
+ .touchstone #visits {
112
+ margin-bottom: 20px;
113
+ }
@@ -0,0 +1,4 @@
1
+ module Touchstone
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,28 @@
1
+ class Touchstone::CampaignsController < ApplicationController
2
+
3
+ layout 'touchstone/touchstone'
4
+
5
+ def index
6
+ @campaigns = Campaign.all
7
+ end
8
+
9
+ def new
10
+ @campaign = Campaign.new
11
+ end
12
+
13
+ def create
14
+ @campaign = Campaign.new(params[:campaign])
15
+ if @campaign.save
16
+ flash[:notice] = "Campaign added"
17
+ redirect_to campaigns_url
18
+ else
19
+ flash[:error] = "Could not add campaign"
20
+ redirect_to new_campaign_url
21
+ end
22
+ end
23
+
24
+ def show
25
+ @campaign = Campaign.find(params[:id])
26
+ end
27
+
28
+ end
@@ -0,0 +1,4 @@
1
+ module Touchstone
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,44 @@
1
+ class Campaign < ActiveRecord::Base
2
+
3
+ validates :name, :presence => true
4
+ validates :spend_amount, :presence => true
5
+
6
+ has_many :campaign_signups
7
+ has_many :campaign_visits
8
+
9
+ attr_accessible :name, :notes, :start_date, :end_date, :spend_amount
10
+
11
+ def revenue
12
+ if self.campaign_signups.length > 0
13
+ total = Array.new
14
+ self.campaign_signups.each do |signup|
15
+ total << signup.user.lifetime_value # TODO: Fix this
16
+ end
17
+ total.inject{|sum,x| sum + x}
18
+ else
19
+ 0.00
20
+ end
21
+ end
22
+
23
+ def roi
24
+ if self.revenue == 0 || self.spend_amount == 0
25
+ 0.00
26
+ else
27
+ ((self.revenue - self.spend_amount) / self.spend_amount) * 100
28
+ end
29
+ end
30
+
31
+ def visits
32
+ self.campaign_visits.count
33
+ end
34
+
35
+ def conversion_rate
36
+ signups = self.campaign_signups.count
37
+ if signups > 0
38
+ (signups.to_f / self.visits.to_f ) * 100
39
+ else
40
+ 0.00
41
+ end
42
+ end
43
+
44
+ end
@@ -0,0 +1,8 @@
1
+ class CampaignSignup < ActiveRecord::Base
2
+
3
+ belongs_to :campaign, :class_name => "Campaign", :foreign_key => "campaign_id"
4
+ belongs_to :user, :class_name => "User", :foreign_key => "user_id" # TODO: Fix this
5
+
6
+ attr_accessible :user_id, :campaign_id
7
+
8
+ end
@@ -0,0 +1,7 @@
1
+ class CampaignVisit < ActiveRecord::Base
2
+
3
+ belongs_to :campaign, :class_name => "Campaign", :foreign_key => "campaign_id"
4
+
5
+ attr_accessible :campaign_id, :request_ip
6
+
7
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Touchstone</title>
5
+ <%= stylesheet_link_tag "touchstone/application", :media => "all" %>
6
+ <%= javascript_include_tag "touchstone/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Touchstone Metrics</title>
5
+ <%= stylesheet_link_tag "touchstone/touchstone.css" %>
6
+ <%= javascript_include_tag "application.js" %>
7
+ <%= csrf_meta_tag %>
8
+ </head>
9
+ <body class="touchstone">
10
+ <div class="wrapper">
11
+
12
+ <section id="flash">
13
+ <% flash.each do |key, value| -%>
14
+ <div id="flash_<%= key %>"><%= value.html_safe %></div>
15
+ <% end -%>
16
+ </section>
17
+
18
+ <%= yield %>
19
+
20
+ </div><!-- .wrapper -->
21
+ </body>
22
+ </html>
@@ -0,0 +1,26 @@
1
+ <p id="new-campaign"><%= link_to "New campaign", new_campaign_url %></p>
2
+
3
+ <h1>Campaigns</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th scope="col" width="15%">Campaign ID</th>
9
+ <th scope="col" width="36%">Name</th>
10
+ <th scope="col" width="17%">Start date</th>
11
+ <th scope="col" width="17%">End date</th>
12
+ <th scope="col" width="15%">Spend amount</th>
13
+ </tr>
14
+ </thead>
15
+ <tbody>
16
+ <% @campaigns.each do |campaign| %>
17
+ <tr>
18
+ <td><%= campaign.id %></td>
19
+ <td><%= link_to "#{campaign.name}", campaign_url(campaign.id) %></td>
20
+ <td><%= campaign.start_date.strftime("%d %B %Y") %></td>
21
+ <td><%= campaign.end_date.strftime("%d %B %Y") %></td>
22
+ <td>$<%= sprintf("%.2f", campaign.spend_amount) %></td>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
@@ -0,0 +1,29 @@
1
+ <h1>New campaign</h1>
2
+
3
+ <%= form_for @campaign do |f| %>
4
+
5
+ <p>
6
+ <%= f.label :name %>
7
+ <%= f.text_field :name %>
8
+ </p>
9
+ <p>
10
+ <%= f.label :notes %>
11
+ <%= f.text_area :notes %>
12
+ </p>
13
+ <p>
14
+ <%= f.label :start_date %>
15
+ <%= f.date_select :start_date, :order => [:day, :month, :year] %>
16
+ </p>
17
+ <p>
18
+ <%= f.label :end_date %>
19
+ <%= f.date_select :end_date, :order => [:day, :month, :year] %>
20
+ </p>
21
+ <p>
22
+ <%= f.label :spend_amount %>
23
+ <%= f.text_field :spend_amount %>
24
+ </p>
25
+ <p>
26
+ <%= f.submit "Create campaign" %>
27
+ </p>
28
+
29
+ <% end %>
@@ -0,0 +1,43 @@
1
+ <p><%= link_to "Home", campaigns_url %></p>
2
+
3
+ <h1>Campaign - <%= @campaign.name %></h1>
4
+
5
+ <section id="campaign-info">
6
+ <p><strong>Campaign ID:</strong> <%= @campaign.id %></p>
7
+
8
+ <p><strong>Campaign dates:</strong> From <%= @campaign.start_date.strftime("%d %B %Y") %> to <%= @campaign.end_date.strftime("%d %B %Y") %></p>
9
+ </section><!-- #campaign-info -->
10
+
11
+ <section id="financials" class="stats">
12
+ <h3><span class="financial-title">Campaign Spend:</span> $<%= sprintf("%.2f", @campaign.spend_amount) %></h3>
13
+ <h3><span class="financial-title">Campaign Revenue:</span> $<%= sprintf("%.2f", @campaign.revenue) %></h3>
14
+ <h3><span class="financial-title">Return on investment:</span> <%= sprintf("%.2f", @campaign.roi) %>%</h3>
15
+ </section>
16
+
17
+ <section id="visits" class="stats">
18
+ <h3><span class="visit-title">Unique Campaign Visits:</span> <%= @campaign.visits %></h3>
19
+ <h3><span class="visit-title">Conversion Rate:</span> <%= sprintf("%.2f",@campaign.conversion_rate) %>%</h3>
20
+ </section>
21
+
22
+ <h2>Signups via this campaign</h2>
23
+
24
+ <table>
25
+ <thead>
26
+ <tr>
27
+ <th scope="col" width="25%">Name</th>
28
+ <th scope="col" width="30%">Email</th>
29
+ <th scope="col" width="30%">Registered</th>
30
+ <th scope="col" width="15%">LTV (inc. VAT)</th>
31
+ </tr>
32
+ </thead>
33
+ <tbody>
34
+ <% @campaign.campaign_signups.each do |signup| %>
35
+ <tr>
36
+ <td><%= signup.user.name %></td>
37
+ <td><%= signup.user.email %></td>
38
+ <td><%= time_ago_in_words(signup.user.created_at) %> ago</td>
39
+ <td>$<%= sprintf("%.2f",signup.user.lifetime_value) %></td>
40
+ </tr>
41
+ <% end %>
42
+ </tbody>
43
+ </table>
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Touchstone::Engine.routes.draw do
2
+
3
+ resources :campaigns
4
+
5
+ end
@@ -0,0 +1,14 @@
1
+ class CreateTouchstoneCampaigns < ActiveRecord::Migration
2
+
3
+ def change
4
+ create_table :campaigns do |t|
5
+ t.string :name
6
+ t.text :notes
7
+ t.date :start_date
8
+ t.date :end_date
9
+ t.float :spend_amount
10
+ t.timestamps
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,11 @@
1
+ class CreateTouchstoneCampaignSignups < ActiveRecord::Migration
2
+
3
+ def change
4
+ create_table :campaign_signups do |t|
5
+ t.integer :user_id
6
+ t.integer :campaign_id
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ end
@@ -0,0 +1,13 @@
1
+ class CreateTouchstoneCampaignVisits < ActiveRecord::Migration
2
+
3
+ def change
4
+ create_table :campaign_visits do |t|
5
+ t.integer :campaign_id
6
+ t.string :request_ip
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :campaign_visits, :request_ip
11
+ end
12
+
13
+ end
@@ -0,0 +1,10 @@
1
+ # require 'thor'
2
+ # include Thor
3
+ #
4
+ # namespace :touchstone do
5
+ #
6
+ # desc "Injects the necessary code into your application to run Touchstone"
7
+ # task :install do
8
+ # inject_into_file "#{Rails.root}/config/routes.rb", "mount Touchstone::Engine, :at => '/touchstone/'", :after => "routes.draw do"
9
+ # end
10
+ # end
@@ -0,0 +1,18 @@
1
+ require 'singleton'
2
+ module Touchstone
3
+ module Configuration
4
+
5
+ extend self
6
+
7
+ attr_accessor :association_name
8
+
9
+ def association_name=name
10
+ @name = name
11
+ end
12
+
13
+ def association_name
14
+ @name || "user"
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,6 @@
1
+ module Touchstone
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Touchstone
4
+
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Touchstone
2
+ VERSION = "0.1.0"
3
+ end
data/lib/touchstone.rb ADDED
@@ -0,0 +1,16 @@
1
+ require "touchstone/engine"
2
+ require "touchstone/configuration"
3
+
4
+ module Touchstone
5
+
6
+ include Configuration
7
+
8
+ mattr_accessor :app_root
9
+
10
+ class << self
11
+ def configure &block
12
+ yield Touchstone::Configuration
13
+ end
14
+ end
15
+
16
+ end