omniture_client 0.0.1
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/README +0 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/lib/omniture_client.rb +42 -0
- data/lib/omniture_client/base.rb +40 -0
- data/lib/omniture_client/printer.rb +30 -0
- data/lib/omniture_client/var.rb +18 -0
- data/lib/omniture_client/var_group.rb +24 -0
- data/lib/rails.rb +31 -0
- data/omniture_client.gemspec +46 -0
- data/omniture_client.rb +7 -0
- metadata +65 -0
data/README
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "omniture_client"
|
5
|
+
gemspec.summary = "A gem for implementing Omniture for web apps that use Rails, Sinatra, etc"
|
6
|
+
gemspec.email = "alex@patch.com"
|
7
|
+
gemspec.homepage = "http://github.com/acatighera/omniture_client"
|
8
|
+
gemspec.authors = ["Alexandru Catighera"]
|
9
|
+
end
|
10
|
+
rescue LoadError
|
11
|
+
puts "Jeweler not available. Install it with: sudo gem install jeweler"
|
12
|
+
end
|
13
|
+
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module OmnitureClient
|
2
|
+
def import_aliases(alias_hash)
|
3
|
+
@alias_hash = alias_hash
|
4
|
+
end
|
5
|
+
|
6
|
+
attr_reader :alias_hash
|
7
|
+
|
8
|
+
module ControllerMethods
|
9
|
+
def self.included(base)
|
10
|
+
base.extend(ClassMethods)
|
11
|
+
end
|
12
|
+
|
13
|
+
module ClassMethods
|
14
|
+
def report_to(reporter)
|
15
|
+
include InstanceMethods
|
16
|
+
@reporter = reporter
|
17
|
+
end
|
18
|
+
|
19
|
+
def reporter
|
20
|
+
@reporter
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module InstanceMethods
|
25
|
+
def reporter
|
26
|
+
if self.class.reporter.is_a?(Class)
|
27
|
+
@reporter ||= reporter
|
28
|
+
elsif self.class.reporter.is_a?(Proc)
|
29
|
+
@reporter ||= reporter.call
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def omniture_js
|
34
|
+
reporter.to_js
|
35
|
+
end
|
36
|
+
|
37
|
+
def omniture_url
|
38
|
+
reporter.to_query
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module OmnitureClient
|
2
|
+
class Base
|
3
|
+
|
4
|
+
include Printer
|
5
|
+
|
6
|
+
attr_reader :controller
|
7
|
+
|
8
|
+
@var_groups = []
|
9
|
+
|
10
|
+
def initialize(controller)
|
11
|
+
@controller = controller
|
12
|
+
end
|
13
|
+
|
14
|
+
def printer
|
15
|
+
@printer ||= Printer.new(self)
|
16
|
+
end
|
17
|
+
|
18
|
+
def vars
|
19
|
+
@vars ||= self.class.var_groups.inject([]) do |vars, grp|
|
20
|
+
vars << grp.values(controller) if grp
|
21
|
+
vars
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_var(name, value)
|
26
|
+
vars << Var.new(name, value)
|
27
|
+
end
|
28
|
+
|
29
|
+
class << self
|
30
|
+
attr_reader :var_groups
|
31
|
+
|
32
|
+
def define_var(name, &block)
|
33
|
+
var_group = instance_eval("@#{name} ||= VarGroup.new(name)")
|
34
|
+
var_group.add_var(block)
|
35
|
+
var_groups << var_group unless var_groups.include?(var_group)
|
36
|
+
var_group
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module OmnitureClient
|
2
|
+
module Printer
|
3
|
+
def to_js
|
4
|
+
var_types.inject("") do |js, var_type|
|
5
|
+
send(var_type).each do |var|
|
6
|
+
js << var_to_js(var)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_query
|
12
|
+
var_types.inject("") do |query, var_type|
|
13
|
+
send(var_type).each do |var|
|
14
|
+
query << var_to_query(var)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def var_to_query(var)
|
22
|
+
send(var).to_query(var) + '&' if send(var)
|
23
|
+
end
|
24
|
+
|
25
|
+
def var_to_js(var)
|
26
|
+
"var #{var} = '#{send(var).gsub()}'; " if send(var)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module OmnitureClient
|
2
|
+
class Var
|
3
|
+
attr_reader :name, :value
|
4
|
+
def initialize(name, value)
|
5
|
+
@name = name
|
6
|
+
if OmnitureClient::alias_hash && OmnitureClient::alias_hash[name]
|
7
|
+
@name = OmnitureClient::alias_hash[name]
|
8
|
+
else
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
@value = value
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_param
|
15
|
+
value.to_param(name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module OmnitureClient
|
2
|
+
class VarGroup
|
3
|
+
attr_reader :name
|
4
|
+
attr_accessor :value_procs
|
5
|
+
|
6
|
+
def initialize(name)
|
7
|
+
@name = name
|
8
|
+
@value_procs = []
|
9
|
+
@composite = composite
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_var(value_proc)
|
13
|
+
value_procs << value_proc
|
14
|
+
end
|
15
|
+
|
16
|
+
def value(scope)
|
17
|
+
Var.new(name, value_procs.map{ |p| scope.instance_eval(p) })
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :composite
|
23
|
+
end
|
24
|
+
end
|
data/lib/rails.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module OmnitureClient
|
2
|
+
module ActionControllerMethods
|
3
|
+
def reports_to_omniture
|
4
|
+
include ControllerMethods
|
5
|
+
|
6
|
+
before_filter do
|
7
|
+
omniture_flash.each do |name, value|
|
8
|
+
reporter.add_var(name, value)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
report_to lambda {
|
13
|
+
begin
|
14
|
+
"#{controller_path.classify}Reporter".constantize.new(self)
|
15
|
+
rescue
|
16
|
+
BasicReporter.new(self)
|
17
|
+
end
|
18
|
+
}
|
19
|
+
|
20
|
+
define_method :omniture_flash do
|
21
|
+
flash[:omniture] ||= {}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if is_defined?(ApplicationController)
|
28
|
+
ApplicationController.extend(ActionControllerMethods)
|
29
|
+
ApplicationController.reports_to_omniture
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{omniture_client}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alexandru Catighera"]
|
12
|
+
s.date = %q{2009-12-02}
|
13
|
+
s.email = %q{alex@patch.com}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"README"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
"README",
|
19
|
+
"Rakefile",
|
20
|
+
"VERSION",
|
21
|
+
"lib/omniture_client.rb",
|
22
|
+
"lib/omniture_client/base.rb",
|
23
|
+
"lib/omniture_client/printer.rb",
|
24
|
+
"lib/omniture_client/var.rb",
|
25
|
+
"lib/omniture_client/var_group.rb",
|
26
|
+
"lib/rails.rb",
|
27
|
+
"omniture_client.gemspec",
|
28
|
+
"omniture_client.rb"
|
29
|
+
]
|
30
|
+
s.homepage = %q{http://github.com/acatighera/omniture_client}
|
31
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
32
|
+
s.require_paths = ["lib"]
|
33
|
+
s.rubygems_version = %q{1.3.5}
|
34
|
+
s.summary = %q{A gem for implementing Omniture for web apps that use Rails, Sinatra, etc}
|
35
|
+
|
36
|
+
if s.respond_to? :specification_version then
|
37
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
38
|
+
s.specification_version = 3
|
39
|
+
|
40
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
41
|
+
else
|
42
|
+
end
|
43
|
+
else
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
data/omniture_client.rb
ADDED
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniture_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexandru Catighera
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-12-02 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: alex@patch.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
|
+
files:
|
25
|
+
- README
|
26
|
+
- Rakefile
|
27
|
+
- VERSION
|
28
|
+
- lib/omniture_client.rb
|
29
|
+
- lib/omniture_client/base.rb
|
30
|
+
- lib/omniture_client/printer.rb
|
31
|
+
- lib/omniture_client/var.rb
|
32
|
+
- lib/omniture_client/var_group.rb
|
33
|
+
- lib/rails.rb
|
34
|
+
- omniture_client.gemspec
|
35
|
+
- omniture_client.rb
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/acatighera/omniture_client
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --charset=UTF-8
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
requirements: []
|
58
|
+
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.3.5
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: A gem for implementing Omniture for web apps that use Rails, Sinatra, etc
|
64
|
+
test_files: []
|
65
|
+
|