referrer_tracker 0.0.2 → 0.1.5
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/Rakefile +1 -1
- data/init.rb +2 -2
- data/lib/app/models/referrer_tracker/referrer_track.rb +5 -0
- data/lib/referrer_tracker.rb +4 -3
- data/lib/referrer_tracker/utils.rb +73 -71
- data/referrer_tracker.gemspec +3 -3
- data/test/old_referrer_tracker.rb +1 -1
- metadata +6 -6
- data/lib/app/models/track.rb +0 -3
data/Rakefile
CHANGED
@@ -30,6 +30,6 @@ Jeweler::Tasks.new do |gem|
|
|
30
30
|
gem.description = %Q{It pulls in the ?ref= and ?sr= type references from urls and marks visitor comings from those urls.}
|
31
31
|
gem.email = "rtdp@weboniselab.com"
|
32
32
|
gem.authors = ["rtdp"]
|
33
|
-
gem.version = "0.
|
33
|
+
gem.version = "0.1.5"
|
34
34
|
end
|
35
35
|
Jeweler::RubygemsDotOrgTasks.new
|
data/init.rb
CHANGED
@@ -4,11 +4,11 @@ require File.join(File.dirname(__FILE__), "lib", "referrer_tracker", "utils")
|
|
4
4
|
|
5
5
|
#
|
6
6
|
#load the configutraions from yml
|
7
|
-
ReferrerTracker::Utils.load_configuration_yaml
|
7
|
+
#ReferrerTracker::Utils.load_configuration_yaml
|
8
8
|
|
9
9
|
#
|
10
10
|
# load models - ReferrerTracker model
|
11
11
|
#
|
12
|
-
path = File.join(File.dirname(__FILE__), 'lib', 'app', "models", "
|
12
|
+
path = File.join(File.dirname(__FILE__), 'lib', 'app', "models", "referrer_tracker", "referrer_track.rb")
|
13
13
|
$LOAD_PATH << path
|
14
14
|
ActiveSupport::Dependencies.load_file(path)
|
data/lib/referrer_tracker.rb
CHANGED
@@ -3,8 +3,11 @@ class ActionController::Base
|
|
3
3
|
before_filter :notice_referrer
|
4
4
|
end
|
5
5
|
|
6
|
+
require 'referrer_tracker/utils'
|
7
|
+
require 'app/models/referrer_tracker/referrer_track'
|
8
|
+
|
6
9
|
module ReferrerTracker
|
7
|
-
include Utils
|
10
|
+
include ReferrerTracker::Utils
|
8
11
|
|
9
12
|
#
|
10
13
|
# This is being called by basic before filter and used to check if conditions from config satisfies..
|
@@ -41,5 +44,3 @@ module ReferrerTracker
|
|
41
44
|
end
|
42
45
|
|
43
46
|
end
|
44
|
-
|
45
|
-
require 'referrer_tracker/utils'
|
@@ -1,102 +1,104 @@
|
|
1
|
-
module ReferrerTracker
|
1
|
+
module ReferrerTracker
|
2
|
+
module Utils
|
2
3
|
|
3
|
-
|
4
|
+
class NotConfigured < Exception; end
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
class << self
|
7
|
+
attr_accessor :conf
|
8
|
+
end
|
8
9
|
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
# to give current pairs order in list of actions
|
12
|
+
def step
|
13
|
+
number = ReferrerTracker::Utils.conf[current_track]["actions"].split.find_index(current_c_a_pair)
|
14
|
+
number.nil? ? 0 : number+1
|
15
|
+
end
|
15
16
|
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
# to get value of current source value specified with referrer_parameter
|
19
|
+
def current_source_value
|
20
|
+
params[get_yml_attributes("referrer_parameter").to_s.to_sym]
|
21
|
+
end
|
21
22
|
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
# to get value of current source key specified with referrer_parameter
|
25
|
+
def current_source_key
|
26
|
+
get_yml_attributes("referrer_parameter").to_s.to_sym
|
27
|
+
end
|
27
28
|
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
# checks value for conversion rate
|
31
|
+
def conversion_rate?
|
32
|
+
get_yml_attributes("conversion_rate").first
|
33
|
+
end
|
33
34
|
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
#
|
37
|
+
# Returns array of controller-action pairs present in .yml conf file.
|
38
|
+
def config_actions
|
39
|
+
get_yml_attributes("actions").map{|i| i.split}.flatten
|
40
|
+
end
|
40
41
|
|
41
42
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
#
|
44
|
+
# get current track here
|
45
|
+
def current_track
|
46
|
+
result = ""
|
47
|
+
ReferrerTracker::Utils.conf.each_pair do |k, v|
|
48
|
+
if v["actions"].split.include?(current_c_a_pair) and !result.present?
|
49
|
+
result = k
|
50
|
+
end
|
49
51
|
end
|
52
|
+
result
|
50
53
|
end
|
51
|
-
result
|
52
|
-
end
|
53
54
|
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
#
|
57
|
+
# Gives current controller action pair
|
58
|
+
def current_c_a_pair
|
59
|
+
[params[:controller], params[:action]].join("#")
|
60
|
+
end
|
60
61
|
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
#
|
64
|
+
# Getter methods over module got get conf,
|
65
|
+
# raises NotConfigured, if nil
|
66
|
+
def self.conf
|
67
|
+
@conf || raise_unconfigured_exception
|
68
|
+
end
|
68
69
|
|
69
70
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
#
|
72
|
+
# NotConfigured exception rising class
|
73
|
+
def self.raise_unconfigured_exception
|
74
|
+
raise NotConfigured.new("No configuration provided for Referrer Tracker.")
|
75
|
+
end
|
75
76
|
|
76
77
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
78
|
+
#
|
79
|
+
# Loads configuration from yml file. called at application start.
|
80
|
+
#
|
81
|
+
def self.load_configuration_yaml
|
82
|
+
config = YAML.load(File.read(File.join(Rails.root,"config","referrer_tracker.yml")))
|
83
|
+
raise NotConfigured.new("Unable to load configuration for #{::Rails.env} from referrer_tracker.yml. Is it set up?") if config.nil?
|
84
|
+
self.conf = config#.with_indifferent_access
|
85
|
+
end
|
85
86
|
|
86
87
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
88
|
+
#
|
89
|
+
# Give Attributes from yml file
|
90
|
+
def get_yml_attributes(action)
|
91
|
+
ReferrerTracker::Utils.conf.values.map{|i| i["#{action}"]}
|
92
|
+
end
|
92
93
|
|
93
94
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
95
|
+
#
|
96
|
+
# This is to check if current referrer key is the one defined in configs.
|
97
|
+
#
|
98
|
+
#
|
99
|
+
def source_match?
|
99
100
|
params[current_source_key.to_sym].present?
|
100
|
-
|
101
|
+
end
|
101
102
|
|
103
|
+
end
|
102
104
|
end
|
data/referrer_tracker.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{referrer_tracker}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["rtdp"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-02}
|
13
13
|
s.description = %q{It pulls in the ?ref= and ?sr= type references from urls and marks visitor comings from those urls.}
|
14
14
|
s.email = %q{rtdp@weboniselab.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
"Rakefile",
|
22
22
|
"init.rb",
|
23
23
|
"install.rb",
|
24
|
-
"lib/app/models/
|
24
|
+
"lib/app/models/referrer_tracker/referrer_track.rb",
|
25
25
|
"lib/db/migrate/20110523140707_create_referrer_track_model.rb",
|
26
26
|
"lib/db/schema.rb",
|
27
27
|
"lib/referrer_tracker.rb",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: referrer_tracker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 1
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- rtdp
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-06-
|
18
|
+
date: 2011-06-02 00:00:00 +05:30
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -33,7 +33,7 @@ files:
|
|
33
33
|
- Rakefile
|
34
34
|
- init.rb
|
35
35
|
- install.rb
|
36
|
-
- lib/app/models/
|
36
|
+
- lib/app/models/referrer_tracker/referrer_track.rb
|
37
37
|
- lib/db/migrate/20110523140707_create_referrer_track_model.rb
|
38
38
|
- lib/db/schema.rb
|
39
39
|
- lib/referrer_tracker.rb
|
data/lib/app/models/track.rb
DELETED