omniturize 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +22 -0
- data/README.markdown +139 -0
- data/Rakefile +1 -0
- data/lib/class_level_inheritable_attributes.rb +31 -0
- data/lib/omniturize/base.rb +104 -0
- data/lib/omniturize/meta_js.rb +42 -0
- data/lib/omniturize/meta_var.rb +53 -0
- data/lib/omniturize/printer.rb +62 -0
- data/lib/omniturize/var.rb +22 -0
- data/lib/omniturize/version.rb +3 -0
- data/lib/omniturize.rb +26 -0
- data/lib/omniturize_rails.rb +34 -0
- data/omniturize.gemspec +20 -0
- metadata +80 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2009 Alexandru Catighera
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
# Omniturize
|
2
|
+
This gem integrates Omniture SiteCatalyst into your web app.
|
3
|
+
|
4
|
+
## Installation
|
5
|
+
gem install omniturize
|
6
|
+
|
7
|
+
## Based on and unaware collaborators
|
8
|
+
This is gem is based on [activenetwork's OmnitureClient gem](https://github.com/activenetwork/omniture_client, "activenetwork's OmnitureClient"), which was forked from [acatighera's](https://github.com/acatighera/omniture_client, "acatighera's OmnitureClient").
|
9
|
+
|
10
|
+
There is some borrowed code from unawared coders. So thank you to
|
11
|
+
|
12
|
+
* [acatighera](https://github.com/acatighera, "acatighera github homepage")
|
13
|
+
* [activenetwork](https://github.com/activenetwork, "activenetwork github homepage")
|
14
|
+
* [John Nunemaker](http://railstips.org/about, "railstips") for his [ClassLevelInheritableAttributes solution](http://railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/, "Class and instance variables in ruby")
|
15
|
+
|
16
|
+
## Configuration
|
17
|
+
You must configure the Omniture namespace, suite(s), version that you wish to use.
|
18
|
+
Optionally, you can set up aliases to make things easier for yourself when coding reporters. Omniture uses c1, e1, r, etc to represent custom variables, e_vars, the referrer, etc. These param names are obscure and can be hard to remember so you can set up aliases for them.
|
19
|
+
|
20
|
+
# config/omniture.yml
|
21
|
+
development:
|
22
|
+
base_url: http://102.112.2O7.net
|
23
|
+
ssl_url: https://102.112.2O7.net
|
24
|
+
suite: suite1
|
25
|
+
version: G.4--NS
|
26
|
+
aliases:
|
27
|
+
search_term: c1
|
28
|
+
movie_titles: e1
|
29
|
+
referrer: r
|
30
|
+
|
31
|
+
Then, you should add this line to an initializer:
|
32
|
+
|
33
|
+
Omniturize::config(YAML::load(File.open("#{Rails.root}/config/omniture.yml"))[Rails.env])
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
###Attaching to the controllers
|
37
|
+
You can select which controllers you want to track by adding the next line
|
38
|
+
|
39
|
+
class FooController < ApplicationController
|
40
|
+
omniturize
|
41
|
+
end
|
42
|
+
|
43
|
+
For each controller you want to track, you should create a reporter. The root name of this reporter should be the same name as the controller -or the `BasicController` explained below.
|
44
|
+
|
45
|
+
|
46
|
+
#FooReporter for FooController
|
47
|
+
class FooReporter < Omniturize::Base
|
48
|
+
...
|
49
|
+
end
|
50
|
+
|
51
|
+
If there is a basic behaviour for some of your controllers, you should create a BasicReporter. This reporter will be used in case a reporter with the same name as the controller is not found.
|
52
|
+
|
53
|
+
#BasicReporter
|
54
|
+
class BasicReporter < Omniturize::Base
|
55
|
+
...
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
###vars
|
60
|
+
You can define a var by giving it a name and defining a block
|
61
|
+
|
62
|
+
|
63
|
+
var :my_var do
|
64
|
+
params[:id]
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
You can define a var to be present in or excluded from some actions.
|
69
|
+
|
70
|
+
#This var will be present only in index and new actions
|
71
|
+
var :my_var, :only => [:index, :new] do
|
72
|
+
'value_for_my_var'
|
73
|
+
end
|
74
|
+
|
75
|
+
#this var will be excluded from index, new, create, update and destroy actions
|
76
|
+
|
77
|
+
var :my_var, :except => [:index, :new, :create, :update, :destroy] do
|
78
|
+
params[:id]
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
If no :only or :excluded options are passed, the defined var will be available in every action.
|
83
|
+
|
84
|
+
###Events
|
85
|
+
You can define an event the same way you define a var, except that you don't have to give a name for the event
|
86
|
+
|
87
|
+
event, :only => [:search] do
|
88
|
+
'my_event'
|
89
|
+
end
|
90
|
+
|
91
|
+
###Custom javascript
|
92
|
+
You can define custom javascript code the same way you define an event
|
93
|
+
|
94
|
+
js_snippet, :only => [:search] do
|
95
|
+
's.server = window.location.host;'
|
96
|
+
end
|
97
|
+
|
98
|
+
###Using controller methods in the blocks
|
99
|
+
Since the block you are defining is executed within the controller context, you can use every method defined in your controller.
|
100
|
+
|
101
|
+
##File structure
|
102
|
+
My advice is to create these reporters in the 'app/reporters' directory, by creating this directory and adding it to the autoload_path
|
103
|
+
|
104
|
+
config.autoload_paths += "#{RAILS_ROOT}/app/reporters"
|
105
|
+
|
106
|
+
You can create a hierarchy of reporters. This way you can share some configurations between classes and override them if necessary, e.g: you would want to create an ApplicationReporter which will contain the most common behaviour, and subclass this reporter for adding or modifying new vars, events, or js
|
107
|
+
|
108
|
+
|
109
|
+
class ApplicationReporter < Omniturize::Base
|
110
|
+
var :my_var do
|
111
|
+
'common value'
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class FooReporter < ApplicationReporter
|
116
|
+
var :my_var do
|
117
|
+
'foo'
|
118
|
+
end
|
119
|
+
|
120
|
+
var :foo_var do
|
121
|
+
'foo2'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
## Views
|
127
|
+
Somewhere in your view -probably in one of your layouts- you should add the next line:
|
128
|
+
|
129
|
+
|
130
|
+
@controller.reporter.js(:action => params[:action])
|
131
|
+
|
132
|
+
|
133
|
+
##More info
|
134
|
+
Since this gem has been created for a very specific use, it may be that this documentation is not enough for you. I have tried to keep the most code from the original sources, so you would want to take a look to the code itself or to the original sources where I took the code
|
135
|
+
|
136
|
+
* [OmnitureClient gem](https://github.com/acatighera/omniture_client, "acathigera's OmnitureClient")
|
137
|
+
* [activenetwork's fork](https://github.com/activenetwork/omniture_client, "activenetwork's OmnitureClient")
|
138
|
+
|
139
|
+
##### Copyright (c) 2011 Javier Lafora, released under MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# This code was proudly and shamelessly copied from
|
2
|
+
# http://railstips.org/blog/archives/2006/11/18/class-and-instance-variables-in-ruby/
|
3
|
+
# so let's all thank John Nunemaker with a loud and strong applause: PLAS!!!!'
|
4
|
+
|
5
|
+
module Omniturize
|
6
|
+
module ClassLevelInheritableAttributes
|
7
|
+
def self.included(base)
|
8
|
+
base.extend(ClassMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module ClassMethods
|
12
|
+
def inheritable_attributes(*args)
|
13
|
+
@omniture_inheritable_attributes ||= [:omniture_inheritable_attributes]
|
14
|
+
@omniture_inheritable_attributes += args
|
15
|
+
args.each do |arg|
|
16
|
+
class_eval %(
|
17
|
+
class << self; attr_accessor :#{arg} end
|
18
|
+
)
|
19
|
+
end
|
20
|
+
@omniture_inheritable_attributes
|
21
|
+
end
|
22
|
+
|
23
|
+
def inherited(subclass)
|
24
|
+
@omniture_inheritable_attributes.each do |inheritable_attribute|
|
25
|
+
instance_var = "@#{inheritable_attribute}"
|
26
|
+
subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
module Omniturize
|
2
|
+
class Base
|
3
|
+
|
4
|
+
include Omniturize::ClassLevelInheritableAttributes
|
5
|
+
include Omniturize::Printer
|
6
|
+
inheritable_attributes :meta_vars, :meta_js_events, :meta_js_snippets
|
7
|
+
|
8
|
+
attr_reader :controller
|
9
|
+
|
10
|
+
@meta_vars = []
|
11
|
+
@meta_js_events = []
|
12
|
+
@meta_js_snippets = []
|
13
|
+
|
14
|
+
|
15
|
+
class << self
|
16
|
+
attr_accessor :meta_vars, :meta_js_events, :meta_js_snippets
|
17
|
+
@@controller = nil
|
18
|
+
|
19
|
+
def var(name, options={}, &block)
|
20
|
+
meta_var = Omniturize::MetaVar.new(name.to_s, options)
|
21
|
+
meta_var.add_var(block)
|
22
|
+
meta_vars.insert(0, meta_var) unless meta_vars.include?(meta_var)
|
23
|
+
meta_var
|
24
|
+
end
|
25
|
+
|
26
|
+
def event(options = {}, &block)
|
27
|
+
meta_js(meta_js_events, block, options)
|
28
|
+
end
|
29
|
+
|
30
|
+
def js_snippet(options = {}, &block)
|
31
|
+
meta_js(meta_js_snippets, block, options)
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_meta_vars(name, action = nil)
|
35
|
+
filter_collection_for_action(meta_vars.select{|x|x.matches_name?(name)}, action).uniq_by(:name)
|
36
|
+
end
|
37
|
+
|
38
|
+
def filter_collection_for_action(collection, action)
|
39
|
+
return collection if action.blank?
|
40
|
+
collection.select do |element|
|
41
|
+
(element.only.present? && element.only.include?(action.try(:to_sym))) ||
|
42
|
+
(element.except.present? && !element.except.include?(action.try(:to_sym))) ||
|
43
|
+
(element.only.blank? && element.except.blank?)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
protected
|
48
|
+
|
49
|
+
def meta_js(collection, block, options = {})
|
50
|
+
meta_js = Omniture::MetaJs.new(options)
|
51
|
+
meta_js.add_js(block)
|
52
|
+
collection.insert(0, meta_js)
|
53
|
+
meta_js
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def initialize(controller)
|
59
|
+
@controller = controller
|
60
|
+
end
|
61
|
+
|
62
|
+
def vars(options = {})
|
63
|
+
meta_collection_to_values(self.class.meta_vars, options[:action]).uniq_by(:name)
|
64
|
+
end
|
65
|
+
|
66
|
+
def js_events(options = {})
|
67
|
+
meta_collection_to_values(self.class.meta_js_events, options[:action]).uniq
|
68
|
+
end
|
69
|
+
|
70
|
+
def js_snippets(options = {})
|
71
|
+
meta_collection_to_values(self.class.meta_js_snippets, options[:action]).uniq
|
72
|
+
end
|
73
|
+
|
74
|
+
def add_var(name, value)
|
75
|
+
self.class.var(name) do
|
76
|
+
value
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def find_var(name, options = {})
|
81
|
+
vars(options[:action]).detect{|x|x.matches_name?(name)}
|
82
|
+
end
|
83
|
+
|
84
|
+
def meta_vars_to_vars(meta_vars)
|
85
|
+
meta_vars.inject([]) do |vars, meta_var|
|
86
|
+
vars << meta_var.value(controller) if meta_var
|
87
|
+
vars
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
protected
|
92
|
+
|
93
|
+
def build_js_collection(procs_collection)
|
94
|
+
procs_collection.inject([]) do |code, js|
|
95
|
+
code << controller.instance_eval(&js)
|
96
|
+
code
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def meta_collection_to_values(collection, action = nil)
|
101
|
+
action.present? ? meta_vars_to_vars(self.class.filter_collection_for_action(collection, action)): meta_vars_to_vars(collection)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Omniture
|
2
|
+
class MetaJs
|
3
|
+
attr_reader :cache_key, :expires_in, :only, :except, :delimiter
|
4
|
+
attr_accessor :value_procs
|
5
|
+
|
6
|
+
DEFAULT_OPTIONS = { :unique => nil,
|
7
|
+
:expires_in => 0,
|
8
|
+
:only => [],
|
9
|
+
:except => [],
|
10
|
+
:delimiter => ','
|
11
|
+
}
|
12
|
+
|
13
|
+
def initialize(options = {})
|
14
|
+
options = DEFAULT_OPTIONS.merge(options)
|
15
|
+
|
16
|
+
@value_procs = []
|
17
|
+
@cache_key = "omniture/#{Time.now.to_i}/#{options[:unique]}"
|
18
|
+
@expires_in = options[:expires_in]
|
19
|
+
@only = options[:only]
|
20
|
+
@except = options[:except]
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_js(value_proc)
|
24
|
+
value_procs << value_proc
|
25
|
+
end
|
26
|
+
|
27
|
+
def value(scope)
|
28
|
+
if @expires_in > 0
|
29
|
+
Rails.cache.fetch(@cache_key, :expires_in => @expires_in) do
|
30
|
+
return_var(scope)
|
31
|
+
end
|
32
|
+
else
|
33
|
+
return_var(scope)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def return_var(scope)
|
38
|
+
value_procs.map{ |p| scope.instance_eval(&p) }.flatten.uniq.join(delimiter)
|
39
|
+
#scope.instance_eval(&p)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Omniturize
|
2
|
+
class MetaVar
|
3
|
+
|
4
|
+
DEFAULT_OPTIONS = { :delimiter => ',',
|
5
|
+
:unique => nil,
|
6
|
+
:expires_in => 0,
|
7
|
+
:only => [],
|
8
|
+
:except => []
|
9
|
+
}
|
10
|
+
|
11
|
+
attr_reader :name, :delimiter, :cache_key, :expires_in, :only, :except
|
12
|
+
attr_accessor :value_procs
|
13
|
+
|
14
|
+
def initialize(name, options = {})
|
15
|
+
options = DEFAULT_OPTIONS.merge(options)
|
16
|
+
@name = name
|
17
|
+
@value_procs = []
|
18
|
+
@delimiter = options[:delimiter]
|
19
|
+
@cache_key = "omniture/#{name}/#{options[:unique]}"
|
20
|
+
@expires_in = options[:expires_in]
|
21
|
+
@only = Array(options[:only])
|
22
|
+
@except = Array(options[:except])
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_var(value_proc)
|
26
|
+
value_procs << value_proc
|
27
|
+
end
|
28
|
+
|
29
|
+
# wrap up the value in a Var object and cache if needed
|
30
|
+
def value(scope)
|
31
|
+
if @expires_in > 0
|
32
|
+
Rails.cache.fetch(@cache_key, :expires_in => @expires_in) do
|
33
|
+
return_var(scope)
|
34
|
+
end
|
35
|
+
else
|
36
|
+
return_var(scope)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def return_var(scope)
|
41
|
+
Var.new(name, value_procs.map{ |p| scope.instance_eval(&p) }.flatten.uniq.join(delimiter))
|
42
|
+
end
|
43
|
+
|
44
|
+
def matches_name?(name)
|
45
|
+
select_condition = case name
|
46
|
+
when Regexp then self.name.match(name)
|
47
|
+
when String then self.name == name
|
48
|
+
else raise ArgumentError.new('name must be a String or a Regexp')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Omniturize
|
2
|
+
module Printer
|
3
|
+
|
4
|
+
def url(ssl = false)
|
5
|
+
suite = Omniturize::suite.is_a?(Array) ? Omniturize::suite.join(',') : Omniturize::suite
|
6
|
+
base_url = ssl == :ssl ? Omniturize::ssl_url : Omniturize::base_url
|
7
|
+
"#{base_url}/b/ss/#{suite}/#{Omniturize::version}/#{rand(9999999)}?#{query}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def js(options = {})
|
11
|
+
output = <<-JS
|
12
|
+
<script type="text/javascript" language="JavaScript" src="#{Omniturize::js_src}"></script>
|
13
|
+
<script type="text/javascript" language="JavaScript">
|
14
|
+
#{js_vars(options)}
|
15
|
+
#{print_js_events(options)}
|
16
|
+
#{print_js_snippets(options)}
|
17
|
+
var s_code=s.t();if(s_code)document.write(s_code)
|
18
|
+
</script>
|
19
|
+
JS
|
20
|
+
end
|
21
|
+
|
22
|
+
def query(options = {})
|
23
|
+
vars(options).inject([]) do |query, var|
|
24
|
+
query << var_to_query(var) if var.value && var.value != ""
|
25
|
+
query
|
26
|
+
end.join('&')
|
27
|
+
end
|
28
|
+
|
29
|
+
def js_vars(options = {})
|
30
|
+
vars(options).inject([]) do |query, var|
|
31
|
+
query << var_to_js(var) if var.value && var.value != ""
|
32
|
+
query
|
33
|
+
end.join(";\n") + ';'
|
34
|
+
end
|
35
|
+
|
36
|
+
def raw_vars(options = {})
|
37
|
+
vars(options).inject([]) do |query, var|
|
38
|
+
query << { var.name.to_sym => var.value } if var.value && var.value != ""
|
39
|
+
query
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def print_js_events(options = {})
|
44
|
+
values = js_events(options).join(',')
|
45
|
+
values.blank? ? nil : "s.events = \"#{values}\""
|
46
|
+
end
|
47
|
+
|
48
|
+
def print_js_snippets(options = {})
|
49
|
+
js_snippets(options).join("\n")
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
def var_to_query(var)
|
55
|
+
"#{ CGI::escape(var.name) }=#{ CGI::escape(var.value) }" if var
|
56
|
+
end
|
57
|
+
|
58
|
+
def var_to_js(var)
|
59
|
+
%Q{\t#{Omniturize::var_prefix + '.' if Omniturize::var_prefix}#{var.name}="#{var.value}"} if var
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Omniturize
|
2
|
+
class Var
|
3
|
+
attr_reader :name, :value
|
4
|
+
def initialize(name, value)
|
5
|
+
if Omniturize::aliases && Omniturize::aliases[name.to_s]
|
6
|
+
@name = Omniturize::aliases[name.to_s]
|
7
|
+
else
|
8
|
+
@name = name.to_s
|
9
|
+
end
|
10
|
+
@value = value
|
11
|
+
end
|
12
|
+
|
13
|
+
def matches_name?(name)
|
14
|
+
select_condition = case name
|
15
|
+
when Regexp then self.name.match(name)
|
16
|
+
when String then self.name == name
|
17
|
+
else raise ArgumentError.new('name must be a String or a Regexp')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/omniturize.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "omniturize/version"
|
2
|
+
require File.dirname(__FILE__) + '/class_level_inheritable_attributes'
|
3
|
+
require File.dirname(__FILE__) + '/omniturize/printer'
|
4
|
+
require File.dirname(__FILE__) + '/omniturize/base'
|
5
|
+
require File.dirname(__FILE__) + '/omniturize/var'
|
6
|
+
require File.dirname(__FILE__) + '/omniturize/meta_js'
|
7
|
+
require File.dirname(__FILE__) + '/omniturize/meta_var'
|
8
|
+
require 'cgi'
|
9
|
+
|
10
|
+
module Omniturize
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def config(config_hash)
|
14
|
+
config_hash.each do |key, val|
|
15
|
+
module_eval do
|
16
|
+
mattr_accessor key.to_sym
|
17
|
+
end
|
18
|
+
send("#{key}=", val)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
if defined?(Rails)
|
25
|
+
require File.dirname(__FILE__) + '/omniturize_rails'
|
26
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Omniturize
|
2
|
+
module ActionControllerMethods
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.extend(ClassMethods)
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def omniturize(options = {})
|
10
|
+
include InstanceMethods
|
11
|
+
before_filter :set_reporter, options
|
12
|
+
attr_accessor :reporter
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module InstanceMethods
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def set_reporter(options = {})
|
21
|
+
|
22
|
+
@reporter ||= begin
|
23
|
+
options[:controller].present? ? "#{options[:controller].classify}Reporter".constantize.new(self) :
|
24
|
+
"#{self.controller_name.capitalize}Reporter".constantize.new(self)
|
25
|
+
rescue NameError
|
26
|
+
BasicReporter.new(self)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
ActionController::Base.send(:include, Omniturize::ActionControllerMethods) if defined?(ActionController::Base)
|
data/omniturize.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniturize/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "omniturize"
|
7
|
+
s.version = Omniturize::VERSION
|
8
|
+
s.authors = ["eLafo"]
|
9
|
+
s.email = ["javierlafora@gmail.com"]
|
10
|
+
s.homepage = "https://github.com/eLafo/omniturize"
|
11
|
+
s.summary = %q{This gem integrates Omniture SiteCatalyst into your web app}
|
12
|
+
s.description = %q{This gem integrates Omniture SiteCatalyst into your web app. You can specify vars, events and custom javascript for every action of a controller. This gem is proudly based on the omniture_client gem, from which it takes much code and ideas}
|
13
|
+
|
14
|
+
s.rubyforge_project = "omniturize"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniturize
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- eLafo
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-09-13 00:00:00 Z
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: This gem integrates Omniture SiteCatalyst into your web app. You can specify vars, events and custom javascript for every action of a controller. This gem is proudly based on the omniture_client gem, from which it takes much code and ideas
|
22
|
+
email:
|
23
|
+
- javierlafora@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- MIT-LICENSE
|
34
|
+
- README.markdown
|
35
|
+
- Rakefile
|
36
|
+
- lib/class_level_inheritable_attributes.rb
|
37
|
+
- lib/omniturize.rb
|
38
|
+
- lib/omniturize/base.rb
|
39
|
+
- lib/omniturize/meta_js.rb
|
40
|
+
- lib/omniturize/meta_var.rb
|
41
|
+
- lib/omniturize/printer.rb
|
42
|
+
- lib/omniturize/var.rb
|
43
|
+
- lib/omniturize/version.rb
|
44
|
+
- lib/omniturize_rails.rb
|
45
|
+
- omniturize.gemspec
|
46
|
+
homepage: https://github.com/eLafo/omniturize
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
hash: 3
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
requirements: []
|
73
|
+
|
74
|
+
rubyforge_project: omniturize
|
75
|
+
rubygems_version: 1.8.10
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: This gem integrates Omniture SiteCatalyst into your web app
|
79
|
+
test_files: []
|
80
|
+
|