snogmetrics 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/snogmetrics.rb +14 -18
- data/spec/snogmetrics_spec.rb +6 -6
- metadata +4 -32
data/lib/snogmetrics.rb
CHANGED
@@ -16,7 +16,7 @@ require 'snogmetrics/railtie' if defined? Rails::Railtie
|
|
16
16
|
# the default implementation outputs the real API only when
|
17
17
|
# `Rails.env.production?` is true.
|
18
18
|
module Snogmetrics
|
19
|
-
VERSION = '0.1.
|
19
|
+
VERSION = '0.1.7'
|
20
20
|
|
21
21
|
# Returns an instance of KissmetricsApi, which is an interface to the
|
22
22
|
# KISSmetrics API. It has the methods #record and #identify, which work just
|
@@ -105,22 +105,18 @@ private
|
|
105
105
|
# subsequent calls to #js will not send events that have already been sent.
|
106
106
|
def js(options={})
|
107
107
|
options = {:reset => false}.merge(options)
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
#{buffer.join("\n")}
|
121
|
-
</script>
|
122
|
-
JAVASCRIPT
|
123
|
-
end
|
108
|
+
|
109
|
+
buffer = queue.map { |item| %(_kmq.push(#{item.to_json});) }
|
110
|
+
|
111
|
+
queue.clear if options[:reset]
|
112
|
+
|
113
|
+
<<-JAVASCRIPT
|
114
|
+
<script type="text/javascript">
|
115
|
+
var _kmq = _kmq || [];
|
116
|
+
#{api_js}
|
117
|
+
#{buffer.join("\n")}
|
118
|
+
</script>
|
119
|
+
JAVASCRIPT
|
124
120
|
end
|
125
121
|
|
126
122
|
private
|
@@ -151,4 +147,4 @@ private
|
|
151
147
|
end
|
152
148
|
end
|
153
149
|
end
|
154
|
-
end
|
150
|
+
end
|
data/spec/snogmetrics_spec.rb
CHANGED
@@ -111,10 +111,6 @@ describe Snogmetrics do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
describe '#js' do
|
114
|
-
it 'outputs nothing if there are no events and no identity' do
|
115
|
-
@context.km.js.should be_empty
|
116
|
-
end
|
117
|
-
|
118
114
|
context 'in production' do
|
119
115
|
before do
|
120
116
|
Rails.stub!(:env).and_return(mock('env', :production? => true))
|
@@ -135,6 +131,10 @@ describe Snogmetrics do
|
|
135
131
|
@context.km.js.should_not include('scripts.kissmetrics.com')
|
136
132
|
end
|
137
133
|
end
|
134
|
+
|
135
|
+
it 'outputs javascript even if there are no events and no identity' do
|
136
|
+
@context.km.js.should include('kmq')
|
137
|
+
end
|
138
138
|
|
139
139
|
it 'outputs code that conditionally sets the _kmq variable' do
|
140
140
|
@context.km.identify('Phil')
|
@@ -151,7 +151,7 @@ describe Snogmetrics do
|
|
151
151
|
it 'resets the session when passed :reset => true' do
|
152
152
|
@context.km.record('hello world')
|
153
153
|
@context.km.js(:reset => true)
|
154
|
-
@context.km.js.
|
154
|
+
@context.km.js.should_not include('hello world')
|
155
155
|
end
|
156
156
|
|
157
157
|
it 'does not let HTML slip through' do
|
@@ -164,7 +164,7 @@ describe Snogmetrics do
|
|
164
164
|
it 'works like #js(:reset => true)' do
|
165
165
|
@context.km.record('hello world')
|
166
166
|
@context.km.js!
|
167
|
-
@context.km.js.
|
167
|
+
@context.km.js!.should_not include('_kmq.push(["record"')
|
168
168
|
end
|
169
169
|
|
170
170
|
it 'does not push an identify call if the identity has already been sent once' do
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snogmetrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 6
|
9
|
-
version: 0.1.6
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.7
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Theo Hultberg
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-06-27 00:00:00 +02:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,10 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ~>
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 0
|
31
|
-
- 0
|
32
24
|
version: 1.0.0
|
33
25
|
type: :development
|
34
26
|
version_requirements: *id001
|
@@ -40,10 +32,6 @@ dependencies:
|
|
40
32
|
requirements:
|
41
33
|
- - ~>
|
42
34
|
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 0
|
45
|
-
- 8
|
46
|
-
- 7
|
47
35
|
version: 0.8.7
|
48
36
|
type: :development
|
49
37
|
version_requirements: *id002
|
@@ -55,8 +43,6 @@ dependencies:
|
|
55
43
|
requirements:
|
56
44
|
- - ">="
|
57
45
|
- !ruby/object:Gem::Version
|
58
|
-
segments:
|
59
|
-
- 0
|
60
46
|
version: "0"
|
61
47
|
type: :development
|
62
48
|
version_requirements: *id003
|
@@ -68,8 +54,6 @@ dependencies:
|
|
68
54
|
requirements:
|
69
55
|
- - ">="
|
70
56
|
- !ruby/object:Gem::Version
|
71
|
-
segments:
|
72
|
-
- 0
|
73
57
|
version: "0"
|
74
58
|
type: :development
|
75
59
|
version_requirements: *id004
|
@@ -81,8 +65,6 @@ dependencies:
|
|
81
65
|
requirements:
|
82
66
|
- - ">="
|
83
67
|
- !ruby/object:Gem::Version
|
84
|
-
segments:
|
85
|
-
- 0
|
86
68
|
version: "0"
|
87
69
|
type: :development
|
88
70
|
version_requirements: *id005
|
@@ -94,8 +76,6 @@ dependencies:
|
|
94
76
|
requirements:
|
95
77
|
- - ">="
|
96
78
|
- !ruby/object:Gem::Version
|
97
|
-
segments:
|
98
|
-
- 0
|
99
79
|
version: "0"
|
100
80
|
type: :development
|
101
81
|
version_requirements: *id006
|
@@ -107,8 +87,6 @@ dependencies:
|
|
107
87
|
requirements:
|
108
88
|
- - ">="
|
109
89
|
- !ruby/object:Gem::Version
|
110
|
-
segments:
|
111
|
-
- 0
|
112
90
|
version: "0"
|
113
91
|
type: :development
|
114
92
|
version_requirements: *id007
|
@@ -177,23 +155,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
155
|
requirements:
|
178
156
|
- - ">="
|
179
157
|
- !ruby/object:Gem::Version
|
180
|
-
segments:
|
181
|
-
- 0
|
182
158
|
version: "0"
|
183
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
160
|
none: false
|
185
161
|
requirements:
|
186
162
|
- - ">="
|
187
163
|
- !ruby/object:Gem::Version
|
188
|
-
segments:
|
189
|
-
- 1
|
190
|
-
- 3
|
191
|
-
- 6
|
192
164
|
version: 1.3.6
|
193
165
|
requirements: []
|
194
166
|
|
195
167
|
rubyforge_project: snogmetrics
|
196
|
-
rubygems_version: 1.
|
168
|
+
rubygems_version: 1.5.2
|
197
169
|
signing_key:
|
198
170
|
specification_version: 3
|
199
171
|
summary: SNOGmetrics is a KISSmetrics helper for Rails
|