due_credit 0.0.1 → 0.1.0
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/Gemfile +0 -2
- data/Gemfile.lock +0 -12
- data/README.rdoc +5 -1
- data/app/models/due_credit/campaign.rb +3 -0
- data/app/models/due_credit/referrer.rb +24 -0
- data/due_credit.gemspec +1 -1
- data/lib/due_credit/version.rb +1 -1
- data/lib/due_credit.rb +2 -1
- metadata +4 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -30,12 +30,6 @@ GEM
|
|
30
30
|
multi_json (~> 1.0)
|
31
31
|
arel (3.0.2)
|
32
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
33
|
erubis (2.7.0)
|
40
34
|
hike (1.2.2)
|
41
35
|
i18n (0.6.1)
|
@@ -46,7 +40,6 @@ GEM
|
|
46
40
|
treetop (~> 1.4.8)
|
47
41
|
mime-types (1.23)
|
48
42
|
multi_json (1.7.3)
|
49
|
-
nokogiri (1.5.9)
|
50
43
|
polyglot (0.3.3)
|
51
44
|
rack (1.4.5)
|
52
45
|
rack-cache (1.2)
|
@@ -78,20 +71,15 @@ GEM
|
|
78
71
|
multi_json (~> 1.0)
|
79
72
|
rack (~> 1.0)
|
80
73
|
tilt (~> 1.1, != 1.3.0)
|
81
|
-
sqlite3 (1.3.7)
|
82
74
|
thor (0.18.1)
|
83
75
|
tilt (1.4.1)
|
84
76
|
treetop (1.4.12)
|
85
77
|
polyglot
|
86
78
|
polyglot (>= 0.3.1)
|
87
79
|
tzinfo (0.3.37)
|
88
|
-
xpath (2.0.0)
|
89
|
-
nokogiri (~> 1.3)
|
90
80
|
|
91
81
|
PLATFORMS
|
92
82
|
ruby
|
93
83
|
|
94
84
|
DEPENDENCIES
|
95
|
-
capybara (>= 0.4.0)
|
96
85
|
rails (~> 3.2.13)
|
97
|
-
sqlite3
|
data/README.rdoc
CHANGED
@@ -27,9 +27,13 @@ Or install it yourself as:
|
|
27
27
|
# From your app
|
28
28
|
|
29
29
|
DueCredit::Campaign.create!(name: 'something', threshold: 5, endpoint: '/welcome')
|
30
|
-
DueCredit::Referrer.create!(campaign: DueCredit::Campaign.first,
|
30
|
+
DueCredit::Referrer.create!(campaign: DueCredit::Campaign.first, model: 'User', model_id: User.first.id)
|
31
31
|
DueCredit::Referral.create!(referrer: DueCredit::Referrer.first)
|
32
32
|
|
33
|
+
Alternatively you can put in a Rails initializer something like this
|
34
|
+
|
35
|
+
$due_credit_campaign = DueCredit::Campaign.where(name:'Product Announce', endpoint: '/').first_or_create
|
36
|
+
|
33
37
|
# Routes added
|
34
38
|
|
35
39
|
get "due-credit/:token" => "due_credit/credit#click_through" , :as => :due_credit
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Use to create a sharing token for your Referrer
|
2
|
+
#
|
3
|
+
# DueCredit::Referrer.create(campaign: $due_credit_campaign, model: 'user', model_id: user.id)
|
4
|
+
#
|
5
|
+
|
1
6
|
module DueCredit
|
2
7
|
class Referrer < ActiveRecord::Base
|
3
8
|
attr_accessible :token, :model, :model_id, :campaign
|
@@ -5,5 +10,24 @@ module DueCredit
|
|
5
10
|
has_many :referrals
|
6
11
|
validates_presence_of :token, :model, :model_id, :campaign_id
|
7
12
|
validates_uniqueness_of :token
|
13
|
+
before_validation :on => :create do |record|
|
14
|
+
record.ensure_unique
|
15
|
+
end
|
16
|
+
|
17
|
+
# Ensures that the token will be unique when created
|
18
|
+
#
|
19
|
+
#
|
20
|
+
def ensure_unique(&block)
|
21
|
+
begin
|
22
|
+
self['token'] = (block ? block.call : self.class.generate_unique)
|
23
|
+
end while self.class.exists?('token' => self['token'])
|
24
|
+
|
25
|
+
self['token']
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.generate_unique
|
29
|
+
SecureRandom.hex(5)
|
30
|
+
end
|
31
|
+
|
8
32
|
end
|
9
33
|
end
|
data/due_credit.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.version = DueCredit::VERSION
|
8
8
|
s.authors = [ "Thomas Hanley" ]
|
9
9
|
s.email = [ "tjhanleyx@gmail.com" ]
|
10
|
-
s.homepage = "
|
10
|
+
s.homepage = "https://github.com/tjhanley/due_credit"
|
11
11
|
s.summary = "#{s.name}-#{s.version}"
|
12
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
13
|
#s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
|
data/lib/due_credit/version.rb
CHANGED
data/lib/due_credit.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# CURRENT FILE :: lib/due_credit.rb
|
2
2
|
# Requires
|
3
3
|
require "active_support/dependencies"
|
4
|
+
require "securerandom"
|
4
5
|
module DueCredit
|
5
6
|
# Our host application root path
|
6
7
|
# We set this when the engine is initialized
|
@@ -13,4 +14,4 @@ module DueCredit
|
|
13
14
|
|
14
15
|
end
|
15
16
|
# Require our engine
|
16
|
-
require "due_credit/engine"
|
17
|
+
require "due_credit/engine"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: due_credit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -104,7 +104,7 @@ files:
|
|
104
104
|
- test/integration/navigation_test.rb
|
105
105
|
- test/support/integration_case.rb
|
106
106
|
- test/test_helper.rb
|
107
|
-
homepage:
|
107
|
+
homepage: https://github.com/tjhanley/due_credit
|
108
108
|
licenses: []
|
109
109
|
post_install_message:
|
110
110
|
rdoc_options: []
|
@@ -127,5 +127,5 @@ rubyforge_project:
|
|
127
127
|
rubygems_version: 1.8.23
|
128
128
|
signing_key:
|
129
129
|
specification_version: 3
|
130
|
-
summary: due_credit-0.0
|
130
|
+
summary: due_credit-0.1.0
|
131
131
|
test_files: []
|