rack-track 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -7
- data/README.markdown +5 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/rack/track.rb +1 -0
- data/rack-track.gemspec +12 -13
- data/test/test_rack-track.rb +21 -12
- metadata +48 -21
- data/Gemfile.lock +0 -23
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -4,11 +4,13 @@ On too many projects I've worked on, nobody actually know every tracking pixel w
|
|
4
4
|
becomes a massive headache when you need to do work around them. This is where Rack::Track comes in to play, providing a DSL to define tracking pixels
|
5
5
|
and the areas they should appear on. It's all in one place, instead of across layouts and pages and it's self documenting.
|
6
6
|
|
7
|
+
The only option on pixel is :on, where you identify an area of the site to appear on. Other options are ignored, making it useful to track owners, departments etc who 'own' the pixel.
|
8
|
+
|
7
9
|
```ruby
|
8
10
|
MyApp::Application.config.middleware.use(Rack::Track) do
|
9
11
|
area :confirmation_pages, "/checkout/order_confirmation", "/basket/complete"
|
10
12
|
|
11
|
-
pixel "Generic GA", :on => :all_pages do
|
13
|
+
pixel "Generic GA", :on => :all_pages, :owner => "Anna Lyst" do
|
12
14
|
%Q{
|
13
15
|
<!-- GOOGLE ANALYTICS -->
|
14
16
|
blah
|
@@ -16,7 +18,7 @@ MyApp::Application.config.middleware.use(Rack::Track) do
|
|
16
18
|
}
|
17
19
|
end
|
18
20
|
|
19
|
-
pixel "Goal GA", :on => :confirmation_pages do
|
21
|
+
pixel "Goal GA", :on => :confirmation_pages, :owner => "Anna Lyst" do
|
20
22
|
%Q{
|
21
23
|
<!-- GOOGLE ANALYTICS -->
|
22
24
|
blah
|
@@ -25,6 +27,7 @@ MyApp::Application.config.middleware.use(Rack::Track) do
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
```
|
30
|
+
|
28
31
|
These tracking pixels will be inserted in to the page before the body tag closes. This is what most tracking pixels expect. If you require a pixel
|
29
32
|
to be placed in the head tag, or anywhere else, let me know and I'll extend it (or you could clone and submit a pull request with your changes!)
|
30
33
|
|
data/Rakefile
CHANGED
@@ -15,7 +15,7 @@ require 'jeweler'
|
|
15
15
|
Jeweler::Tasks.new do |gem|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
17
|
gem.name = "rack-track"
|
18
|
-
gem.version = "0.1.
|
18
|
+
gem.version = "0.1.2"
|
19
19
|
gem.homepage = "http://github.com/michaelbaldry/rack-track"
|
20
20
|
gem.license = "MIT"
|
21
21
|
gem.summary = %Q{Taking all the pain away from managing Tracking Pixels}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/rack/track.rb
CHANGED
@@ -13,6 +13,7 @@ module Rack
|
|
13
13
|
response_body = ""
|
14
14
|
response.each { |p| response_body += p }
|
15
15
|
response = [@rules.apply(request, response_body)] if response_body.include? "</body>"
|
16
|
+
headers["Content-Length"] = response.inject{|sum,x| sum + x }
|
16
17
|
end
|
17
18
|
|
18
19
|
[status, headers, response]
|
data/rack-track.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rack-track}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{2011-08-
|
11
|
+
s.authors = ["Michael Baldry"]
|
12
|
+
s.date = %q{2011-08-24}
|
13
13
|
s.description = %q{A rack middleware that allows you to define and document tracking pixels in one location}
|
14
14
|
s.email = %q{clockwize@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
21
|
"Gemfile",
|
22
|
-
"Gemfile.lock",
|
23
22
|
"LICENSE.txt",
|
24
23
|
"README.markdown",
|
25
24
|
"Rakefile",
|
@@ -31,30 +30,30 @@ Gem::Specification.new do |s|
|
|
31
30
|
"test/test_rack-track.rb"
|
32
31
|
]
|
33
32
|
s.homepage = %q{http://github.com/michaelbaldry/rack-track}
|
34
|
-
s.licenses = [
|
35
|
-
s.require_paths = [
|
36
|
-
s.rubygems_version = %q{1.
|
33
|
+
s.licenses = ["MIT"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = %q{1.6.2}
|
37
36
|
s.summary = %q{Taking all the pain away from managing Tracking Pixels}
|
38
37
|
|
39
38
|
if s.respond_to? :specification_version then
|
40
39
|
s.specification_version = 3
|
41
40
|
|
42
41
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
43
|
-
s.add_runtime_dependency(%q<rack>, [">= 0"])
|
44
|
-
s.add_development_dependency(%q<bundler>, ["~> 1.0
|
42
|
+
s.add_runtime_dependency(%q<rack-track>, [">= 0"])
|
43
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
45
44
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
46
45
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
47
46
|
s.add_development_dependency(%q<rack-test>, [">= 0"])
|
48
47
|
else
|
49
|
-
s.add_dependency(%q<rack>, [">= 0"])
|
50
|
-
s.add_dependency(%q<bundler>, ["~> 1.0
|
48
|
+
s.add_dependency(%q<rack-track>, [">= 0"])
|
49
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
51
50
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
52
51
|
s.add_dependency(%q<rcov>, [">= 0"])
|
53
52
|
s.add_dependency(%q<rack-test>, [">= 0"])
|
54
53
|
end
|
55
54
|
else
|
56
|
-
s.add_dependency(%q<rack>, [">= 0"])
|
57
|
-
s.add_dependency(%q<bundler>, ["~> 1.0
|
55
|
+
s.add_dependency(%q<rack-track>, [">= 0"])
|
56
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
58
57
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
59
58
|
s.add_dependency(%q<rcov>, [">= 0"])
|
60
59
|
s.add_dependency(%q<rack-test>, [">= 0"])
|
data/test/test_rack-track.rb
CHANGED
@@ -9,9 +9,9 @@ class TestRackTrack < Test::Unit::TestCase
|
|
9
9
|
@app_class = SimpleApp
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
SAMPLE_RULE = Proc.new do
|
13
13
|
pixel "Test pixel", :on => :all do
|
14
|
-
"
|
14
|
+
"THIS-IS-A-TEST"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -39,11 +39,7 @@ class TestRackTrack < Test::Unit::TestCase
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_psudo_area_all
|
42
|
-
@rules =
|
43
|
-
pixel "Test pixel", :on => :all do
|
44
|
-
"THIS-IS-A-TEST"
|
45
|
-
end
|
46
|
-
end
|
42
|
+
@rules = SAMPLE_RULE
|
47
43
|
get '/'
|
48
44
|
assert last_response.body.include? "THIS-IS-A-TEST</body>"
|
49
45
|
get '/poatoes'
|
@@ -73,10 +69,10 @@ class TestRackTrack < Test::Unit::TestCase
|
|
73
69
|
end
|
74
70
|
end
|
75
71
|
|
76
|
-
@rules =
|
72
|
+
@rules = SAMPLE_RULE
|
77
73
|
|
78
74
|
get '/'
|
79
|
-
assert last_response.body != "<html><head><title></title></head><body>hello this is the
|
75
|
+
assert last_response.body != "<html><head><title></title></head><body>hello this is the bodyTHIS-IS-A-TEST</body></html>"
|
80
76
|
end
|
81
77
|
|
82
78
|
def test_only_works_on_html_pages_with_charset
|
@@ -86,10 +82,10 @@ class TestRackTrack < Test::Unit::TestCase
|
|
86
82
|
end
|
87
83
|
end
|
88
84
|
|
89
|
-
@rules =
|
85
|
+
@rules = SAMPLE_RULE
|
90
86
|
|
91
87
|
get '/'
|
92
|
-
assert last_response.body == "<html><head><title></title></head><body>hello this is the
|
88
|
+
assert last_response.body == "<html><head><title></title></head><body>hello this is the bodyTHIS-IS-A-TEST</body></html>"
|
93
89
|
end
|
94
90
|
|
95
91
|
def test_only_works_on_pages_with_closing_body
|
@@ -99,9 +95,22 @@ class TestRackTrack < Test::Unit::TestCase
|
|
99
95
|
end
|
100
96
|
end
|
101
97
|
|
102
|
-
@rules =
|
98
|
+
@rules = SAMPLE_RULE
|
103
99
|
|
104
100
|
get '/'
|
105
101
|
assert last_response.body == "<html><head><title></title></head><body>hello this is the body</html>"
|
106
102
|
end
|
103
|
+
|
104
|
+
def test_fixes_content_length_header
|
105
|
+
@app_class = Class.new do
|
106
|
+
def call(env)
|
107
|
+
[200, {'Content-Type' => "text/html; charset=utf-8"}, ["<html><head><title></title></head><body>hello this is the body</body></html>"]]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
@rules = SAMPLE_RULE
|
112
|
+
|
113
|
+
get '/'
|
114
|
+
assert_equal "<html><head><title></title></head><body>hello this is the bodyTHIS-IS-A-TEST</body></html>".length, last_response.headers["Content-Length"].to_i
|
115
|
+
end
|
107
116
|
end
|
metadata
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-track
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 31
|
4
5
|
prerelease:
|
5
|
-
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
6
11
|
platform: ruby
|
7
12
|
authors:
|
8
13
|
- Michael Baldry
|
@@ -10,62 +15,81 @@ autorequire:
|
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
17
|
|
13
|
-
date: 2011-08-
|
18
|
+
date: 2011-08-24 00:00:00 +01:00
|
19
|
+
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
type: :runtime
|
17
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
18
25
|
none: false
|
19
26
|
requirements:
|
20
27
|
- - ">="
|
21
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
22
32
|
version: "0"
|
23
|
-
|
24
|
-
prerelease: false
|
33
|
+
name: rack-track
|
25
34
|
version_requirements: *id001
|
26
35
|
- !ruby/object:Gem::Dependency
|
27
|
-
|
36
|
+
prerelease: false
|
37
|
+
type: :development
|
28
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
29
39
|
none: false
|
30
40
|
requirements:
|
31
41
|
- - ~>
|
32
42
|
- !ruby/object:Gem::Version
|
33
|
-
|
34
|
-
|
35
|
-
|
43
|
+
hash: 15
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 0
|
47
|
+
version: "1.0"
|
48
|
+
name: bundler
|
36
49
|
version_requirements: *id002
|
37
50
|
- !ruby/object:Gem::Dependency
|
38
|
-
|
51
|
+
prerelease: false
|
52
|
+
type: :development
|
39
53
|
requirement: &id003 !ruby/object:Gem::Requirement
|
40
54
|
none: false
|
41
55
|
requirements:
|
42
56
|
- - ~>
|
43
57
|
- !ruby/object:Gem::Version
|
58
|
+
hash: 7
|
59
|
+
segments:
|
60
|
+
- 1
|
61
|
+
- 6
|
62
|
+
- 4
|
44
63
|
version: 1.6.4
|
45
|
-
|
46
|
-
prerelease: false
|
64
|
+
name: jeweler
|
47
65
|
version_requirements: *id003
|
48
66
|
- !ruby/object:Gem::Dependency
|
49
|
-
|
67
|
+
prerelease: false
|
68
|
+
type: :development
|
50
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
51
70
|
none: false
|
52
71
|
requirements:
|
53
72
|
- - ">="
|
54
73
|
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
55
77
|
version: "0"
|
56
|
-
|
57
|
-
prerelease: false
|
78
|
+
name: rcov
|
58
79
|
version_requirements: *id004
|
59
80
|
- !ruby/object:Gem::Dependency
|
60
|
-
|
81
|
+
prerelease: false
|
82
|
+
type: :development
|
61
83
|
requirement: &id005 !ruby/object:Gem::Requirement
|
62
84
|
none: false
|
63
85
|
requirements:
|
64
86
|
- - ">="
|
65
87
|
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
66
91
|
version: "0"
|
67
|
-
|
68
|
-
prerelease: false
|
92
|
+
name: rack-test
|
69
93
|
version_requirements: *id005
|
70
94
|
description: A rack middleware that allows you to define and document tracking pixels in one location
|
71
95
|
email: clockwize@gmail.com
|
@@ -79,7 +103,6 @@ extra_rdoc_files:
|
|
79
103
|
files:
|
80
104
|
- .document
|
81
105
|
- Gemfile
|
82
|
-
- Gemfile.lock
|
83
106
|
- LICENSE.txt
|
84
107
|
- README.markdown
|
85
108
|
- Rakefile
|
@@ -89,6 +112,7 @@ files:
|
|
89
112
|
- rack-track.gemspec
|
90
113
|
- test/helper.rb
|
91
114
|
- test/test_rack-track.rb
|
115
|
+
has_rdoc: true
|
92
116
|
homepage: http://github.com/michaelbaldry/rack-track
|
93
117
|
licenses:
|
94
118
|
- MIT
|
@@ -102,7 +126,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
126
|
requirements:
|
103
127
|
- - ">="
|
104
128
|
- !ruby/object:Gem::Version
|
105
|
-
hash:
|
129
|
+
hash: 3
|
106
130
|
segments:
|
107
131
|
- 0
|
108
132
|
version: "0"
|
@@ -111,11 +135,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
135
|
requirements:
|
112
136
|
- - ">="
|
113
137
|
- !ruby/object:Gem::Version
|
138
|
+
hash: 3
|
139
|
+
segments:
|
140
|
+
- 0
|
114
141
|
version: "0"
|
115
142
|
requirements: []
|
116
143
|
|
117
144
|
rubyforge_project:
|
118
|
-
rubygems_version: 1.
|
145
|
+
rubygems_version: 1.6.2
|
119
146
|
signing_key:
|
120
147
|
specification_version: 3
|
121
148
|
summary: Taking all the pain away from managing Tracking Pixels
|
data/Gemfile.lock
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
git (1.2.5)
|
5
|
-
jeweler (1.6.4)
|
6
|
-
bundler (~> 1.0)
|
7
|
-
git (>= 1.2.5)
|
8
|
-
rake
|
9
|
-
rack (1.3.2)
|
10
|
-
rack-test (0.5.7)
|
11
|
-
rack (>= 1.0)
|
12
|
-
rake (0.9.2)
|
13
|
-
rcov (0.9.9)
|
14
|
-
|
15
|
-
PLATFORMS
|
16
|
-
ruby
|
17
|
-
|
18
|
-
DEPENDENCIES
|
19
|
-
bundler (~> 1.0.0)
|
20
|
-
jeweler (~> 1.6.4)
|
21
|
-
rack
|
22
|
-
rack-test
|
23
|
-
rcov
|