trade_tracker 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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +75 -0
- data/Rakefile +2 -0
- data/lib/generators/trade_tracker/config_generator.rb +20 -0
- data/lib/generators/trade_tracker/templates/trade_tracker.yml +10 -0
- data/lib/trade_tracker.rb +11 -0
- data/lib/trade_tracker/click.rb +65 -0
- data/lib/trade_tracker/concerns/click.rb +35 -0
- data/lib/trade_tracker/concerns/conversion.rb +50 -0
- data/lib/trade_tracker/conversion.rb +84 -0
- data/lib/trade_tracker/version.rb +3 -0
- data/spec/click_spec.rb +94 -0
- data/spec/conversion_spec.rb +91 -0
- data/trade_tracker.gemspec +26 -0
- metadata +121 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 36b7d41431da7b4ca8cdae1ca5d19451c1411d16
|
4
|
+
data.tar.gz: 651ead1bd6058f2083e347e509183e997f130198
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cd720bdea851c63d7474c0771c317b28bdfddbf9fe36ce3c0e0894e5f6c0206a074f5ed8c4a2daf50c289fa74c913def53f811cc0bbf4921b507f866504f8709
|
7
|
+
data.tar.gz: 752c9b0ebcfb57f2e19bbb80fb694d28a1aeaf533c606df3a296cd9ab7452ad47e17df39415dda8fd8f1c274773c203c1b6a4b54879ae929e1eb5f937ff22434
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Blimp
|
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,75 @@
|
|
1
|
+
# TradeTracker on Rails
|
2
|
+
|
3
|
+
This gem is for you if you're looking to integrate TradeTracker click/conversion tracking into your Rails app.
|
4
|
+
|
5
|
+
This assumes basic knowledge of the TradeTracker tool.
|
6
|
+
Refer to the official documentation if you have questions on the click/conversion process.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'trade_tracker', github: 'blimp/trade_tracker', branch: :master
|
13
|
+
|
14
|
+
Then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
And finally, generate your configuration file:
|
19
|
+
|
20
|
+
$ rails g trade_tracker:config
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
### 1. Setup two routes
|
25
|
+
```ruby
|
26
|
+
get 'my_click_page' => 'tradetracker#index'
|
27
|
+
get 'my_conversion_page' => 'tradetracker#conversion'
|
28
|
+
```
|
29
|
+
### 2. Create a basic controller (or map to your own)
|
30
|
+
```ruby
|
31
|
+
class TradetrackerController < ApplicationController
|
32
|
+
include TradeTracker::Concerns::Click
|
33
|
+
include TradeTracker::Concerns::Conversion
|
34
|
+
|
35
|
+
def index
|
36
|
+
set_p3p_header # Can comment out at will. It's still in the TT integration specs.
|
37
|
+
set_cookies # Stores the required cookie hash so TT knows we're legit.
|
38
|
+
send_click_to_tradetracker # Redirects to TTs trackback URL, and back to your redirect URL.
|
39
|
+
end
|
40
|
+
|
41
|
+
def conversion
|
42
|
+
send_conversion_to_tradetracker # Redirects to TTs trackback_URL
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
46
|
+
### 3. Add the conversion image tag
|
47
|
+
```ruby
|
48
|
+
# app/controllers/my_fancy_conversion_page_controller.rb:
|
49
|
+
class MyFancyConversionPageController < ApplicationController
|
50
|
+
include TradeTracker::Concerns::Conversion
|
51
|
+
|
52
|
+
def my_fancy_action
|
53
|
+
# Refer to the TradeTracker documentation to see which params are available.
|
54
|
+
set_conversion_image_parameters(
|
55
|
+
conversion_type: 'sales',
|
56
|
+
transaction_id: 1234,
|
57
|
+
price: 1337,
|
58
|
+
merchant_description: "Describe what you sold (IDs/names/...)",
|
59
|
+
email: 'customer@bought.it',
|
60
|
+
)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
```
|
64
|
+
```ruby
|
65
|
+
# app/views/my_fancy_action.html.erb
|
66
|
+
<%= conversion_image_tag %>
|
67
|
+
```
|
68
|
+
|
69
|
+
## Contributing
|
70
|
+
|
71
|
+
1. Fork it ( https://github.com/[my-github-username]/trade_tracker/fork )
|
72
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
73
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
74
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
75
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module TradeTracker
|
4
|
+
class ConfigGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
desc 'generate yaml config for TradeTracker campaign_id and product_id'
|
8
|
+
|
9
|
+
def copy_files
|
10
|
+
say_status '', "Copying configuration file... \n", :blue
|
11
|
+
copy_file 'trade_tracker.yml', 'config/trade_tracker.yml'
|
12
|
+
end
|
13
|
+
|
14
|
+
def print_manual
|
15
|
+
say_status 'OK', 'Done.', :green
|
16
|
+
say "\nRemember to fill in your campaign_id and product_id in config/trade_tracker.yml", :yellow
|
17
|
+
say "Further implementation details can be found at http://github.com/blimp/trade_tracker\n", :yellow
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'active_support/dependencies'
|
2
|
+
require 'active_support/concern'
|
3
|
+
require 'trade_tracker/version'
|
4
|
+
require 'trade_tracker/click'
|
5
|
+
require 'trade_tracker/conversion'
|
6
|
+
require 'trade_tracker/concerns/click.rb'
|
7
|
+
require 'trade_tracker/concerns/conversion.rb'
|
8
|
+
|
9
|
+
module TradeTracker
|
10
|
+
include ActiveSupport::Dependencies
|
11
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module TradeTracker
|
2
|
+
class Click
|
3
|
+
attr_reader :campaign_id, :material_id, :affiliate_id, :reference,
|
4
|
+
:redirect_url
|
5
|
+
|
6
|
+
def initialize(params)
|
7
|
+
if params[:campaignID]
|
8
|
+
self.campaign_id = params[:campaignID]
|
9
|
+
self.material_id = params[:material_id]
|
10
|
+
self.affiliate_id = params[:affiliate_id]
|
11
|
+
self.redirect_url = params[:redirect_url]
|
12
|
+
elsif params[:tt]
|
13
|
+
tracking_data = params[:tt].split('_')
|
14
|
+
|
15
|
+
self.campaign_id = tracking_data[0]
|
16
|
+
self.material_id = tracking_data[1]
|
17
|
+
self.affiliate_id = tracking_data[2]
|
18
|
+
self.reference = tracking_data[3]
|
19
|
+
self.redirect_url = params[:r]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def campaign_id=(value)
|
24
|
+
@campaign_id = value.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def material_id=(value)
|
28
|
+
@material_id = value.to_s
|
29
|
+
end
|
30
|
+
|
31
|
+
def affiliate_id=(value)
|
32
|
+
@affiliate_id = value.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def reference=(value)
|
36
|
+
@reference = CGI.escape value.to_s
|
37
|
+
end
|
38
|
+
|
39
|
+
def redirect_url=(value)
|
40
|
+
@redirect_url = CGI.escape value.to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
def trackback_url
|
44
|
+
if campaign_id.present? || affiliate_id.present?
|
45
|
+
"http://tc.tradetracker.net/?c=#{campaign_id}&m=#{material_id}&a=#{affiliate_id}&r=#{reference}&u=#{redirect_url}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def cookie_name
|
50
|
+
"TT2_#{campaign_id}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def cookie_value
|
54
|
+
"#{material_id}::#{affiliate_id}::#{reference}::#{checksum}::#{Time.now.to_i}"
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def checksum
|
60
|
+
Digest::MD5.hexdigest(
|
61
|
+
"CHK_#{campaign_id}::#{material_id}::#{affiliate_id}::#{reference}"
|
62
|
+
)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module TradeTracker
|
2
|
+
module Concerns
|
3
|
+
module Click
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def send_click_to_tradetracker
|
7
|
+
if tradetracker_click.trackback_url
|
8
|
+
redirect_to tradetracker_click.trackback_url
|
9
|
+
else
|
10
|
+
redirect_to root_path
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def tradetracker_click
|
17
|
+
@click ||= TradeTracker::Click.new params
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_cookies
|
21
|
+
# Apparently we need both a session/regular cookies, both with the same name/value
|
22
|
+
cookies[tradetracker_click.cookie_name] = {
|
23
|
+
value: tradetracker_click.cookie_value,
|
24
|
+
expires: Time.now + 31536000,
|
25
|
+
domain: request.host
|
26
|
+
}
|
27
|
+
session[tradetracker_click.cookie_name] = tradetracker_click.cookie_value
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_p3p_header
|
31
|
+
response.headers['P3P'] = 'CP="ALL PUR DSP CUR ADMi DEVi CONi OUR COR IND"'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module TradeTracker
|
4
|
+
module Concerns
|
5
|
+
module Conversion
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
attr_reader :conversion_image_parameters
|
8
|
+
|
9
|
+
included do
|
10
|
+
helper_method :conversion_image_tag
|
11
|
+
end
|
12
|
+
|
13
|
+
def conversion_image_tag
|
14
|
+
parameters = default_parameters.merge conversion_image_parameters
|
15
|
+
url = tradetracker_conversion_path parameters
|
16
|
+
('<img src="%s" width="1" height="1" border="0" alt="" />' % url).html_safe
|
17
|
+
end
|
18
|
+
|
19
|
+
def send_conversion_to_tradetracker
|
20
|
+
redirect_to tradetracker_conversion.trackback_url
|
21
|
+
end
|
22
|
+
|
23
|
+
def set_conversion_image_parameters(parameters = {})
|
24
|
+
@conversion_image_parameters = parameters
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def default_parameters
|
30
|
+
{
|
31
|
+
use_https: tradetracker_conversion.use_https,
|
32
|
+
campaign_id: tradetracker_conversion.campaign_id,
|
33
|
+
product_id: tradetracker_conversion.product_id,
|
34
|
+
conversion_type: tradetracker_conversion.conversion_type,
|
35
|
+
transaction_id: tradetracker_conversion.transaction_id,
|
36
|
+
transaction_amount: tradetracker_conversion.transaction_amount,
|
37
|
+
email: tradetracker_conversion.email,
|
38
|
+
quantity: tradetracker_conversion.quantity,
|
39
|
+
merchant_description: tradetracker_conversion.merchant_description,
|
40
|
+
affiliate_description: tradetracker_conversion.affiliate_description
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def tradetracker_conversion
|
45
|
+
config = YAML.load_file('config/trade_tracker.yml')[Rails.env].symbolize_keys
|
46
|
+
@conversion ||= TradeTracker::Conversion.new params, config
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module TradeTracker
|
2
|
+
class Conversion
|
3
|
+
PARAMETERS = %w(use_https campaign_id product_id conversion_type tracking_data
|
4
|
+
tracking_type transaction_id transaction_amount quantity
|
5
|
+
email merchant_description affiliate_description)
|
6
|
+
|
7
|
+
def initialize(params, config = nil)
|
8
|
+
PARAMETERS.each do |p|
|
9
|
+
values = config && config.include?(p.to_sym) ? config : params
|
10
|
+
self.send "#{p}=", values[p.to_sym]
|
11
|
+
|
12
|
+
unless self.respond_to?(p)
|
13
|
+
self.class.send(:define_method, p, lambda {
|
14
|
+
instance_variable_get('@' + p)
|
15
|
+
})
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def campaign_id=(value)
|
21
|
+
@campaign_id = value.to_s
|
22
|
+
end
|
23
|
+
|
24
|
+
def product_id=(value)
|
25
|
+
@product_id = value.to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
def conversion_type=(value)
|
29
|
+
@conversion_type = value.to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
def use_https
|
33
|
+
@use_https == 1
|
34
|
+
end
|
35
|
+
|
36
|
+
def use_https=(value)
|
37
|
+
@use_https = value.to_i
|
38
|
+
end
|
39
|
+
|
40
|
+
def tracking_data=(value)
|
41
|
+
@tracking_data = CGI.escape value.to_s
|
42
|
+
end
|
43
|
+
|
44
|
+
def tracking_type=(value)
|
45
|
+
@tracking_type = value.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
def transaction_id=(value)
|
49
|
+
@transaction_id = value.to_s
|
50
|
+
end
|
51
|
+
|
52
|
+
def transaction_amount=(value)
|
53
|
+
@transaction_amount = value.to_f
|
54
|
+
end
|
55
|
+
|
56
|
+
def quantity=(value)
|
57
|
+
@quantity = CGI.escape value.to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
def email=(value)
|
61
|
+
@email = CGI.escape value.to_s
|
62
|
+
end
|
63
|
+
|
64
|
+
def merchant_description=(value)
|
65
|
+
@merchant_description = CGI.escape value.to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
def affiliate_description=(value)
|
69
|
+
@affiliate_description = CGI.escape value.to_s
|
70
|
+
end
|
71
|
+
|
72
|
+
def trackback_url
|
73
|
+
if campaign_id.blank? || product_id.blank?
|
74
|
+
raise 'Wrong or missing parameters'
|
75
|
+
else
|
76
|
+
"#{use_https ? 'https' : 'http'}://#{conversion_type == 'lead' ? 'tl' : 'ts'}.tradetracker.net/?cid=#{campaign_id}&pid=#{product_id}&data=#{tracking_data}&type=#{tracking_type}&tid=#{transaction_id}&tam=#{transaction_amount}&qty=#{quantity}&eml=#{email}&descrMerchant=#{merchant_description}&descrAffiliate=#{affiliate_description}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def cookie_name
|
81
|
+
"TT2_#{campaign_id}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/spec/click_spec.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'trade_tracker'
|
2
|
+
|
3
|
+
describe TradeTracker::Click do
|
4
|
+
let(:instance) do
|
5
|
+
TradeTracker::Click.new(
|
6
|
+
campaignID: '14986',
|
7
|
+
material_id: '0',
|
8
|
+
affiliate_id: '18897',
|
9
|
+
reference: '',
|
10
|
+
r: 'http://www.google.be'
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#campaign_id' do
|
15
|
+
it 'result' do
|
16
|
+
instance.campaign_id = 1234
|
17
|
+
expect(instance.campaign_id).to eq '1234'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'blank' do
|
21
|
+
instance.campaign_id = 0
|
22
|
+
expect(instance.campaign_id).to eq '0'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#affiliate_id' do
|
27
|
+
it 'result' do
|
28
|
+
instance.affiliate_id = 1234
|
29
|
+
expect(instance.affiliate_id).to eq '1234'
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'blank' do
|
33
|
+
instance.affiliate_id = 0
|
34
|
+
expect(instance.affiliate_id).to eq '0'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#material_id' do
|
39
|
+
it 'result' do
|
40
|
+
instance.material_id = 20
|
41
|
+
expect(instance.material_id).to eq '20'
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'blank' do
|
45
|
+
instance.material_id = 0
|
46
|
+
expect(instance.material_id).to eq '0'
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#redirect_url' do
|
51
|
+
it 'filled' do
|
52
|
+
instance.redirect_url = 'http://www.google.be'
|
53
|
+
expect(instance.redirect_url).to eq 'http%3A%2F%2Fwww.google.be'
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'blank' do
|
57
|
+
instance.redirect_url = nil
|
58
|
+
expect(instance.redirect_url).to eq ''
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#reference' do
|
63
|
+
it 'filled' do
|
64
|
+
instance.reference = 'X254'
|
65
|
+
expect(instance.reference).to eq 'X254'
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'blank' do
|
69
|
+
instance.reference = nil
|
70
|
+
expect(instance.reference).to eq ''
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it '#cookie_name' do
|
75
|
+
instance.campaign_id = 'foo'
|
76
|
+
expect(instance.cookie_name).to eq 'TT2_foo'
|
77
|
+
end
|
78
|
+
|
79
|
+
it '#cookie_value' do
|
80
|
+
expect(instance.cookie_value).to include '0::18897::::c83b23df3e4be73b2aa751dbd2fc248e::'
|
81
|
+
end
|
82
|
+
|
83
|
+
it '#trackback_url' do
|
84
|
+
expect(instance.trackback_url).to eq 'http://tc.tradetracker.net/?c=14986&m=0&a=18897&r=&u='
|
85
|
+
end
|
86
|
+
|
87
|
+
it '#respond_to?' do
|
88
|
+
expect(instance).to respond_to(
|
89
|
+
:campaign_id=, :campaign_id, :material_id=, :material_id, :affiliate_id=,
|
90
|
+
:affiliate_id, :reference=, :reference, :redirect_url=, :redirect_url,
|
91
|
+
:cookie_name, :cookie_value, :trackback_url
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'trade_tracker'
|
2
|
+
|
3
|
+
describe TradeTracker::Conversion do
|
4
|
+
let(:instance) do
|
5
|
+
TradeTracker::Conversion.new(
|
6
|
+
campaign_id: '14986',
|
7
|
+
product_id: '22367',
|
8
|
+
conversion_type: 'sales',
|
9
|
+
use_https: '1'
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#campaign_id' do
|
14
|
+
it 'result' do
|
15
|
+
instance.campaign_id = 1234
|
16
|
+
expect(instance.campaign_id).to eq '1234'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'blank' do
|
20
|
+
instance.campaign_id = 0
|
21
|
+
expect(instance.campaign_id).to eq '0'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#product_id' do
|
26
|
+
it 'result' do
|
27
|
+
instance.product_id = 20
|
28
|
+
expect(instance.product_id).to eq '20'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'blank' do
|
32
|
+
instance.product_id = 0
|
33
|
+
expect(instance.product_id).to eq '0'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#conversion_type' do
|
38
|
+
it 'result' do
|
39
|
+
instance.conversion_type = 1234
|
40
|
+
expect(instance.conversion_type).to eq '1234'
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'blank' do
|
44
|
+
instance.conversion_type = 0
|
45
|
+
expect(instance.conversion_type).to eq '0'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '#use_https' do
|
50
|
+
it 'true' do
|
51
|
+
expect(instance.use_https).to be true
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'false' do
|
55
|
+
instance.use_https = '0'
|
56
|
+
expect(instance.use_https).to be false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it '#transaction_amount' do
|
61
|
+
instance.transaction_amount = '1234'
|
62
|
+
expect(instance.transaction_amount).to eq 1234.0
|
63
|
+
end
|
64
|
+
|
65
|
+
describe '#trackback_url' do
|
66
|
+
it 'no campaign ID' do
|
67
|
+
instance.campaign_id = nil
|
68
|
+
expect { instance.trackback_url }.to raise_error('Wrong or missing parameters')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'no product ID' do
|
72
|
+
instance.product_id = nil
|
73
|
+
expect { instance.trackback_url }.to raise_error('Wrong or missing parameters')
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'result' do
|
77
|
+
expect(instance.trackback_url).to eq 'https://ts.tradetracker.net/?cid=14986&pid=22367&data=&type=&tid=&tam=0.0&qty=&eml=&descrMerchant=&descrAffiliate='
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
it '#respond_to?' do
|
82
|
+
expect(instance).to respond_to(
|
83
|
+
:campaign_id=, :campaign_id, :product_id=, :product_id, :conversion_type=,
|
84
|
+
:conversion_type, :use_https=, :use_https, :tracking_data=,
|
85
|
+
:tracking_data, :transaction_id=, :transaction_id, :transaction_amount=,
|
86
|
+
:transaction_amount, :quantity=, :quantity, :email=, :email,
|
87
|
+
:merchant_description=, :merchant_description, :affiliate_description=,
|
88
|
+
:affiliate_description, :trackback_url
|
89
|
+
)
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'trade_tracker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'trade_tracker'
|
8
|
+
spec.version = TradeTracker::VERSION
|
9
|
+
spec.authors = ['Dave Lens']
|
10
|
+
spec.email = ['dave@blimp.be']
|
11
|
+
spec.summary = %q{This Rails gem wants to make the implementation of TradeTracker (click + conversion logging) easier.}
|
12
|
+
spec.description = 'This Rails gem wants to make the implementation of TradeTracker (click + conversion logging) easier. It makes use of a few controller concerns and view helpers to provide conversion logging through an invisible image.'
|
13
|
+
spec.homepage = 'https://github.com/blimp/trade_tracker'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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.6'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.4'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 2.6'
|
24
|
+
|
25
|
+
spec.add_dependency 'activesupport', '~> 4.2'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: trade_tracker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dave Lens
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-24 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.4'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.2'
|
69
|
+
description: This Rails gem wants to make the implementation of TradeTracker (click
|
70
|
+
+ conversion logging) easier. It makes use of a few controller concerns and view
|
71
|
+
helpers to provide conversion logging through an invisible image.
|
72
|
+
email:
|
73
|
+
- dave@blimp.be
|
74
|
+
executables: []
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- lib/generators/trade_tracker/config_generator.rb
|
84
|
+
- lib/generators/trade_tracker/templates/trade_tracker.yml
|
85
|
+
- lib/trade_tracker.rb
|
86
|
+
- lib/trade_tracker/click.rb
|
87
|
+
- lib/trade_tracker/concerns/click.rb
|
88
|
+
- lib/trade_tracker/concerns/conversion.rb
|
89
|
+
- lib/trade_tracker/conversion.rb
|
90
|
+
- lib/trade_tracker/version.rb
|
91
|
+
- spec/click_spec.rb
|
92
|
+
- spec/conversion_spec.rb
|
93
|
+
- trade_tracker.gemspec
|
94
|
+
homepage: https://github.com/blimp/trade_tracker
|
95
|
+
licenses:
|
96
|
+
- MIT
|
97
|
+
metadata: {}
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 2.4.5
|
115
|
+
signing_key:
|
116
|
+
specification_version: 4
|
117
|
+
summary: This Rails gem wants to make the implementation of TradeTracker (click +
|
118
|
+
conversion logging) easier.
|
119
|
+
test_files:
|
120
|
+
- spec/click_spec.rb
|
121
|
+
- spec/conversion_spec.rb
|