ganalytics-rails 0.3
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/MIT-LICENSE +20 -0
- data/README.md +67 -0
- data/Rakefile +38 -0
- data/lib/ganalytics.rb +66 -0
- data/lib/ganalytics/action_controller_methods.rb +15 -0
- data/lib/ganalytics/codes.rb +25 -0
- data/lib/ganalytics/version.rb +3 -0
- data/lib/tasks/ganalytics_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/page_controller.rb +22 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/page/html_page.html.erb +2 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +56 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +10 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +58 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +3489 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/test_ganalytics.rb +70 -0
- data/test/test_helper.rb +19 -0
- metadata +148 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/404.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/422.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
24
|
+
</div>
|
|
25
|
+
</body>
|
|
26
|
+
</html>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
|
7
|
+
div.dialog {
|
|
8
|
+
width: 25em;
|
|
9
|
+
padding: 0 4em;
|
|
10
|
+
margin: 4em auto 0 auto;
|
|
11
|
+
border: 1px solid #ccc;
|
|
12
|
+
border-right-color: #999;
|
|
13
|
+
border-bottom-color: #999;
|
|
14
|
+
}
|
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
|
16
|
+
</style>
|
|
17
|
+
</head>
|
|
18
|
+
|
|
19
|
+
<body>
|
|
20
|
+
<!-- This file lives in public/500.html -->
|
|
21
|
+
<div class="dialog">
|
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
23
|
+
</div>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
3
|
+
|
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
|
6
|
+
require 'rails/commands'
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
class TestGanalytics < ActionController::TestCase
|
|
4
|
+
|
|
5
|
+
def setup
|
|
6
|
+
@controller = PageController.new
|
|
7
|
+
Ganalytics.reset
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "Ganalytics#reset always return empty Array" do
|
|
11
|
+
assert_equal([], Ganalytics.reset)
|
|
12
|
+
Ganalytics.queue << [:foo,:bar]
|
|
13
|
+
assert_equal([], Ganalytics.reset)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
test "Ganalytics#queue returns array of GA tracking queue" do
|
|
17
|
+
assert_equal([], Ganalytics.queue)
|
|
18
|
+
Ganalytics.push :foo, 1
|
|
19
|
+
Ganalytics.push :bar, "123"
|
|
20
|
+
assert_equal([[:foo, 1],[:bar, "123"]], Ganalytics.queue)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test "Ganalytics#set_account is a shortcut for pushing data to Ganalytics#queue" do
|
|
24
|
+
account_id = "AU-123-11"
|
|
25
|
+
Ganalytics.set_account account_id
|
|
26
|
+
queue = Ganalytics.queue.clone
|
|
27
|
+
Ganalytics.reset
|
|
28
|
+
Ganalytics.push "_setAccount", account_id
|
|
29
|
+
assert_equal(queue, Ganalytics.queue)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test "Ganalytics#track_pageview is a shortcut for pushing data to Ganalytics#queue" do
|
|
33
|
+
Ganalytics.track_pageview
|
|
34
|
+
queue = Ganalytics.queue.clone
|
|
35
|
+
Ganalytics.reset
|
|
36
|
+
Ganalytics.push "_trackPageview"
|
|
37
|
+
assert_equal(queue, Ganalytics.queue)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
test "Put Google Analytics tracking code code before the closing </head> tag" do
|
|
41
|
+
get :html_page
|
|
42
|
+
assert_match(Ganalytics::Codes.tracking_code(Ganalytics.queue)+'</head>', @response.body)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
test "Put Google Analytics tracking code to site without </head> tag does nothing" do
|
|
46
|
+
get :json_page
|
|
47
|
+
assert_equal @response.body, assigns(:json_response_text)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
test "Put Google Analytics tracking code to site without text response" do
|
|
51
|
+
get :nothing_page
|
|
52
|
+
assert_equal @response.body, " "
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
test "When GA code putted add also support for _gaq =[] async JS defining values" do
|
|
56
|
+
get :html_page
|
|
57
|
+
assert_match "var _gaq = _gaq || [];", @response.body
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
test "gaq.push added for page with ga_push helper usage" do
|
|
61
|
+
Ganalytics.set_account "UA-XXX-X"
|
|
62
|
+
Ganalytics.track_pageview
|
|
63
|
+
get :html_page_with_ga
|
|
64
|
+
assert_match /_gaq\.push\(.*\)/, @response.body
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
test "Ganalytics has queue method which returns Array" do
|
|
68
|
+
assert_kind_of Array, Ganalytics.queue
|
|
69
|
+
end
|
|
70
|
+
end
|
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Configure Rails Environment
|
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
|
3
|
+
|
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
|
5
|
+
require "rails/test_help"
|
|
6
|
+
|
|
7
|
+
# color output from test/unit 2.X.X
|
|
8
|
+
require 'test/unit/ui/console/testrunner'
|
|
9
|
+
|
|
10
|
+
class Test::Unit::UI::Console::TestRunner
|
|
11
|
+
def guess_color_availability
|
|
12
|
+
true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Rails.backtrace_cleaner.remove_silencers!
|
|
17
|
+
|
|
18
|
+
# Load support files
|
|
19
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
metadata
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ganalytics-rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: '0.3'
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Rafal 'RaVbaker' Piekarski
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2012-03-06 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: rails
|
|
16
|
+
requirement: &2151800900 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ~>
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: 3.2.1
|
|
22
|
+
type: :runtime
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *2151800900
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: sqlite3
|
|
27
|
+
requirement: &2151800240 !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
29
|
+
requirements:
|
|
30
|
+
- - ! '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: *2151800240
|
|
36
|
+
description: ! 'See more on github: https://github.com/RaVbaker/GAnalytics-rails'
|
|
37
|
+
email:
|
|
38
|
+
- ravbaker@gmail.com
|
|
39
|
+
executables: []
|
|
40
|
+
extensions: []
|
|
41
|
+
extra_rdoc_files: []
|
|
42
|
+
files:
|
|
43
|
+
- lib/ganalytics/action_controller_methods.rb
|
|
44
|
+
- lib/ganalytics/codes.rb
|
|
45
|
+
- lib/ganalytics/version.rb
|
|
46
|
+
- lib/ganalytics.rb
|
|
47
|
+
- lib/tasks/ganalytics_tasks.rake
|
|
48
|
+
- MIT-LICENSE
|
|
49
|
+
- Rakefile
|
|
50
|
+
- README.md
|
|
51
|
+
- test/dummy/app/assets/javascripts/application.js
|
|
52
|
+
- test/dummy/app/assets/stylesheets/application.css
|
|
53
|
+
- test/dummy/app/controllers/application_controller.rb
|
|
54
|
+
- test/dummy/app/controllers/page_controller.rb
|
|
55
|
+
- test/dummy/app/helpers/application_helper.rb
|
|
56
|
+
- test/dummy/app/views/layouts/application.html.erb
|
|
57
|
+
- test/dummy/app/views/page/html_page.html.erb
|
|
58
|
+
- test/dummy/config/application.rb
|
|
59
|
+
- test/dummy/config/boot.rb
|
|
60
|
+
- test/dummy/config/database.yml
|
|
61
|
+
- test/dummy/config/environment.rb
|
|
62
|
+
- test/dummy/config/environments/development.rb
|
|
63
|
+
- test/dummy/config/environments/production.rb
|
|
64
|
+
- test/dummy/config/environments/test.rb
|
|
65
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
|
66
|
+
- test/dummy/config/initializers/inflections.rb
|
|
67
|
+
- test/dummy/config/initializers/mime_types.rb
|
|
68
|
+
- test/dummy/config/initializers/secret_token.rb
|
|
69
|
+
- test/dummy/config/initializers/session_store.rb
|
|
70
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
|
71
|
+
- test/dummy/config/locales/en.yml
|
|
72
|
+
- test/dummy/config/routes.rb
|
|
73
|
+
- test/dummy/config.ru
|
|
74
|
+
- test/dummy/db/development.sqlite3
|
|
75
|
+
- test/dummy/db/test.sqlite3
|
|
76
|
+
- test/dummy/log/development.log
|
|
77
|
+
- test/dummy/log/test.log
|
|
78
|
+
- test/dummy/public/404.html
|
|
79
|
+
- test/dummy/public/422.html
|
|
80
|
+
- test/dummy/public/500.html
|
|
81
|
+
- test/dummy/public/favicon.ico
|
|
82
|
+
- test/dummy/Rakefile
|
|
83
|
+
- test/dummy/README.rdoc
|
|
84
|
+
- test/dummy/script/rails
|
|
85
|
+
- test/test_ganalytics.rb
|
|
86
|
+
- test/test_helper.rb
|
|
87
|
+
homepage: https://github.com/RaVbaker/GAnalytics-rails
|
|
88
|
+
licenses: []
|
|
89
|
+
post_install_message:
|
|
90
|
+
rdoc_options: []
|
|
91
|
+
require_paths:
|
|
92
|
+
- lib
|
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
94
|
+
none: false
|
|
95
|
+
requirements:
|
|
96
|
+
- - ! '>='
|
|
97
|
+
- !ruby/object:Gem::Version
|
|
98
|
+
version: '0'
|
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
|
+
none: false
|
|
101
|
+
requirements:
|
|
102
|
+
- - ! '>='
|
|
103
|
+
- !ruby/object:Gem::Version
|
|
104
|
+
version: '0'
|
|
105
|
+
requirements: []
|
|
106
|
+
rubyforge_project:
|
|
107
|
+
rubygems_version: 1.8.17
|
|
108
|
+
signing_key:
|
|
109
|
+
specification_version: 3
|
|
110
|
+
summary: This project is created to simplify usage of Google Analytics tracking functionalities
|
|
111
|
+
in your Rails apps.
|
|
112
|
+
test_files:
|
|
113
|
+
- test/dummy/app/assets/javascripts/application.js
|
|
114
|
+
- test/dummy/app/assets/stylesheets/application.css
|
|
115
|
+
- test/dummy/app/controllers/application_controller.rb
|
|
116
|
+
- test/dummy/app/controllers/page_controller.rb
|
|
117
|
+
- test/dummy/app/helpers/application_helper.rb
|
|
118
|
+
- test/dummy/app/views/layouts/application.html.erb
|
|
119
|
+
- test/dummy/app/views/page/html_page.html.erb
|
|
120
|
+
- test/dummy/config/application.rb
|
|
121
|
+
- test/dummy/config/boot.rb
|
|
122
|
+
- test/dummy/config/database.yml
|
|
123
|
+
- test/dummy/config/environment.rb
|
|
124
|
+
- test/dummy/config/environments/development.rb
|
|
125
|
+
- test/dummy/config/environments/production.rb
|
|
126
|
+
- test/dummy/config/environments/test.rb
|
|
127
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
|
128
|
+
- test/dummy/config/initializers/inflections.rb
|
|
129
|
+
- test/dummy/config/initializers/mime_types.rb
|
|
130
|
+
- test/dummy/config/initializers/secret_token.rb
|
|
131
|
+
- test/dummy/config/initializers/session_store.rb
|
|
132
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
|
133
|
+
- test/dummy/config/locales/en.yml
|
|
134
|
+
- test/dummy/config/routes.rb
|
|
135
|
+
- test/dummy/config.ru
|
|
136
|
+
- test/dummy/db/development.sqlite3
|
|
137
|
+
- test/dummy/db/test.sqlite3
|
|
138
|
+
- test/dummy/log/development.log
|
|
139
|
+
- test/dummy/log/test.log
|
|
140
|
+
- test/dummy/public/404.html
|
|
141
|
+
- test/dummy/public/422.html
|
|
142
|
+
- test/dummy/public/500.html
|
|
143
|
+
- test/dummy/public/favicon.ico
|
|
144
|
+
- test/dummy/Rakefile
|
|
145
|
+
- test/dummy/README.rdoc
|
|
146
|
+
- test/dummy/script/rails
|
|
147
|
+
- test/test_ganalytics.rb
|
|
148
|
+
- test/test_helper.rb
|