analytics-rails 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +13 -7
  4. data/Rakefile +1 -14
  5. data/lib/analytics/rails.rb +2 -1
  6. data/lib/analytics/rails/extensions/action_view/base.rb +38 -0
  7. data/lib/analytics/rails/railtie.rb +4 -2
  8. data/lib/analytics/rails/version.rb +1 -1
  9. data/test/dummy/Rakefile +1 -2
  10. data/test/dummy/app/assets/javascripts/application.js +2 -2
  11. data/test/dummy/app/assets/stylesheets/application.css +6 -4
  12. data/test/dummy/app/views/layouts/application.html.erb +9 -12
  13. data/test/dummy/bin/bundle +1 -0
  14. data/test/dummy/bin/rails +2 -1
  15. data/test/dummy/bin/rake +1 -0
  16. data/test/dummy/bin/setup +30 -0
  17. data/test/dummy/config.ru +1 -1
  18. data/test/dummy/config/application.rb +6 -2
  19. data/test/dummy/config/boot.rb +1 -1
  20. data/test/dummy/config/environment.rb +1 -1
  21. data/test/dummy/config/environments/development.rb +14 -5
  22. data/test/dummy/config/environments/production.rb +18 -26
  23. data/test/dummy/config/environments/test.rb +10 -12
  24. data/test/dummy/config/initializers/assets.rb +11 -0
  25. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  26. data/test/dummy/config/initializers/mime_types.rb +1 -2
  27. data/test/dummy/config/initializers/session_store.rb +1 -1
  28. data/test/dummy/config/routes.rb +2 -2
  29. data/test/dummy/config/secrets.yml +22 -0
  30. data/test/dummy/log/test.log +108 -0
  31. data/test/dummy/public/404.html +58 -55
  32. data/test/dummy/public/422.html +58 -55
  33. data/test/dummy/public/500.html +57 -54
  34. data/test/tag_test.rb +47 -0
  35. data/test/test_helper.rb +5 -14
  36. metadata +21 -46
  37. data/lib/analytics/rails/action_view/base.rb +0 -43
  38. data/test/dummy/README.rdoc +0 -28
  39. data/test/dummy/config/database.yml +0 -25
  40. data/test/dummy/config/initializers/secret_token.rb +0 -13
  41. data/test/dummy/db/schema.rb +0 -16
  42. data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  43. data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  44. data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  45. data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  46. data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  47. data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  48. data/test/include_tag_test.rb +0 -28
@@ -1,57 +1,60 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/500.html -->
52
- <div class="dialog">
53
- <h1>We're sorry, but something went wrong.</h1>
54
- </div>
55
- <p>If you are the application owner check the logs for more information.</p>
56
- </body>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+ div.dialog {
15
+ width: 95%;
16
+ max-width: 33em;
17
+ margin: 4em auto 0;
18
+ }
19
+ div.dialog > div {
20
+ border: 1px solid #CCC;
21
+ border-right-color: #999;
22
+ border-left-color: #999;
23
+ border-bottom-color: #BBB;
24
+ border-top: #B00100 solid 4px;
25
+ border-top-left-radius: 9px;
26
+ border-top-right-radius: 9px;
27
+ background-color: white;
28
+ padding: 7px 12% 0;
29
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
30
+ }
31
+ h1 {
32
+ font-size: 100%;
33
+ color: #730E15;
34
+ line-height: 1.5em;
35
+ }
36
+ div.dialog > p {
37
+ margin: 0 0 1em;
38
+ padding: 1em;
39
+ background-color: #F7F7F7;
40
+ border: 1px solid #CCC;
41
+ border-right-color: #999;
42
+ border-left-color: #999;
43
+ border-bottom-color: #999;
44
+ border-bottom-left-radius: 4px;
45
+ border-bottom-right-radius: 4px;
46
+ border-top-color: #DADADA;
47
+ color: #666;
48
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
49
+ }
50
+ </style>
51
+ </head>
52
+ <body>
53
+ <div class="dialog">
54
+ <div>
55
+ <h1>We're sorry, but something went wrong.</h1>
56
+ </div>
57
+ <p>If you are the application owner check the logs for more information.</p>
58
+ </div>
59
+ </body>
57
60
  </html>
@@ -0,0 +1,47 @@
1
+ require 'test_helper'
2
+
3
+ class TagTest < ActionView::TestCase
4
+
5
+ test 'include' do
6
+ with_env 'production' do
7
+ tag = google_analytics_include_tag('id')
8
+ assert_includes tag, 'ga("create", "id", "auto");'
9
+ assert_includes tag, 'ga("send", "pageview", {});'
10
+
11
+ tag = google_analytics_include_tag('id', other: 'value')
12
+ assert_includes tag, 'ga("create", "id", "auto");'
13
+ assert_includes tag, 'ga("send", "pageview", {"other":"value"});'
14
+ end
15
+
16
+ with_env 'development' do
17
+ assert_not google_analytics_include_tag
18
+ end
19
+ end
20
+
21
+ test 'event' do
22
+ with_env 'production' do
23
+ assert_includes(
24
+ google_analytics_event_tag('Popup', 'click'),
25
+ 'ga("send", "event", "Popup", "click", {});'
26
+ )
27
+ assert_includes(
28
+ google_analytics_event_tag('Video', 'play', 'ad.mp4', 10, other: 'value'),
29
+ 'ga("send", "event", "Video", "play", "ad.mp4", 10, {"other":"value"});'
30
+ )
31
+ end
32
+
33
+ with_env 'development' do
34
+ assert_not google_analytics_event_tag
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def with_env(value)
41
+ old_env = Rails.env
42
+ Rails.env = value
43
+ yield
44
+ Rails.env = old_env
45
+ end
46
+
47
+ end
@@ -1,24 +1,15 @@
1
1
  # Configure Rails Environment
2
2
  ENV['RAILS_ENV'] = 'test'
3
3
 
4
- require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
+ require File.expand_path('../../test/dummy/config/environment.rb', __FILE__)
5
5
  require 'rails/test_help'
6
6
 
7
- Rails.backtrace_cleaner.remove_silencers!
7
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
8
+ # to be shown.
9
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
8
10
 
9
11
  # Load support files
10
12
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
13
 
12
- # Load fixtures from the engine
13
- if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
- ActiveSupport::TestCase.fixture_path = File.expand_path('../fixtures', __FILE__)
15
- end
16
-
17
- # Load database
18
- config = YAML::load(File.read(File.expand_path('../dummy/config/database.yml', __FILE__)))
19
- config['test']['adapter'] = 'jdbcsqlite3' if RUBY_PLATFORM == 'java'
20
- ActiveRecord::Base.establish_connection(config['test'])
21
- load(File.expand_path('../dummy/db/schema.rb', __FILE__))
22
-
23
14
  # Include helpers
24
- ActionView::TestCase.send :include, Analytics::Rails::ActionView::Base
15
+ ActionView::TestCase.include Analytics::Rails::Extensions::ActionView::Base
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analytics-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmontossi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-15 00:00:00.000000000 Z
11
+ date: 2016-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0
19
+ version: 4.2.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: 4.3.0
@@ -26,28 +26,13 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: 4.0.0
29
+ version: 4.2.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: 4.3.0
33
- - !ruby/object:Gem::Dependency
34
- name: sqlite3
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - "~>"
38
- - !ruby/object:Gem::Version
39
- version: '1.3'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '1.3'
47
- description: Adds a simple view helper to create the google analytics include tag
48
- in rails.
33
+ description: Adds a helper to create the google analytics script in rails.
49
34
  email:
50
- - mmontossi@buyin.io
35
+ - mmontossi@gmail.com
51
36
  executables: []
52
37
  extensions: []
53
38
  extra_rdoc_files: []
@@ -57,10 +42,9 @@ files:
57
42
  - Rakefile
58
43
  - lib/analytics-rails.rb
59
44
  - lib/analytics/rails.rb
60
- - lib/analytics/rails/action_view/base.rb
45
+ - lib/analytics/rails/extensions/action_view/base.rb
61
46
  - lib/analytics/rails/railtie.rb
62
47
  - lib/analytics/rails/version.rb
63
- - test/dummy/README.rdoc
64
48
  - test/dummy/Rakefile
65
49
  - test/dummy/app/assets/javascripts/application.js
66
50
  - test/dummy/app/assets/stylesheets/application.css
@@ -70,35 +54,31 @@ files:
70
54
  - test/dummy/bin/bundle
71
55
  - test/dummy/bin/rails
72
56
  - test/dummy/bin/rake
57
+ - test/dummy/bin/setup
73
58
  - test/dummy/config.ru
74
59
  - test/dummy/config/application.rb
75
60
  - test/dummy/config/boot.rb
76
- - test/dummy/config/database.yml
77
61
  - test/dummy/config/environment.rb
78
62
  - test/dummy/config/environments/development.rb
79
63
  - test/dummy/config/environments/production.rb
80
64
  - test/dummy/config/environments/test.rb
65
+ - test/dummy/config/initializers/assets.rb
81
66
  - test/dummy/config/initializers/backtrace_silencers.rb
67
+ - test/dummy/config/initializers/cookies_serializer.rb
82
68
  - test/dummy/config/initializers/filter_parameter_logging.rb
83
69
  - test/dummy/config/initializers/inflections.rb
84
70
  - test/dummy/config/initializers/mime_types.rb
85
- - test/dummy/config/initializers/secret_token.rb
86
71
  - test/dummy/config/initializers/session_store.rb
87
72
  - test/dummy/config/initializers/wrap_parameters.rb
88
73
  - test/dummy/config/locales/en.yml
89
74
  - test/dummy/config/routes.rb
90
- - test/dummy/db/schema.rb
75
+ - test/dummy/config/secrets.yml
76
+ - test/dummy/log/test.log
91
77
  - test/dummy/public/404.html
92
78
  - test/dummy/public/422.html
93
79
  - test/dummy/public/500.html
94
80
  - test/dummy/public/favicon.ico
95
- - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
96
- - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
97
- - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
98
- - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
99
- - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
100
- - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
101
- - test/include_tag_test.rb
81
+ - test/tag_test.rb
102
82
  - test/test_helper.rb
103
83
  homepage: https://github.com/mmontossi/analytics-rails
104
84
  licenses:
@@ -112,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
112
92
  requirements:
113
93
  - - ">="
114
94
  - !ruby/object:Gem::Version
115
- version: 1.9.3
95
+ version: 2.1.0
116
96
  required_rubygems_version: !ruby/object:Gem::Requirement
117
97
  requirements:
118
98
  - - ">="
@@ -120,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
100
  version: '0'
121
101
  requirements: []
122
102
  rubyforge_project:
123
- rubygems_version: 2.4.5
103
+ rubygems_version: 2.5.1
124
104
  signing_key:
125
105
  specification_version: 4
126
106
  summary: Google analytics for rails.
@@ -133,35 +113,30 @@ test_files:
133
113
  - test/dummy/bin/bundle
134
114
  - test/dummy/bin/rails
135
115
  - test/dummy/bin/rake
116
+ - test/dummy/bin/setup
136
117
  - test/dummy/config/application.rb
137
118
  - test/dummy/config/boot.rb
138
- - test/dummy/config/database.yml
139
119
  - test/dummy/config/environment.rb
140
120
  - test/dummy/config/environments/development.rb
141
121
  - test/dummy/config/environments/production.rb
142
122
  - test/dummy/config/environments/test.rb
123
+ - test/dummy/config/initializers/assets.rb
143
124
  - test/dummy/config/initializers/backtrace_silencers.rb
125
+ - test/dummy/config/initializers/cookies_serializer.rb
144
126
  - test/dummy/config/initializers/filter_parameter_logging.rb
145
127
  - test/dummy/config/initializers/inflections.rb
146
128
  - test/dummy/config/initializers/mime_types.rb
147
- - test/dummy/config/initializers/secret_token.rb
148
129
  - test/dummy/config/initializers/session_store.rb
149
130
  - test/dummy/config/initializers/wrap_parameters.rb
150
131
  - test/dummy/config/locales/en.yml
151
132
  - test/dummy/config/routes.rb
133
+ - test/dummy/config/secrets.yml
152
134
  - test/dummy/config.ru
153
- - test/dummy/db/schema.rb
135
+ - test/dummy/log/test.log
154
136
  - test/dummy/public/404.html
155
137
  - test/dummy/public/422.html
156
138
  - test/dummy/public/500.html
157
139
  - test/dummy/public/favicon.ico
158
140
  - test/dummy/Rakefile
159
- - test/dummy/README.rdoc
160
- - test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705
161
- - test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af
162
- - test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953
163
- - test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
164
- - test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
165
- - test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
166
- - test/include_tag_test.rb
141
+ - test/tag_test.rb
167
142
  - test/test_helper.rb
@@ -1,43 +0,0 @@
1
- module Analytics
2
- module Rails
3
- module ActionView
4
- module Base
5
-
6
- def google_analytics_include_tag(*args)
7
- options = args.extract_options!
8
- if ::Rails.env.production?
9
- [:variables, :events].each do |name|
10
- if options.has_key? name
11
- options[name].map! do |values|
12
- values.map(&:inspect).join(', ').gsub('"',"'")
13
- end
14
- else
15
- options[name] = []
16
- end
17
- end
18
- variables = options[:variables].map do |values|
19
- "_gaq.push(['_setCustomVar', #{values}]);"
20
- end
21
- events = options[:events].map do |values|
22
- "ga('send', 'event', #{values});"
23
- end
24
- script = <<-SCRIPT
25
- var _gaq = _gaq || [];
26
- _gaq.push(['_setAccount', '#{args.first}']);
27
- #{variables.join("\n")}
28
- _gaq.push(['_trackPageview']);
29
- (function(){
30
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
31
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
32
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
33
- })();
34
- #{events.join("\n")}
35
- SCRIPT
36
- content_tag :script, script.html_safe, type: 'text/javascript'
37
- end
38
- end
39
-
40
- end
41
- end
42
- end
43
- end
@@ -1,28 +0,0 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.
@@ -1,25 +0,0 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- development:
7
- adapter: sqlite3
8
- database: db/development.sqlite3
9
- pool: 5
10
- timeout: 5000
11
-
12
- # Warning: The database defined as "test" will be erased and
13
- # re-generated from your development database when you run "rake".
14
- # Do not set this db to the same as development or production.
15
- test:
16
- adapter: sqlite3
17
- database: ":memory:"
18
- pool: 5
19
- timeout: 5000
20
-
21
- production:
22
- adapter: sqlite3
23
- database: db/production.sqlite3
24
- pool: 5
25
- timeout: 5000