due_credit 0.0.1
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/.gitignore +11 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +97 -0
- data/LICENSE.txt +22 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +51 -0
- data/Rakefile +29 -0
- data/app/controllers/due_credit/credit_controller.rb +9 -0
- data/app/models/due_credit/campaign.rb +8 -0
- data/app/models/due_credit/referral.rb +7 -0
- data/app/models/due_credit/referrer.rb +9 -0
- data/config/routes.rb +3 -0
- data/due_credit.gemspec +21 -0
- data/lib/due_credit.rb +16 -0
- data/lib/due_credit/engine.rb +15 -0
- data/lib/due_credit/version.rb +3 -0
- data/lib/generators/due_credit/due_credit_generator.rb +23 -0
- data/lib/generators/due_credit/templates/migration.rb +40 -0
- data/test/due_credit_test.rb +7 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +45 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +22 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +26 -0
- data/test/dummy/config/environments/production.rb +49 -0
- data/test/dummy/config/environments/test.rb +35 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +10 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +26 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/javascripts/application.js +2 -0
- data/test/dummy/public/javascripts/controls.js +965 -0
- data/test/dummy/public/javascripts/dragdrop.js +974 -0
- data/test/dummy/public/javascripts/effects.js +1123 -0
- data/test/dummy/public/javascripts/prototype.js +6001 -0
- data/test/dummy/public/javascripts/rails.js +202 -0
- data/test/dummy/public/stylesheets/.gitkeep +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/navigation_test.rb +7 -0
- data/test/support/integration_case.rb +5 -0
- data/test/test_helper.rb +22 -0
- metadata +131 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
actionmailer (3.2.13)
|
5
|
+
actionpack (= 3.2.13)
|
6
|
+
mail (~> 2.5.3)
|
7
|
+
actionpack (3.2.13)
|
8
|
+
activemodel (= 3.2.13)
|
9
|
+
activesupport (= 3.2.13)
|
10
|
+
builder (~> 3.0.0)
|
11
|
+
erubis (~> 2.7.0)
|
12
|
+
journey (~> 1.0.4)
|
13
|
+
rack (~> 1.4.5)
|
14
|
+
rack-cache (~> 1.2)
|
15
|
+
rack-test (~> 0.6.1)
|
16
|
+
sprockets (~> 2.2.1)
|
17
|
+
activemodel (3.2.13)
|
18
|
+
activesupport (= 3.2.13)
|
19
|
+
builder (~> 3.0.0)
|
20
|
+
activerecord (3.2.13)
|
21
|
+
activemodel (= 3.2.13)
|
22
|
+
activesupport (= 3.2.13)
|
23
|
+
arel (~> 3.0.2)
|
24
|
+
tzinfo (~> 0.3.29)
|
25
|
+
activeresource (3.2.13)
|
26
|
+
activemodel (= 3.2.13)
|
27
|
+
activesupport (= 3.2.13)
|
28
|
+
activesupport (3.2.13)
|
29
|
+
i18n (= 0.6.1)
|
30
|
+
multi_json (~> 1.0)
|
31
|
+
arel (3.0.2)
|
32
|
+
builder (3.0.4)
|
33
|
+
capybara (2.1.0)
|
34
|
+
mime-types (>= 1.16)
|
35
|
+
nokogiri (>= 1.3.3)
|
36
|
+
rack (>= 1.0.0)
|
37
|
+
rack-test (>= 0.5.4)
|
38
|
+
xpath (~> 2.0)
|
39
|
+
erubis (2.7.0)
|
40
|
+
hike (1.2.2)
|
41
|
+
i18n (0.6.1)
|
42
|
+
journey (1.0.4)
|
43
|
+
json (1.8.0)
|
44
|
+
mail (2.5.4)
|
45
|
+
mime-types (~> 1.16)
|
46
|
+
treetop (~> 1.4.8)
|
47
|
+
mime-types (1.23)
|
48
|
+
multi_json (1.7.3)
|
49
|
+
nokogiri (1.5.9)
|
50
|
+
polyglot (0.3.3)
|
51
|
+
rack (1.4.5)
|
52
|
+
rack-cache (1.2)
|
53
|
+
rack (>= 0.4)
|
54
|
+
rack-ssl (1.3.3)
|
55
|
+
rack
|
56
|
+
rack-test (0.6.2)
|
57
|
+
rack (>= 1.0)
|
58
|
+
rails (3.2.13)
|
59
|
+
actionmailer (= 3.2.13)
|
60
|
+
actionpack (= 3.2.13)
|
61
|
+
activerecord (= 3.2.13)
|
62
|
+
activeresource (= 3.2.13)
|
63
|
+
activesupport (= 3.2.13)
|
64
|
+
bundler (~> 1.0)
|
65
|
+
railties (= 3.2.13)
|
66
|
+
railties (3.2.13)
|
67
|
+
actionpack (= 3.2.13)
|
68
|
+
activesupport (= 3.2.13)
|
69
|
+
rack-ssl (~> 1.3.2)
|
70
|
+
rake (>= 0.8.7)
|
71
|
+
rdoc (~> 3.4)
|
72
|
+
thor (>= 0.14.6, < 2.0)
|
73
|
+
rake (10.0.4)
|
74
|
+
rdoc (3.12.2)
|
75
|
+
json (~> 1.4)
|
76
|
+
sprockets (2.2.2)
|
77
|
+
hike (~> 1.2)
|
78
|
+
multi_json (~> 1.0)
|
79
|
+
rack (~> 1.0)
|
80
|
+
tilt (~> 1.1, != 1.3.0)
|
81
|
+
sqlite3 (1.3.7)
|
82
|
+
thor (0.18.1)
|
83
|
+
tilt (1.4.1)
|
84
|
+
treetop (1.4.12)
|
85
|
+
polyglot
|
86
|
+
polyglot (>= 0.3.1)
|
87
|
+
tzinfo (0.3.37)
|
88
|
+
xpath (2.0.0)
|
89
|
+
nokogiri (~> 1.3)
|
90
|
+
|
91
|
+
PLATFORMS
|
92
|
+
ruby
|
93
|
+
|
94
|
+
DEPENDENCIES
|
95
|
+
capybara (>= 0.4.0)
|
96
|
+
rails (~> 3.2.13)
|
97
|
+
sqlite3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tom Hanley
|
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/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2013 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.rdoc
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# DueCredit
|
2
|
+
|
3
|
+
A rails engine to give credit to your users for referring people back to your site. For instance if you have someone sign up, you give them a unique link back to your site for them to share on Twitter, Facebook, Emails, etc.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'due_credit'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install due_credit
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
# Generate the migrations
|
22
|
+
|
23
|
+
$ bundle exec rails g due_credit
|
24
|
+
|
25
|
+
# Run the migration. This should create the following tables: Campaigns, Referrers, Referrals
|
26
|
+
|
27
|
+
# From your app
|
28
|
+
|
29
|
+
DueCredit::Campaign.create!(name: 'something', threshold: 5, endpoint: '/welcome')
|
30
|
+
DueCredit::Referrer.create!(campaign: DueCredit::Campaign.first, token: 'unique-token-1234', model: 'User', model_id: User.first.id)
|
31
|
+
DueCredit::Referral.create!(referrer: DueCredit::Referrer.first)
|
32
|
+
|
33
|
+
# Routes added
|
34
|
+
|
35
|
+
get "due-credit/:token" => "due_credit/credit#click_through" , :as => :due_credit
|
36
|
+
|
37
|
+
## TODO
|
38
|
+
|
39
|
+
A shit ton. basic link through working.
|
40
|
+
|
41
|
+
## Reference
|
42
|
+
|
43
|
+
http://coding.smashingmagazine.com/2011/06/23/a-guide-to-starting-your-own-rails-engine-gem/
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rake'
|
10
|
+
require 'rdoc/task'
|
11
|
+
|
12
|
+
require 'rake/testtask'
|
13
|
+
|
14
|
+
Rake::TestTask.new(:test) do |t|
|
15
|
+
t.libs << 'lib'
|
16
|
+
t.libs << 'test'
|
17
|
+
t.pattern = 'test/**/*_test.rb'
|
18
|
+
t.verbose = false
|
19
|
+
end
|
20
|
+
|
21
|
+
task :default => :test
|
22
|
+
|
23
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
24
|
+
rdoc.rdoc_dir = 'rdoc'
|
25
|
+
rdoc.title = 'DueCredit'
|
26
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
27
|
+
rdoc.rdoc_files.include('README.rdoc')
|
28
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
|
+
end
|
data/config/routes.rb
ADDED
data/due_credit.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Provide a simple gemspec so you can easily use your enginex
|
2
|
+
# project in your rails apps through git.
|
3
|
+
require File.expand_path("../lib/due_credit/version", __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "due_credit"
|
7
|
+
s.version = DueCredit::VERSION
|
8
|
+
s.authors = [ "Thomas Hanley" ]
|
9
|
+
s.email = [ "tjhanleyx@gmail.com" ]
|
10
|
+
s.homepage = "http://github.com/tjhanley"
|
11
|
+
s.summary = "#{s.name}-#{s.version}"
|
12
|
+
s.description = "The system will give the user credit for the referral. You can set a threshold on a campaign so the user gets full credit"
|
13
|
+
#s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.required_rubygems_version = "> 1.3.6"
|
18
|
+
|
19
|
+
s.add_dependency "activesupport" , "~> 3.2.13"
|
20
|
+
s.add_dependency "rails" , "~> 3.2.13"
|
21
|
+
end
|
data/lib/due_credit.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# CURRENT FILE :: lib/due_credit.rb
|
2
|
+
# Requires
|
3
|
+
require "active_support/dependencies"
|
4
|
+
module DueCredit
|
5
|
+
# Our host application root path
|
6
|
+
# We set this when the engine is initialized
|
7
|
+
mattr_accessor :app_root
|
8
|
+
|
9
|
+
# Yield self on setup for nice config blocks
|
10
|
+
def self.setup
|
11
|
+
yield self
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
# Require our engine
|
16
|
+
require "due_credit/engine"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module DueCredit
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
|
4
|
+
initializer "due_credit.load_app_instance_data" do |app|
|
5
|
+
DueCredit.setup do |config|
|
6
|
+
config.app_root = app.root
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
initializer "due_credit.load_static_assets" do |app|
|
11
|
+
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# CURRENT FILE :: lib/generators/due_credit/due_credit_generator.rb
|
2
|
+
# Requires
|
3
|
+
require 'rails/generators'
|
4
|
+
require 'rails/generators/migration'
|
5
|
+
|
6
|
+
class DueCreditGenerator < Rails::Generators::Base
|
7
|
+
include Rails::Generators::Migration
|
8
|
+
def self.source_root
|
9
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.next_migration_number(dirname)
|
13
|
+
if ActiveRecord::Base.timestamped_migrations
|
14
|
+
Time.new.utc.strftime("%Y%m%d%H%M%S")
|
15
|
+
else
|
16
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_migration_file
|
21
|
+
migration_template 'migration.rb', 'db/migrate/create_due_credit_tables.rb'
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# CURRENT FILE :: lib/generators/due_credit/templates/migration.rb
|
2
|
+
class CreateDueCreditTables < ActiveRecord::Migration
|
3
|
+
def self.up
|
4
|
+
create_table :campaigns do |t|
|
5
|
+
t.string :name
|
6
|
+
t.integer :threshold, :default => 0
|
7
|
+
t.string :endpoint
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
create_table :referrers do |t|
|
12
|
+
t.string :token
|
13
|
+
t.string :model
|
14
|
+
t.integer :model_id
|
15
|
+
t.references :campaign
|
16
|
+
t.timestamps
|
17
|
+
end
|
18
|
+
|
19
|
+
create_table :referrals do |t|
|
20
|
+
t.references :referrer
|
21
|
+
t.timestamps
|
22
|
+
end
|
23
|
+
|
24
|
+
add_index :campaigns, :name
|
25
|
+
add_index :referrers, :token
|
26
|
+
add_index :referrals, :referrer_id
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.down
|
30
|
+
|
31
|
+
remove_index :campaigns, :name
|
32
|
+
remove_index :referrers, :token
|
33
|
+
remove_index :referrals, :referrer_id
|
34
|
+
|
35
|
+
drop_table :campaigns
|
36
|
+
drop_table :referrers
|
37
|
+
drop_table :referrals
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
5
|
+
require 'rake'
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|