analytical 2.1.0 → 2.2.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.2.0
data/analytical.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{analytical}
8
- s.version = "2.1.0"
8
+ s.version = "2.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joshua Krall", "Nathan Phelps", "Adam Anderson"]
@@ -95,6 +95,7 @@ Gem::Specification.new do |s|
95
95
  "spec/analytical/api_spec.rb",
96
96
  "spec/analytical/bot_detector_spec.rb",
97
97
  "spec/analytical/command_store_spec.rb",
98
+ "spec/analytical/modules/adwords_spec.rb",
98
99
  "spec/analytical/modules/base_spec.rb",
99
100
  "spec/analytical/modules/chartbeat_spec.rb",
100
101
  "spec/analytical/modules/clicky_spec.rb",
@@ -117,6 +118,7 @@ Gem::Specification.new do |s|
117
118
  "spec/analytical/api_spec.rb",
118
119
  "spec/analytical/bot_detector_spec.rb",
119
120
  "spec/analytical/command_store_spec.rb",
121
+ "spec/analytical/modules/adwords_spec.rb",
120
122
  "spec/analytical/modules/base_spec.rb",
121
123
  "spec/analytical/modules/chartbeat_spec.rb",
122
124
  "spec/analytical/modules/clicky_spec.rb",
@@ -13,13 +13,13 @@ module Analytical
13
13
  @initializing = true
14
14
  html = "<!-- Analytical Init: Google Adwords -->\n"
15
15
  event_commands = []
16
- @commands.each do |c|
16
+ @command_store.commands.each do |c|
17
17
  if c[0] == :event
18
18
  event_commands << event(*c[1..-1])
19
19
  end
20
20
  end
21
21
  html += event_commands.join("\n")
22
- @commands = @commands.delete_if {|c| c[0] == :event }
22
+ @command_store.commands = @command_store.commands.delete_if {|c| c[0] == :event }
23
23
  @initializing = false
24
24
 
25
25
  html
@@ -62,10 +62,10 @@ module Analytical
62
62
  var google_conversion_value = #{data[:value] || conversion[:value]};
63
63
  /* ]]> */
64
64
  </script>
65
- <script type="text/javascript" src="#{procotol}://www.googleadservices.com/pagead/conversion.js"></script>
65
+ <script type="text/javascript" src="#{protocol}://www.googleadservices.com/pagead/conversion.js"></script>
66
66
  <noscript>
67
67
  <div style="display:inline;">
68
- <img height="1" width="1" style="border-style:none;" alt="" src="#{procotol}://www.googleadservices.com/pagead/conversion/#{conversion[:id]}/?label=#{conversion[:label]}&amp;guid=ON&amp;script=0"/>
68
+ <img height="1" width="1" style="border-style:none;" alt="" src="#{protocol}://www.googleadservices.com/pagead/conversion/#{conversion[:id]}/?label=#{conversion[:label]}&amp;guid=ON&amp;script=0"/>
69
69
  </div>
70
70
  </noscript>
71
71
  HTML
@@ -0,0 +1,76 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
+
3
+ describe "Analytical::Modules::Adwords" do
4
+ before(:each) do
5
+ @parent = mock('api', :options=>{:google=>{:key=>'abc'}})
6
+ end
7
+ describe 'on initialize' do
8
+ it 'should set the command_location' do
9
+ a = Analytical::Modules::Adwords.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::Adwords.new :parent=>@parent, :key=>'abc'
14
+ a.options.should == {:key=>'abc', :parent=>@parent}
15
+ end
16
+ end
17
+ describe '#event' do
18
+ it 'should return an empty string' do
19
+ @api = Analytical::Modules::Adwords.new :parent=>@parent, :key=>'abcdef'
20
+ @api.event('Nothing', {:some=>'data'}).should == ''
21
+ end
22
+ end
23
+ describe '#init_javascript' do
24
+ describe 'when a matching conversion event is not found' do
25
+ it 'should return the event js' do
26
+ @api = Analytical::Modules::Adwords.new :parent=>@parent, :key=>'abcdef'
27
+ @api.queue :event, 'Nothing', {:some=>'data'}
28
+ @api.init_javascript(:body_append).should.should =~ /<!-- No Adwords Conversion for: Nothing -->/
29
+ end
30
+ end
31
+ describe 'for a given conversion event' do
32
+ before(:each) do
33
+ @api = Analytical::Modules::Adwords.new :parent=>@parent, :key=>'abcdef', :'TheBigEvent'=>{
34
+ :id=>'55555',
35
+ :language=>'en',
36
+ :format=>'2',
37
+ :color=>'ffffff',
38
+ :label=>'abcdef',
39
+ :value=>'0',
40
+ }
41
+ end
42
+ it 'should return the event js' do
43
+ @api.queue :event, 'TheBigEvent'
44
+ body_append = @api.init_javascript(:body_append).should
45
+ body_append.should =~ /google_conversion_id = 55555/m
46
+ body_append.should =~ /google_conversion_language = "en";/m
47
+ body_append.should =~ /google_conversion_format = "2";/m
48
+ body_append.should =~ /google_conversion_color = "ffffff";/m
49
+ body_append.should =~ /google_conversion_label = "abcdef";/m
50
+ body_append.should =~ /google_conversion_value = 0;/m
51
+ body_append.should =~ /http:\/\/www.googleadservices.com\/pagead\/conversion.js/m
52
+ end
53
+ describe 'with a custom value' do
54
+ it 'should return the event js' do
55
+ @api.queue :event, 'TheBigEvent', :value=>666.66
56
+ body_append = @api.init_javascript(:body_append).should
57
+ body_append.should =~ /google_conversion_value = 666.66;/m
58
+ end
59
+ end
60
+ describe 'for https' do
61
+ it 'should return the event js' do
62
+ @api = Analytical::Modules::Adwords.new :parent=>@parent, :key=>'abcdef', :ssl=>true, :'TheBigEvent'=>{
63
+ :id=>'55555',
64
+ :language=>'en',
65
+ :format=>'2',
66
+ :color=>'ffffff',
67
+ :label=>'abcdef',
68
+ :value=>'0',
69
+ }
70
+ @api.queue :event, 'TheBigEvent'
71
+ @api.init_javascript(:body_append).should =~ /https:\/\/www.googleadservices.com\/pagead\/conversion.js/
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 2
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 2.1.0
9
+ version: 2.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joshua Krall
@@ -133,6 +133,7 @@ files:
133
133
  - spec/analytical/api_spec.rb
134
134
  - spec/analytical/bot_detector_spec.rb
135
135
  - spec/analytical/command_store_spec.rb
136
+ - spec/analytical/modules/adwords_spec.rb
136
137
  - spec/analytical/modules/base_spec.rb
137
138
  - spec/analytical/modules/chartbeat_spec.rb
138
139
  - spec/analytical/modules/clicky_spec.rb
@@ -179,6 +180,7 @@ test_files:
179
180
  - spec/analytical/api_spec.rb
180
181
  - spec/analytical/bot_detector_spec.rb
181
182
  - spec/analytical/command_store_spec.rb
183
+ - spec/analytical/modules/adwords_spec.rb
182
184
  - spec/analytical/modules/base_spec.rb
183
185
  - spec/analytical/modules/chartbeat_spec.rb
184
186
  - spec/analytical/modules/clicky_spec.rb