analytical 3.0.8 → 3.0.9

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.
Files changed (82) hide show
  1. data/lib/analytical/api.rb +2 -2
  2. metadata +6 -86
  3. data/.document +0 -5
  4. data/.rspec +0 -2
  5. data/.rvmrc +0 -8
  6. data/Gemfile +0 -18
  7. data/Gemfile.lock +0 -118
  8. data/Guardfile +0 -8
  9. data/Rakefile +0 -34
  10. data/VERSION +0 -1
  11. data/analytical.gemspec +0 -187
  12. data/example/.gitignore +0 -4
  13. data/example/Gemfile +0 -27
  14. data/example/Gemfile.lock +0 -80
  15. data/example/README +0 -244
  16. data/example/Rakefile +0 -10
  17. data/example/app/controllers/application_controller.rb +0 -6
  18. data/example/app/controllers/page_controller.rb +0 -18
  19. data/example/app/helpers/application_helper.rb +0 -2
  20. data/example/app/helpers/page_helper.rb +0 -2
  21. data/example/app/views/layouts/application.html.erb +0 -17
  22. data/example/app/views/page/index.html.erb +0 -6
  23. data/example/app/views/page/test_a.html.erb +0 -11
  24. data/example/app/views/page/test_b.html.erb +0 -7
  25. data/example/config.ru +0 -4
  26. data/example/config/analytical.yml +0 -30
  27. data/example/config/application.rb +0 -46
  28. data/example/config/boot.rb +0 -6
  29. data/example/config/database.yml +0 -22
  30. data/example/config/environment.rb +0 -7
  31. data/example/config/environments/development.rb +0 -21
  32. data/example/config/environments/production.rb +0 -42
  33. data/example/config/environments/test.rb +0 -32
  34. data/example/config/initializers/backtrace_silencers.rb +0 -7
  35. data/example/config/initializers/inflections.rb +0 -10
  36. data/example/config/initializers/mime_types.rb +0 -5
  37. data/example/config/initializers/secret_token.rb +0 -7
  38. data/example/config/initializers/session_store.rb +0 -8
  39. data/example/config/locales/en.yml +0 -5
  40. data/example/config/routes.rb +0 -63
  41. data/example/db/seeds.rb +0 -7
  42. data/example/doc/README_FOR_APP +0 -2
  43. data/example/lib/tasks/.gitkeep +0 -0
  44. data/example/public/404.html +0 -26
  45. data/example/public/422.html +0 -26
  46. data/example/public/500.html +0 -26
  47. data/example/public/favicon.ico +0 -0
  48. data/example/public/images/rails.png +0 -0
  49. data/example/public/javascripts/application.js +0 -2
  50. data/example/public/javascripts/controls.js +0 -965
  51. data/example/public/javascripts/dragdrop.js +0 -974
  52. data/example/public/javascripts/effects.js +0 -1123
  53. data/example/public/javascripts/prototype.js +0 -4874
  54. data/example/public/javascripts/rails.js +0 -118
  55. data/example/public/robots.txt +0 -5
  56. data/example/public/stylesheets/.gitkeep +0 -0
  57. data/example/script/rails +0 -9
  58. data/example/test/functional/page_controller_test.rb +0 -19
  59. data/example/test/performance/browsing_test.rb +0 -9
  60. data/example/test/test_helper.rb +0 -13
  61. data/example/test/unit/helpers/page_helper_test.rb +0 -4
  62. data/example/vendor/plugins/.gitkeep +0 -0
  63. data/spec/analytical/api_spec.rb +0 -167
  64. data/spec/analytical/bot_detector_spec.rb +0 -24
  65. data/spec/analytical/command_store_spec.rb +0 -36
  66. data/spec/analytical/modules/adroll_spec.rb +0 -27
  67. data/spec/analytical/modules/adwords_spec.rb +0 -76
  68. data/spec/analytical/modules/base_spec.rb +0 -138
  69. data/spec/analytical/modules/chartbeat_spec.rb +0 -26
  70. data/spec/analytical/modules/clicky_spec.rb +0 -44
  71. data/spec/analytical/modules/comscore_spec.rb +0 -27
  72. data/spec/analytical/modules/google_spec.rb +0 -54
  73. data/spec/analytical/modules/kiss_metrics_spec.rb +0 -51
  74. data/spec/analytical/modules/mixpanel_spec.rb +0 -49
  75. data/spec/analytical/modules/optimizely_spec.rb +0 -26
  76. data/spec/analytical/modules/quantcast.rb +0 -26
  77. data/spec/analytical/modules/reinvigorate_spec.rb +0 -35
  78. data/spec/analytical/session_command_store_spec.rb +0 -50
  79. data/spec/analytical_spec.rb +0 -118
  80. data/spec/config/analytical.yml +0 -19
  81. data/spec/spec.opts +0 -5
  82. data/spec/spec_helper.rb +0 -22
@@ -1,118 +0,0 @@
1
- document.observe("dom:loaded", function() {
2
- function handleRemote(element) {
3
- var method, url, params;
4
-
5
- if (element.tagName.toLowerCase() === 'form') {
6
- method = element.readAttribute('method') || 'post';
7
- url = element.readAttribute('action');
8
- params = element.serialize(true);
9
- } else {
10
- method = element.readAttribute('data-method') || 'get';
11
- url = element.readAttribute('href');
12
- params = {};
13
- }
14
-
15
- var event = element.fire("ajax:before");
16
- if (event.stopped) return false;
17
-
18
- new Ajax.Request(url, {
19
- method: method,
20
- parameters: params,
21
- asynchronous: true,
22
- evalScripts: true,
23
-
24
- onLoading: function(request) { element.fire("ajax:loading", {request: request}); },
25
- onLoaded: function(request) { element.fire("ajax:loaded", {request: request}); },
26
- onInteractive: function(request) { element.fire("ajax:interactive", {request: request}); },
27
- onComplete: function(request) { element.fire("ajax:complete", {request: request}); },
28
- onSuccess: function(request) { element.fire("ajax:success", {request: request}); },
29
- onFailure: function(request) { element.fire("ajax:failure", {request: request}); }
30
- });
31
-
32
- element.fire("ajax:after");
33
- }
34
-
35
- function handleMethod(element) {
36
- var method, url, token_name, token;
37
-
38
- method = element.readAttribute('data-method');
39
- url = element.readAttribute('href');
40
- csrf_param = $$('meta[name=csrf-param]').first();
41
- csrf_token = $$('meta[name=csrf-token]').first();
42
-
43
- var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
44
- element.parentNode.appendChild(form);
45
-
46
- if (method != 'post') {
47
- var field = new Element('input', { type: 'hidden', name: '_method', value: method });
48
- form.appendChild(field);
49
- }
50
-
51
- if (csrf_param) {
52
- var param = csrf_param.readAttribute('content');
53
- var token = csrf_token.readAttribute('content');
54
- var field = new Element('input', { type: 'hidden', name: param, value: token });
55
- form.appendChild(field);
56
- }
57
-
58
- form.submit();
59
- }
60
-
61
- $(document.body).observe("click", function(event) {
62
- var message = event.findElement().readAttribute('data-confirm');
63
- if (message && !confirm(message)) {
64
- event.stop();
65
- return false;
66
- }
67
-
68
- var element = event.findElement("a[data-remote]");
69
- if (element) {
70
- handleRemote(element);
71
- event.stop();
72
- return true;
73
- }
74
-
75
- var element = event.findElement("a[data-method]");
76
- if (element) {
77
- handleMethod(element);
78
- event.stop();
79
- return true;
80
- }
81
- });
82
-
83
- // TODO: I don't think submit bubbles in IE
84
- $(document.body).observe("submit", function(event) {
85
- var element = event.findElement(),
86
- message = element.readAttribute('data-confirm');
87
- if (message && !confirm(message)) {
88
- event.stop();
89
- return false;
90
- }
91
-
92
- var inputs = element.select("input[type=submit][data-disable-with]");
93
- inputs.each(function(input) {
94
- input.disabled = true;
95
- input.writeAttribute('data-original-value', input.value);
96
- input.value = input.readAttribute('data-disable-with');
97
- });
98
-
99
- var element = event.findElement("form[data-remote]");
100
- if (element) {
101
- handleRemote(element);
102
- event.stop();
103
- }
104
- });
105
-
106
- $(document.body).observe("ajax:after", function(event) {
107
- var element = event.findElement();
108
-
109
- if (element.tagName.toLowerCase() === 'form') {
110
- var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
111
- inputs.each(function(input) {
112
- input.value = input.readAttribute('data-original-value');
113
- input.writeAttribute('data-original-value', null);
114
- input.disabled = false;
115
- });
116
- }
117
- });
118
- });
@@ -1,5 +0,0 @@
1
- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
- #
3
- # To ban all spiders from the entire site uncomment the next two lines:
4
- # User-Agent: *
5
- # Disallow: /
File without changes
@@ -1,9 +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
- ENV_PATH = File.expand_path('../../config/environment', __FILE__)
5
- BOOT_PATH = File.expand_path('../../config/boot', __FILE__)
6
- APP_PATH = File.expand_path('../../config/application', __FILE__)
7
-
8
- require BOOT_PATH
9
- require 'rails/commands'
@@ -1,19 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PageControllerTest < ActionController::TestCase
4
- test "should get index" do
5
- get :index
6
- assert_response :success
7
- end
8
-
9
- test "should get test_a" do
10
- get :test_a
11
- assert_response :success
12
- end
13
-
14
- test "should get test_b" do
15
- get :test_b
16
- assert_response :success
17
- end
18
-
19
- end
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
- require 'rails/performance_test_help'
3
-
4
- # Profiling results for each test method are written to tmp/performance.
5
- class BrowsingTest < ActionDispatch::PerformanceTest
6
- def test_homepage
7
- get '/'
8
- end
9
- end
@@ -1,13 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path('../../config/environment', __FILE__)
3
- require 'rails/test_help'
4
-
5
- class ActiveSupport::TestCase
6
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
- #
8
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
- # -- they do not yet inherit this setting
10
- fixtures :all
11
-
12
- # Add more helper methods to be used by all tests here...
13
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PageHelperTest < ActionView::TestCase
4
- end
File without changes
@@ -1,167 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe "Analytical::Api" do
4
-
5
- describe 'on initialization' do
6
- it 'should construct an api class for each module' do
7
- Analytical::Modules::Console.should_receive(:new).and_return(@console = mock('console'))
8
- Analytical::Modules::Google.should_receive(:new).and_return(@google = mock('google'))
9
- a = Analytical::Api.new :modules=>[:console, :google]
10
- a.modules.should == {
11
- :console=>@console,
12
- :google=>@google,
13
- }
14
- end
15
- it 'should pass the ssl option on to the module constructor' do
16
- Analytical::Modules::Console.should_receive(:new).with(hash_including(:ssl=>true)).and_return(@console = mock('console'))
17
- Analytical::Api.new :modules=>[:console], :ssl=>true
18
- end
19
- describe 'with a session option' do
20
- before(:each) do
21
- @session = {}
22
- end
23
- it 'should create a new SessionCommandStore for each module' do
24
- Analytical::SessionCommandStore.should_receive(:new).with(@session, :console).and_return(@console_store = mock('console_store'))
25
- Analytical::SessionCommandStore.should_receive(:new).with(@session, :google).and_return(@google_store = mock('google_store'))
26
- Analytical::Modules::Console.should_receive(:new).with(:session_store=>@console_store, :session=>@session).and_return(mock('console'))
27
- Analytical::Modules::Google.should_receive(:new).with(:session_store=>@google_store, :session=>@session).and_return(mock('google'))
28
- Analytical::Api.new :modules=>[:console, :google], :session=>@session
29
- end
30
- end
31
- end
32
-
33
- describe 'with modules' do
34
- before(:each) do
35
- Analytical::Modules::Console.stub!(:new).and_return(@console = mock('console'))
36
- Analytical::Modules::Google.stub!(:new).and_return(@google = mock('google'))
37
- Analytical::Modules::Clicky.stub!(:new).and_return(@clicky = mock('clicky'))
38
- Analytical::Modules::Chartbeat.stub!(:new).and_return(@chartbeat = mock('chartbeat'))
39
-
40
- @api = Analytical::Api.new :modules=>[:console, :google]
41
- end
42
-
43
- describe '#track' do
44
- it 'should store the #track command for each module api class' do
45
- @api = Analytical::Api.new :modules=>[:console, :google, :clicky]
46
-
47
- @console.should_receive(:queue).with(:track, 'something', {:a=>1, :b=>2})
48
- @clicky.should_receive(:queue).with(:track, 'something', {:a=>1, :b=>2})
49
- @google.should_receive(:queue).with(:track, 'something', {:a=>1, :b=>2})
50
-
51
- @api.track('something', {:a=>1, :b=>2})
52
- end
53
- end
54
-
55
- describe '#identify' do
56
- it 'should store the #track command for each module api class' do
57
- @api = Analytical::Api.new :modules=>[:console, :google, :clicky]
58
-
59
- @console.should_receive(:queue).with(:identify, 'something', {:a=>1, :b=>2})
60
- @clicky.should_receive(:queue).with(:identify, 'something', {:a=>1, :b=>2})
61
- @google.should_receive(:queue).with(:identify, 'something', {:a=>1, :b=>2})
62
-
63
- @api.identify('something', {:a=>1, :b=>2})
64
- end
65
- end
66
-
67
- describe '#now' do
68
- it 'should call a command on each module and collect the results' do
69
- @api = Analytical::Api.new :modules=>[:console, :google, :clicky]
70
-
71
- @console.should_receive(:track).with('something', {:a=>1, :b=>2}).and_return('console track')
72
- @clicky.should_receive(:track).with('something', {:a=>1, :b=>2}).and_return('clicky track')
73
- @google.should_receive(:respond_to?).with(:track).and_return(false)
74
- @google.should_not_receive(:track)
75
-
76
- @api.now.track('something', {:a=>1, :b=>2}).should == "console track\nclicky track"
77
- end
78
- end
79
-
80
- describe 'when accessing a module by name' do
81
- it 'should return the module api object' do
82
- @api = Analytical::Api.new :modules=>[:console, :google, :clicky, :chartbeat]
83
- @api.console.should == @console
84
- @api.clicky.should == @clicky
85
- @api.google.should == @google
86
- @api.chartbeat.should == @chartbeat
87
- end
88
- end
89
-
90
- describe 'gathering javascript' do
91
- before(:each) do
92
- @console.stub!(:init_location?).and_return(false)
93
- @console.stub!(:initialized).and_return(false)
94
- @console.stub!(:process_queued_commands).and_return([])
95
- @google.stub!(:init_location?).and_return(false)
96
- @google.stub!(:initialized).and_return(false)
97
- @google.stub!(:process_queued_commands).and_return([])
98
- end
99
-
100
- describe '#head_prepend_javascript' do
101
- it 'should return the javascript' do
102
- @console.should_receive(:init_javascript).with(:head_prepend).and_return('console_a')
103
- @google.should_receive(:init_javascript).with(:head_prepend).and_return('google_a')
104
- @api.head_prepend_javascript.should == "console_agoogle_a"
105
- end
106
- end
107
-
108
- describe '#head_append_javascript' do
109
- it 'should return the javascript' do
110
- @console.should_receive(:init_javascript).with(:head_append).and_return('console_a')
111
- @google.should_receive(:init_javascript).with(:head_append).and_return('google_a')
112
- @api.head_append_javascript.should == "console_agoogle_a"
113
- end
114
- it 'should render an existing template for Rails 3.0' do
115
- @api.options[:javascript_helpers] = true
116
- (@api.options[:controller] ||= Object.new).stub!(:render_to_string) { |param| param[:partial] }
117
- File.exist?(@api.head_append_javascript).should be_true
118
- end
119
- it 'should not render an existing template if javascript_helpers is false' do
120
- @api.options[:javascript_helpers] = false
121
- (@api.options[:controller] ||= Object.new).should_not_receive(:render_to_string)
122
- @api.head_append_javascript.should be_blank
123
- end
124
- end
125
-
126
- describe '#body_prepend_javascript' do
127
- it 'should return the javascript' do
128
- @console.should_receive(:init_javascript).with(:body_prepend).and_return('console_b')
129
- @google.should_receive(:init_javascript).with(:body_prepend).and_return('google_b')
130
- @api.body_prepend_javascript.should == "console_bgoogle_b"
131
- end
132
- end
133
- describe '#body_append_javascript' do
134
- it 'should return the javascript' do
135
- @console.should_receive(:init_javascript).with(:body_append).and_return('console_c')
136
- @google.should_receive(:init_javascript).with(:body_append).and_return('google_c')
137
- @api.body_append_javascript.should == "console_cgoogle_c"
138
- end
139
- end
140
- describe 'with stored commands' do
141
- before(:each) do
142
- @console.stub!(:init_location?).and_return(true)
143
- @console.stub!(:initialized).and_return(false)
144
- @console.stub!(:track).and_return('console track called')
145
- @console.stub!(:queue)
146
- @console.stub!(:process_queued_commands).and_return(['console track called'])
147
- @google.stub!(:init_location?).and_return(false)
148
- @google.stub!(:initialized).and_return(true)
149
- @google.stub!(:track).and_return('google track called')
150
- @google.stub!(:queue)
151
- @google.stub!(:process_queued_commands).and_return(['google track called'])
152
- @api.track('something', {:a=>1, :b=>2})
153
- end
154
- describe '#body_prepend_javascript' do
155
- it 'should return the javascript' do
156
- @console.should_receive(:init_javascript).with(:body_prepend).and_return('console_b')
157
- @google.should_receive(:init_javascript).with(:body_prepend).and_return('google_b')
158
- @api.body_prepend_javascript.should == "console_bgoogle_b\n<script type='text/javascript'>\nconsole track called\ngoogle track called\n</script>"
159
- end
160
- end
161
- end
162
- end
163
- end
164
-
165
-
166
-
167
- end
@@ -1,24 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe "Analytical::BotDetector" do
4
- class DummyForBotDetector
5
- include Analytical::BotDetector
6
- end
7
- before(:each) do
8
- @d = DummyForBotDetector.new
9
- end
10
-
11
- describe 'with nil user_agent' do
12
- it 'should return false' do
13
- @d.analytical_is_robot?(nil).should be_false
14
- end
15
- end
16
-
17
- describe 'with empty user_agent' do
18
- it 'should return false' do
19
- @d.analytical_is_robot?('').should be_false
20
- end
21
- end
22
-
23
-
24
- end
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Analytical::CommandStore do
4
-
5
- describe 'when behaving exactly like an array' do
6
- it 'should add elements' do
7
- @store = Analytical::CommandStore.new ['a']
8
- @store << 'b'
9
- @store.commands.should == ['a', 'b']
10
- end
11
- it 'should unshift elements' do
12
- @store = Analytical::CommandStore.new ['b']
13
- @store.unshift 'a'
14
- @store.commands.should == ['a', 'b']
15
- end
16
- it 'should iterate over elements' do
17
- @store = Analytical::CommandStore.new ['a', 'b']
18
- @store.each do |elem|
19
- ['a', 'b'].include?(elem).should be_true
20
- end
21
- end
22
- it 'should have size' do
23
- @store = Analytical::CommandStore.new ['a', 'b']
24
- @store.size.should == 2
25
- end
26
- end
27
-
28
- describe 'when flushing' do
29
- it 'should empty the list' do
30
- @store = Analytical::CommandStore.new ['a', 'b']
31
- @store.flush
32
- @store.size.should == 0
33
- end
34
- end
35
-
36
- end
@@ -1,27 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
-
3
- describe "Analytical::Modules::Adroll" do
4
- before(:each) do
5
- @parent = mock('api', :options=>{:Adroll=>{:key=>'abc'}})
6
- end
7
- describe 'on initialize' do
8
- it 'should set the command_location' do
9
- a = Analytical::Modules::Adroll.new :parent=>@parent, :key=>'abc'
10
- a.tracking_command_location.should == :body_append
11
- end
12
- it 'should set the options' do
13
- a = Analytical::Modules::Adroll.new :parent=>@parent, :key=>'abc'
14
- a.options.should == {:key=>'abc', :parent=>@parent}
15
- end
16
- end
17
- describe '#init_javascript' do
18
- it 'should return the init javascript' do
19
- @api = Analytical::Modules::Adroll.new :parent=>@parent, :adv_id=>'abcdef', :pix_id=>'123456'
20
- @api.init_javascript(:head_prepend).should == ''
21
- @api.init_javascript(:head_append).should == ''
22
- @api.init_javascript(:body_append).should =~ /abcdef/
23
- @api.init_javascript(:body_append).should =~ /123456/
24
- @api.init_javascript(:body_append).should =~ /adroll\.com/
25
- end
26
- end
27
- end