garails 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -8
  3. data/LICENSE.txt +21 -0
  4. data/README.rdoc +0 -2
  5. data/app/views/garails/_google_analytics.html.erb +13 -18
  6. data/app/views/garails/_no_google_analytics.html.erb +1 -1
  7. data/config.ru +7 -0
  8. data/garails.gemspec +8 -4
  9. data/lib/garails.rb +1 -29
  10. data/lib/garails/engine.rb +0 -6
  11. data/lib/garails/version.rb +1 -1
  12. data/spec/helpers/javascript_helper_spec.rb +26 -0
  13. data/spec/internal/config/database.yml +3 -0
  14. data/spec/internal/config/routes.rb +3 -0
  15. data/spec/internal/db/schema.rb +3 -0
  16. data/spec/internal/log/.gitignore +1 -0
  17. data/{test/test_app → spec/internal}/public/favicon.ico +0 -0
  18. data/spec/spec_helper.rb +14 -0
  19. metadata +71 -66
  20. data/app/controllers/garails/google_analytics_controller.rb +0 -50
  21. data/app/helpers/garails/event_helper.rb +0 -7
  22. data/app/helpers/garails/mobile_helper.rb +0 -18
  23. data/test/controllers/google_analytics_controller_test.rb +0 -36
  24. data/test/test_app/.gitignore +0 -3
  25. data/test/test_app/app/controllers/application_controller.rb +0 -3
  26. data/test/test_app/app/helpers/application_helper.rb +0 -2
  27. data/test/test_app/app/views/layouts/application.html.erb +0 -14
  28. data/test/test_app/config.ru +0 -4
  29. data/test/test_app/config/application.rb +0 -13
  30. data/test/test_app/config/boot.rb +0 -3
  31. data/test/test_app/config/database.yml +0 -22
  32. data/test/test_app/config/environment.rb +0 -5
  33. data/test/test_app/config/environments/test.rb +0 -30
  34. data/test/test_app/config/initializers/backtrace_silencers.rb +0 -7
  35. data/test/test_app/config/initializers/garails.rb +0 -1
  36. data/test/test_app/config/initializers/inflections.rb +0 -10
  37. data/test/test_app/config/initializers/mime_types.rb +0 -5
  38. data/test/test_app/config/initializers/secret_token.rb +0 -7
  39. data/test/test_app/config/initializers/session_store.rb +0 -8
  40. data/test/test_app/config/routes.rb +0 -2
  41. data/test/test_app/db/seeds.rb +0 -7
  42. data/test/test_app/public/404.html +0 -26
  43. data/test/test_app/public/422.html +0 -26
  44. data/test/test_app/public/500.html +0 -26
  45. data/test/test_app/script/rails +0 -6
  46. data/test/test_helper.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c51aa2dd342d67616a01cb89e1742a2293a013d2
4
- data.tar.gz: 5e6eefcb801587e9c2715f0e32c0e59db4478c7f
3
+ metadata.gz: 88fac3792140efd7c5d68306d55db160dce1c92e
4
+ data.tar.gz: d15947f776582fd6ccfb4dd37a92b69bec0f801b
5
5
  SHA512:
6
- metadata.gz: 856c8254aeafe4c5b9a7133f38b414fe3d83e039109850b6888ae71dcfce676c0bdcfc9dcfd76977d68d7638fbbf48e19f081b3c85ff3d588ad192e9e2cab9bc
7
- data.tar.gz: 20e222b52e8c41964e0af1efdcabccbf2092f0419bab893edc4991b016ed997a1f6f5ee03ab64c769775c95c8b7966275796dd4cc1d8a2f3ad1246ad03bdfa21
6
+ metadata.gz: 0957bed72ffef69a71a1576e1bffd111ae057826fb294b75bf28ba812987d1bbc8ffe2e05daf0b140dfcee7634523d2a7c2ec3c55c4cc76b47f7a7892dabb717
7
+ data.tar.gz: 056b070402a68463da29ac5bc2ad8ae8dc3a9d867c5c03a0df644268b7d15e4ddc1e2e7b9404827295e27a1cf87f4ae06056c48d9be6b6eb84c875cc42fd97fe
data/Gemfile CHANGED
@@ -3,11 +3,4 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in garails.gemspec
4
4
  gemspec
5
5
 
6
- gem "rails", "~> 3.2.0"
7
-
8
- group :test do
9
- gem 'shoulda'
10
- gem 'webmock'
11
- gem 'flexmock'
12
- end
13
-
6
+ gem "rails", ">= 4.2.0"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Paul McMahon
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -17,8 +17,6 @@ and run 'bundle install'.
17
17
  Then create a config/initializers/garails.rb with the following content:
18
18
 
19
19
  Garails.ga_account = 'UA-12345678-9'
20
- # Garails.ga_cookie_domain = '.mydomain.com'
21
- # Garails.ga_hostname = 'www.mydomain.com'
22
20
 
23
21
  == Usage
24
22
 
@@ -1,20 +1,15 @@
1
- <script type='text/javascript'>
2
- //<![CDATA[
3
- var _gaq = _gaq || [];
4
- _gaq.push(['_setAccount', '<%= Garails.ga_account %>']);
5
- <% unless Garails.ga_cookie_domain.blank? -%>
6
- _gaq.push(['_setDomainName', '<%= Garails.ga_cookie_domain %>']);
7
- <% end -%>
8
- _gaq.push(['_trackPageview']);
9
- <% if extra_account %>
10
- _gaq.push(['b._setAccount', '<%= extra_account %>']);
11
- _gaq.push(['b._trackPageview']);
12
- <% end %>
1
+ <script>
2
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
3
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
4
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
5
+ })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
6
+
7
+ ga('create', '<%= Garails.ga_account %>', 'auto');
8
+ ga('send', 'pageview');
9
+
10
+ <% if extra_account %>
11
+ ga('create', '<%= extra_account %>', 'auto', 'extraTracker');
12
+ ga('extraTracker.send', 'pageview');
13
+ <% end %>
13
14
 
14
- (function() {
15
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
16
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
17
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
18
- })();
19
- //]]>
20
15
  </script>
@@ -2,6 +2,6 @@
2
2
  //<![CDATA[
3
3
  // no google analytics account setup, doing primtive setup only to avoid
4
4
  // Javascript errors in development.
5
- var _gaq = _gaq || [];
5
+ function ga() {}
6
6
  //]]>
7
7
  </script>
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require :default, :development
5
+
6
+ Combustion.initialize! :all
7
+ run Combustion::Application
@@ -5,10 +5,10 @@ require "garails/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "garails"
7
7
  s.version = Garails::VERSION
8
- s.platform = Gem::Platform::RUBY
8
+ s.platform = Gem::Platform::RUBY
9
9
  s.authors = 'Michael Reinsch', 'Paul McMahon'
10
- s.email = "info@mobalean.com"
11
- s.homepage = "http://github.com/mobalean/garails"
10
+ s.email = "admins@doorkeeper.jp"
11
+ s.homepage = "http://github.com/doorkeeper/garails"
12
12
  s.description = "Google Analytics for Rails"
13
13
  s.summary = "Google Analytics for Rails"
14
14
 
@@ -17,5 +17,9 @@ Gem::Specification.new do |s|
17
17
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_dependency("gabbara", "~> 0.0.5")
20
+ s.add_dependency "rails", ">= 4.0.0"
21
+
22
+ s.add_development_dependency "combustion"
23
+ s.add_development_dependency "rspec-rails"
24
+ s.add_development_dependency "capybara"
21
25
  end
@@ -1,4 +1,4 @@
1
- require 'gabbara'
1
+ require 'rails'
2
2
 
3
3
  module Garails
4
4
 
@@ -6,37 +6,9 @@ module Garails
6
6
  mattr_accessor :ga_account
7
7
  @@ga_account = nil
8
8
 
9
- # cookie domain for the tracking cookie. Only set this if you need to
10
- # (e.g. for subdomain tracking). Corresponds to "_setDomainName".
11
- mattr_accessor :ga_cookie_domain
12
- @@ga_cookie_domain = nil
13
-
14
- # the host name (such as www.example.com). This is usually derived from the
15
- # incoming request. Set it here if you want to enable tracking outside your
16
- # controllers or views.
17
- mattr_accessor :ga_hostname
18
- @@ga_hostname = nil
19
-
20
9
  def self.ga_setup?
21
10
  ! Garails.ga_account.blank?
22
11
  end
23
-
24
- def self.ga_mobile_account
25
- ga_account.sub(/^UA-/, 'MO-')
26
- end
27
-
28
- def self.gabba(request, opts = {})
29
- create_gabba(Garails.ga_account, request, opts)
30
- end
31
-
32
- def self.mobile_gabba(request, opts = {})
33
- create_gabba(Garails.ga_mobile_account, request, opts)
34
- end
35
-
36
- def self.create_gabba(account, request, opts = {})
37
- opts = opts.reverse_merge(:request => request, :logger => Rails.logger)
38
- ::Gabbara::Gabba.new(account, Garails.ga_hostname, opts)
39
- end
40
12
  end
41
13
 
42
14
  require 'garails/version'
@@ -1,11 +1,5 @@
1
1
 
2
2
  module Garails
3
3
  class Engine < ::Rails::Engine
4
- initializer 'garails.view.helper' do |app|
5
- ActionController::Base.helper Garails::MobileHelper, Garails::JavascriptHelper, Garails::EventHelper
6
- end
7
- initializer 'garails.controller.helper' do |app|
8
- ActionController::Base.send :include, Garails::EventHelper
9
- end
10
4
  end
11
5
  end
@@ -1,3 +1,3 @@
1
1
  module Garails
2
- VERSION = '0.3.0'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe Garails::JavascriptHelper, type: :helper do
4
+ after { Garails.ga_account = nil }
5
+
6
+ context "no analytics account setup" do
7
+ subject { google_analytics_tracking_javascript }
8
+ it { should include("no google analytics account setup") }
9
+ end
10
+
11
+ context "has analytics account setup" do
12
+ before { Garails.ga_account = "UA-FOO" }
13
+ subject { google_analytics_tracking_javascript }
14
+ it { should include("ga('create', 'UA-FOO', 'auto')") }
15
+ it { should include("ga('send', 'pageview')") }
16
+ end
17
+
18
+ context "has extra account setup" do
19
+ before { Garails.ga_account = "UA-FOO" }
20
+ subject { google_analytics_tracking_javascript("UA-OTHER") }
21
+ it { should include("ga('create', 'UA-FOO', 'auto')") }
22
+ it { should include("ga('send', 'pageview')") }
23
+ it { should include("ga('create', 'UA-OTHER', 'auto', 'extraTracker')") }
24
+ it { should include("ga('extraTracker.send', 'pageview')") }
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ adapter: sqlite3
3
+ database: db/combustion_test.sqlite
@@ -0,0 +1,3 @@
1
+ Rails.application.routes.draw do
2
+ #
3
+ end
@@ -0,0 +1,3 @@
1
+ ActiveRecord::Schema.define do
2
+ #
3
+ end
@@ -0,0 +1 @@
1
+ *.log
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ require 'combustion'
5
+ require 'capybara/rspec'
6
+
7
+ Combustion.initialize! :action_controller, :action_view
8
+
9
+ require 'rspec/rails'
10
+ require 'capybara/rails'
11
+
12
+ RSpec.configure do |config|
13
+ config.use_transactional_fixtures = true
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: garails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Reinsch
@@ -9,69 +9,92 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-08 00:00:00.000000000 Z
12
+ date: 2016-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: gabbara
15
+ name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 0.0.5
20
+ version: 4.0.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 0.0.5
27
+ version: 4.0.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: combustion
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec-rails
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: capybara
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
28
70
  description: Google Analytics for Rails
29
- email: info@mobalean.com
71
+ email: admins@doorkeeper.jp
30
72
  executables: []
31
73
  extensions: []
32
74
  extra_rdoc_files: []
33
75
  files:
34
- - .gitignore
76
+ - ".gitignore"
35
77
  - Gemfile
78
+ - LICENSE.txt
36
79
  - README.rdoc
37
80
  - Rakefile
38
- - app/controllers/garails/google_analytics_controller.rb
39
- - app/helpers/garails/event_helper.rb
40
81
  - app/helpers/garails/javascript_helper.rb
41
- - app/helpers/garails/mobile_helper.rb
42
82
  - app/views/garails/_google_analytics.html.erb
43
83
  - app/views/garails/_no_google_analytics.html.erb
84
+ - config.ru
44
85
  - config/routes.rb
45
86
  - garails.gemspec
46
87
  - lib/garails.rb
47
88
  - lib/garails/engine.rb
48
89
  - lib/garails/version.rb
49
- - test/controllers/google_analytics_controller_test.rb
50
- - test/test_app/.gitignore
51
- - test/test_app/app/controllers/application_controller.rb
52
- - test/test_app/app/helpers/application_helper.rb
53
- - test/test_app/app/views/layouts/application.html.erb
54
- - test/test_app/config.ru
55
- - test/test_app/config/application.rb
56
- - test/test_app/config/boot.rb
57
- - test/test_app/config/database.yml
58
- - test/test_app/config/environment.rb
59
- - test/test_app/config/environments/test.rb
60
- - test/test_app/config/initializers/backtrace_silencers.rb
61
- - test/test_app/config/initializers/garails.rb
62
- - test/test_app/config/initializers/inflections.rb
63
- - test/test_app/config/initializers/mime_types.rb
64
- - test/test_app/config/initializers/secret_token.rb
65
- - test/test_app/config/initializers/session_store.rb
66
- - test/test_app/config/routes.rb
67
- - test/test_app/db/seeds.rb
68
- - test/test_app/public/404.html
69
- - test/test_app/public/422.html
70
- - test/test_app/public/500.html
71
- - test/test_app/public/favicon.ico
72
- - test/test_app/script/rails
73
- - test/test_helper.rb
74
- homepage: http://github.com/mobalean/garails
90
+ - spec/helpers/javascript_helper_spec.rb
91
+ - spec/internal/config/database.yml
92
+ - spec/internal/config/routes.rb
93
+ - spec/internal/db/schema.rb
94
+ - spec/internal/log/.gitignore
95
+ - spec/internal/public/favicon.ico
96
+ - spec/spec_helper.rb
97
+ homepage: http://github.com/doorkeeper/garails
75
98
  licenses: []
76
99
  metadata: {}
77
100
  post_install_message:
@@ -80,43 +103,25 @@ require_paths:
80
103
  - lib
81
104
  required_ruby_version: !ruby/object:Gem::Requirement
82
105
  requirements:
83
- - - '>='
106
+ - - ">="
84
107
  - !ruby/object:Gem::Version
85
108
  version: '0'
86
109
  required_rubygems_version: !ruby/object:Gem::Requirement
87
110
  requirements:
88
- - - '>='
111
+ - - ">="
89
112
  - !ruby/object:Gem::Version
90
113
  version: '0'
91
114
  requirements: []
92
115
  rubyforge_project:
93
- rubygems_version: 2.1.11
116
+ rubygems_version: 2.2.3
94
117
  signing_key:
95
118
  specification_version: 4
96
119
  summary: Google Analytics for Rails
97
120
  test_files:
98
- - test/controllers/google_analytics_controller_test.rb
99
- - test/test_app/.gitignore
100
- - test/test_app/app/controllers/application_controller.rb
101
- - test/test_app/app/helpers/application_helper.rb
102
- - test/test_app/app/views/layouts/application.html.erb
103
- - test/test_app/config.ru
104
- - test/test_app/config/application.rb
105
- - test/test_app/config/boot.rb
106
- - test/test_app/config/database.yml
107
- - test/test_app/config/environment.rb
108
- - test/test_app/config/environments/test.rb
109
- - test/test_app/config/initializers/backtrace_silencers.rb
110
- - test/test_app/config/initializers/garails.rb
111
- - test/test_app/config/initializers/inflections.rb
112
- - test/test_app/config/initializers/mime_types.rb
113
- - test/test_app/config/initializers/secret_token.rb
114
- - test/test_app/config/initializers/session_store.rb
115
- - test/test_app/config/routes.rb
116
- - test/test_app/db/seeds.rb
117
- - test/test_app/public/404.html
118
- - test/test_app/public/422.html
119
- - test/test_app/public/500.html
120
- - test/test_app/public/favicon.ico
121
- - test/test_app/script/rails
122
- - test/test_helper.rb
121
+ - spec/helpers/javascript_helper_spec.rb
122
+ - spec/internal/config/database.yml
123
+ - spec/internal/config/routes.rb
124
+ - spec/internal/db/schema.rb
125
+ - spec/internal/log/.gitignore
126
+ - spec/internal/public/favicon.ico
127
+ - spec/spec_helper.rb
@@ -1,50 +0,0 @@
1
- require 'gabbara'
2
- require 'digest'
3
-
4
- class Garails::GoogleAnalyticsController < ActionController::Base
5
- unloadable
6
- before_filter :extract_visitor_id
7
-
8
- UTM_HEADERS = {
9
- "Content-Type" => "image/gif",
10
- "Cache-Control" => "private, no-cache, no-cache=Set-Cookie, proxy-revalidate",
11
- "Pragma" => "no-cache",
12
- "Expires" => "Wed, 17 Sep 1975 21:32:10 GMT" }
13
- UTM_GIF_DATA = [
14
- 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, 0x80, 0xff,
15
- 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00,
16
- 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3b ].map{|i| i.chr }.join
17
- UTM_COOKIE_NAME = "__utmmobile"
18
-
19
- def utm
20
- record_access if Garails.ga_setup?
21
- response.headers.merge(UTM_HEADERS)
22
- respond_to do |format|
23
- format.gif { send_data UTM_GIF_DATA, :type => :gif, :disposition => "inline" }
24
- end
25
- end
26
-
27
- private
28
-
29
- def record_access
30
- mobile_gabba.page_view('', :utmvid => @visitor_id)
31
- end
32
-
33
- def mobile_gabba
34
- Garails.mobile_gabba(request, :utmn => params[:utmn], :utmcc => "__utma=999.999.999.999.999.1;", :utmhid => "")
35
- end
36
-
37
- def extract_visitor_id
38
- @visitor_id = cookies[UTM_COOKIE_NAME] || construct_new_visitor_id
39
- cookie_data = {:value => @visitor_id, :expires => Time.now + 2.years, :path => '/'}
40
- cookie_data[:domain] = Garails.ga_cookie_domain unless Garails.ga_cookie_domain.blank?
41
- cookies[UTM_COOKIE_NAME] = cookie_data
42
- end
43
-
44
- def construct_new_visitor_id
45
- raw_visitor_id = request.env["HTTP_X_DCMGUID"].blank? ?
46
- ((request.env["HTTP_USER_AGENT"] || "") + rand(0x7fffffff).to_s) :
47
- (request.env["HTTP_X_DCMGUID"] + (Garails.ga_account || 'unknown'))
48
- "0x" + Digest::MD5.hexdigest(raw_visitor_id)[0, 16]
49
- end
50
- end
@@ -1,7 +0,0 @@
1
- module Garails::EventHelper
2
- def ga_event(category, action, label = nil, value = nil)
3
- return unless Garails.ga_setup?
4
- g = Garails.gabba(request)
5
- g.event(category, action, label, value)
6
- end
7
- end
@@ -1,18 +0,0 @@
1
- module Garails::MobileHelper
2
-
3
- def utm_tag
4
- tag "img", :src => utm_path, :alt => "", :width => "1", :height => "1"
5
- end
6
-
7
- def utm_path
8
- referer = request.env['HTTP_REFERER']
9
- url_for :controller => 'garails/google_analytics',
10
- :action => 'utm',
11
- :format => :gif,
12
- :utmn => rand(0x7fffffff).to_s,
13
- :utmr => referer.blank? ? "-" : referer,
14
- :utmp => request.env['REQUEST_URI'],
15
- :guid => "ON"
16
- end
17
-
18
- end
@@ -1,36 +0,0 @@
1
- require 'test_helper'
2
-
3
- class GoogleAnalyticsControllerTest < ActionController::TestCase
4
- tests Garails::GoogleAnalyticsController
5
-
6
- context "GET to :utm" do
7
- setup do
8
- flexmock(@controller, :rand => 405451725)
9
- stub_analytics("0xd5d59357458cc280")
10
- get :utm, :format => :gif
11
- end
12
- should respond_with :success
13
- should assign_to(:visitor_id)
14
- end
15
-
16
- context "GET to :utm with guid" do
17
- setup do
18
- stub_analytics("0x80620d96c658ed0f")
19
- request.env["HTTP_X_DCMGUID"] = "blah"
20
- get :utm, :format => :gif
21
- end
22
- should respond_with :success
23
- should assign_to(:visitor_id)
24
- end
25
-
26
- def stub_analytics(vid)
27
- query = {
28
- :utmac => "MO-12345678-9", :utmcc => "__utma=999.999.999.999.999.1;", :utmcs => "UTF-8",
29
- :utmhn => "example.org", :utmip => "0.0.0.0", :utmr => "-", :utmul => "en-us",
30
- :utmvid => vid, :utmwv => "4.4sh" }
31
- stub_request(:get, "http://www.google-analytics.com/__utm.gif").
32
- with(:query => query, :headers => {'Accept'=>'*/*', 'User-Agent'=>'Rails%20Testing'}).
33
- to_return(:status => 200, :body => "", :headers => {})
34
- end
35
-
36
- end
@@ -1,3 +0,0 @@
1
- log/*.log
2
- tmp/**/*
3
- *~
@@ -1,3 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>TestApp</title>
5
- <%= stylesheet_link_tag :all %>
6
- <%= javascript_include_tag :defaults %>
7
- <%= csrf_meta_tag %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run TestApp::Application
@@ -1,13 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require "action_controller/railtie"
4
- require "rails/test_unit/railtie"
5
-
6
- Bundler.require :default, :test
7
-
8
- module TestApp
9
- class Application < Rails::Application
10
- config.encoding = "utf-8"
11
- config.filter_parameters += [:password]
12
- end
13
- end
@@ -1,3 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- Bundler.setup
@@ -1,22 +0,0 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3-ruby (not necessary on OS X Leopard)
3
- development:
4
- adapter: sqlite3
5
- database: db/development.sqlite3
6
- pool: 5
7
- timeout: 5000
8
-
9
- # Warning: The database defined as "test" will be erased and
10
- # re-generated from your development database when you run "rake".
11
- # Do not set this db to the same as development or production.
12
- test:
13
- adapter: sqlite3
14
- database: db/test.sqlite3
15
- pool: 5
16
- timeout: 5000
17
-
18
- production:
19
- adapter: sqlite3
20
- database: db/production.sqlite3
21
- pool: 5
22
- timeout: 5000
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- TestApp::Application.initialize!
@@ -1,30 +0,0 @@
1
- TestApp::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
9
-
10
- # Log error messages when you accidentally call methods on nil.
11
- config.whiny_nils = true
12
-
13
- # Show full error reports and disable caching
14
- config.consider_all_requests_local = true
15
- config.action_controller.perform_caching = false
16
-
17
- # Raise exceptions instead of rendering exception templates
18
- config.action_dispatch.show_exceptions = false
19
-
20
- # Disable request forgery protection in test environment
21
- config.action_controller.allow_forgery_protection = false
22
-
23
- # Use SQL instead of Active Record's schema dumper when creating the test database.
24
- # This is necessary if your schema can't be completely dumped by the schema dumper,
25
- # like if you have constraints or database-specific column types
26
- # config.active_record.schema_format = :sql
27
-
28
- # Print deprecation notices to the stderr
29
- config.active_support.deprecation = :stderr
30
- end
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
- # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
-
6
- # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
- # Rails.backtrace_cleaner.remove_silencers!
@@ -1 +0,0 @@
1
- Garails.ga_account = 'UA-12345678-9'
@@ -1,10 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format
4
- # (all these examples are active by default):
5
- # ActiveSupport::Inflector.inflections do |inflect|
6
- # inflect.plural /^(ox)$/i, '\1en'
7
- # inflect.singular /^(ox)en/i, '\1'
8
- # inflect.irregular 'person', 'people'
9
- # inflect.uncountable %w( fish sheep )
10
- # end
@@ -1,5 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
5
- # Mime::Type.register_alias "text/html", :iphone
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- TestApp::Application.config.secret_token = '50053f3c1b13b80ea9ef92a92fe29c47dbe487827d65f9bf20a55b05cbc3d7c5b934a6dddb93b6860867c48ad40f3259fa573e22b362e6605de501ef42f1aced'
@@ -1,8 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- TestApp::Application.config.session_store :cookie_store, :key => '_test_app_session'
4
-
5
- # Use the database for sessions instead of the cookie-based default,
6
- # which shouldn't be used to store highly confidential information
7
- # (create the session table with "rails generate session_migration")
8
- # TestApp::Application.config.session_store :active_record_store
@@ -1,2 +0,0 @@
1
- TestApp::Application.routes.draw do
2
- end
@@ -1,7 +0,0 @@
1
- # This file should contain all the record creation needed to seed the database with its default values.
2
- # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
3
- #
4
- # Examples:
5
- #
6
- # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
7
- # Mayor.create(:name => 'Daley', :city => cities.first)
@@ -1,26 +0,0 @@
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>
@@ -1,26 +0,0 @@
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>
@@ -1,26 +0,0 @@
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
- <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,6 +0,0 @@
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'
@@ -1,8 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- $:.unshift File.dirname(__FILE__)
3
-
4
- require 'test_app/config/environment'
5
- require 'rails/test_help'
6
- require 'webmock/test_unit'
7
- require 'flexmock/test_unit'
8
-