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 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.0.2"
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", "track.rb")
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)
@@ -0,0 +1,5 @@
1
+ class ReferrerTracker::ReferrerTrack < ActiveRecord::Base
2
+
3
+ set_table_name 'referrer_tracks'
4
+
5
+ end
@@ -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::Utils
1
+ module ReferrerTracker
2
+ module Utils
2
3
 
3
- class NotConfigured < Exception; end
4
+ class NotConfigured < Exception; end
4
5
 
5
- class << self
6
- attr_accessor :conf
7
- end
6
+ class << self
7
+ attr_accessor :conf
8
+ end
8
9
 
9
10
 
10
- # to give current pairs order in list of actions
11
- def step
12
- number = ReferrerTracker::Utils.conf[current_track]["actions"].split.find_index(current_c_a_pair)
13
- number.nil? ? 0 : number+1
14
- end
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
- # to get value of current source value specified with referrer_parameter
18
- def current_source_value
19
- params[get_yml_attributes("referrer_parameter").to_s.to_sym]
20
- end
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
- # to get value of current source key specified with referrer_parameter
24
- def current_source_key
25
- get_yml_attributes("referrer_parameter").to_s.to_sym
26
- end
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
- # checks value for conversion rate
30
- def conversion_rate?
31
- get_yml_attributes("conversion_rate").first
32
- end
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
- # Returns array of controller-action pairs present in .yml conf file.
37
- def config_actions
38
- get_yml_attributes("actions").map{|i| i.split}.flatten
39
- end
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
- # get current track here
44
- def current_track
45
- result = ""
46
- ReferrerTracker::Utils.conf.each_pair do |k, v|
47
- if v["actions"].split.include?(current_c_a_pair) and !result.present?
48
- result = k
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
- # Gives current controller action pair
57
- def current_c_a_pair
58
- [params[:controller], params[:action]].join("#")
59
- end
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
- # Getter methods over module got get conf,
64
- # raises NotConfigured, if nil
65
- def self.conf
66
- @conf || raise_unconfigured_exception
67
- end
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
- # NotConfigured exception rising class
72
- def self.raise_unconfigured_exception
73
- raise NotConfigured.new("No configuration provided for Referrer Tracker.")
74
- end
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
- # Loads configuration from yml file. called at application start.
79
- #
80
- def self.load_configuration_yaml
81
- config = YAML.load(File.read(File.join(Rails.root,"config","referrer_tracker.yml")))
82
- raise NotConfigured.new("Unable to load configuration for #{::Rails.env} from referrer_tracker.yml. Is it set up?") if config.nil?
83
- self.conf = config#.with_indifferent_access
84
- end
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
- # Give Attributes from yml file
89
- def get_yml_attributes(action)
90
- ReferrerTracker::Utils.conf.values.map{|i| i["#{action}"]}
91
- end
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
- # This is to check if current referrer key is the one defined in configs.
96
- #
97
- #
98
- def source_match?
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
- end
101
+ end
101
102
 
103
+ end
102
104
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{referrer_tracker}
8
- s.version = "0.0.2"
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-01}
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/track.rb",
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",
@@ -81,6 +81,6 @@ end
81
81
 
82
82
 
83
83
  #Load the model files.
84
- path = File.join(File.dirname(__FILE__), 'app', "models", "track.rb")
84
+ path = File.join(File.dirname(__FILE__), 'app', "models", "referrer_track.rb")
85
85
  $LOAD_PATH << path
86
86
  ActiveSupport::Dependencies.load_file(path)
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: 27
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
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-01 00:00:00 +05:30
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/track.rb
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
@@ -1,3 +0,0 @@
1
- class ReferrerTrack < ActiveRecord::Base
2
-
3
- end