appstats 0.13.3 → 0.13.4
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/Gemfile.lock +1 -1
- data/lib/appstats/logger.rb +4 -1
- data/lib/appstats/version.rb +1 -1
- data/spec/entry_spec.rb +8 -8
- data/spec/logger_spec.rb +27 -21
- data/spec/query_spec.rb +14 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/lib/appstats/logger.rb
CHANGED
@@ -40,7 +40,10 @@ module Appstats
|
|
40
40
|
answer = "#{Appstats::VERSION} setup[#{section_delimiter},#{assign_delimiter},#{newline_delimiter}] "
|
41
41
|
answer += "#{now} action#{assign_delimiter}#{format_input(action,newline_delimiter)}"
|
42
42
|
contexts.keys.sort.each do |key|
|
43
|
-
|
43
|
+
all_val = contexts[key].kind_of?(Array) ? contexts[key] : [contexts[key]]
|
44
|
+
all_val.each do |value|
|
45
|
+
answer += " #{section_delimiter} #{key}#{assign_delimiter}#{format_input(value,newline_delimiter)}"
|
46
|
+
end
|
44
47
|
end
|
45
48
|
answer
|
46
49
|
end
|
data/lib/appstats/version.rb
CHANGED
data/spec/entry_spec.rb
CHANGED
@@ -193,18 +193,18 @@ module Appstats
|
|
193
193
|
end
|
194
194
|
|
195
195
|
it "should understand an entry without contexts" do
|
196
|
-
entry = Entry.create_from_logger_string("0.13.
|
196
|
+
entry = Entry.create_from_logger_string("0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
|
197
197
|
Entry.count.should == @before_count + 1
|
198
198
|
entry.action.should == "address_search"
|
199
|
-
entry.raw_entry.should == "0.13.
|
199
|
+
entry.raw_entry.should == "0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
|
200
200
|
entry.occurred_at.should == Time.parse("2010-09-21 23:15:20")
|
201
201
|
end
|
202
202
|
|
203
203
|
it "should understand contexts" do
|
204
|
-
entry = Entry.create_from_logger_string("0.13.
|
204
|
+
entry = Entry.create_from_logger_string("0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
|
205
205
|
Entry.count.should == @before_count + 1
|
206
206
|
entry.action.should == "address_filter"
|
207
|
-
entry.raw_entry.should == "0.13.
|
207
|
+
entry.raw_entry.should == "0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
|
208
208
|
entry.occurred_at.should == Time.parse("2010-09-21 23:15:20")
|
209
209
|
entry.contexts.size.should == 2
|
210
210
|
entry.contexts[0].context_key = "app_name"
|
@@ -214,10 +214,10 @@ module Appstats
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should handle 'action' as a context" do
|
217
|
-
entry = Entry.create_from_logger_string('0.13.
|
217
|
+
entry = Entry.create_from_logger_string('0.13.4 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : action=save_ovcen : app_name=cdb')
|
218
218
|
Entry.count.should == @before_count + 1
|
219
219
|
entry.action.should == "page-view"
|
220
|
-
entry.raw_entry.should == "0.13.
|
220
|
+
entry.raw_entry.should == "0.13.4 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : action=save_ovcen : app_name=cdb"
|
221
221
|
entry.occurred_at.should == Time.parse("2011-02-24 12:59:57")
|
222
222
|
entry.contexts.size.should == 2
|
223
223
|
entry.contexts[0].context_key = "action"
|
@@ -228,10 +228,10 @@ module Appstats
|
|
228
228
|
end
|
229
229
|
|
230
230
|
it "should handle multiple of the same 'context'" do
|
231
|
-
entry = Entry.create_from_logger_string('0.13.
|
231
|
+
entry = Entry.create_from_logger_string('0.13.4 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : app_name=market : app_name=cdb')
|
232
232
|
Entry.count.should == @before_count + 1
|
233
233
|
entry.action.should == "page-view"
|
234
|
-
entry.raw_entry.should == "0.13.
|
234
|
+
entry.raw_entry.should == "0.13.4 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : app_name=market : app_name=cdb"
|
235
235
|
entry.occurred_at.should == Time.parse("2011-02-24 12:59:57")
|
236
236
|
entry.contexts.size.should == 2
|
237
237
|
entry.contexts[0].context_key = "app_name"
|
data/spec/logger_spec.rb
CHANGED
@@ -115,16 +115,22 @@ module Appstats
|
|
115
115
|
|
116
116
|
it "should accept numbers" do
|
117
117
|
Appstats::Logger.entry(5, :blah => 6)
|
118
|
-
Appstats::Logger.raw_read.should == ["0.13.
|
118
|
+
Appstats::Logger.raw_read.should == ["0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=5 : blah=6"]
|
119
119
|
end
|
120
120
|
|
121
|
+
it "should accept arrays" do
|
122
|
+
Appstats::Logger.entry('search', :provider => [ 'one', 'two' ])
|
123
|
+
Appstats::Logger.raw_read.should == ["0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=search : provider=one : provider=two"]
|
124
|
+
end
|
125
|
+
|
126
|
+
|
121
127
|
end
|
122
128
|
|
123
129
|
describe "#exception_entry" do
|
124
130
|
|
125
131
|
it "should look similar to regular entry" do
|
126
132
|
Appstats::Logger.exception_entry(RuntimeError.new("blah"),:on => "login")
|
127
|
-
Appstats::Logger.raw_read.should == ["0.13.
|
133
|
+
Appstats::Logger.raw_read.should == ["0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=appstats-exception : error=blah : on=login"]
|
128
134
|
end
|
129
135
|
|
130
136
|
end
|
@@ -141,47 +147,47 @@ module Appstats
|
|
141
147
|
|
142
148
|
it "should handle a statistics entry" do
|
143
149
|
expected = { :action => "address_search", :timestamp => "2010-09-21 23:15:20" }
|
144
|
-
actual = Appstats::Logger.entry_to_hash("0.13.
|
150
|
+
actual = Appstats::Logger.entry_to_hash("0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
|
145
151
|
actual.should == expected
|
146
152
|
end
|
147
153
|
|
148
154
|
it "should handle contexts" do
|
149
155
|
expected = { :action => "address_filter", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
|
150
|
-
actual = Appstats::Logger.entry_to_hash("0.13.
|
156
|
+
actual = Appstats::Logger.entry_to_hash("0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
|
151
157
|
actual.should == expected
|
152
158
|
end
|
153
159
|
|
154
160
|
it "should handle multiple actions" do
|
155
161
|
expected = { :action => ["address_filter", "blah"], :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
|
156
|
-
actual = Appstats::Logger.entry_to_hash("0.13.
|
162
|
+
actual = Appstats::Logger.entry_to_hash("0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : action=blah : app_name=Market : server=Live")
|
157
163
|
actual.should == expected
|
158
164
|
end
|
159
165
|
|
160
166
|
it "should handle multiple of same context" do
|
161
167
|
expected = { :action => "address_filter", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => ['Sin','Market'] }
|
162
|
-
actual = Appstats::Logger.entry_to_hash("0.13.
|
168
|
+
actual = Appstats::Logger.entry_to_hash("0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Sin : app_name=Market : server=Live")
|
163
169
|
actual.should == expected
|
164
170
|
end
|
165
171
|
|
166
172
|
it "should handle no actions" do
|
167
173
|
expected = { :action => "UNKNOWN_ACTION", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
|
168
|
-
actual = Appstats::Logger.entry_to_hash("0.13.
|
174
|
+
actual = Appstats::Logger.entry_to_hash("0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 app_name=Market : server=Live")
|
169
175
|
actual.should == expected
|
170
176
|
end
|
171
177
|
|
172
178
|
it "should handle actions with the delimiter (and change the delimiter)" do
|
173
179
|
expected = { :action => "address:=search-n", :timestamp => "2010-09-21 23:15:20" }
|
174
|
-
actual = Appstats::Logger.entry_to_hash("0.13.
|
180
|
+
actual = Appstats::Logger.entry_to_hash("0.13.4 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n")
|
175
181
|
actual.should == expected
|
176
182
|
|
177
183
|
expected = { :action => "address::search==--n", :timestamp => "2010-09-21 23:15:20" }
|
178
|
-
actual = Appstats::Logger.entry_to_hash("0.13.
|
184
|
+
actual = Appstats::Logger.entry_to_hash("0.13.4 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n")
|
179
185
|
actual.should == expected
|
180
186
|
end
|
181
187
|
|
182
188
|
it "should handle contexts with the delimiter (and change the delimiter)" do
|
183
189
|
expected = { :action => "address", :timestamp => "2010-09-21 23:15:20", :server => "market:eval=-n" }
|
184
|
-
actual = Appstats::Logger.entry_to_hash("0.13.
|
190
|
+
actual = Appstats::Logger.entry_to_hash("0.13.4 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n")
|
185
191
|
actual.should == expected
|
186
192
|
end
|
187
193
|
|
@@ -190,66 +196,66 @@ module Appstats
|
|
190
196
|
describe "#entry_to_s" do
|
191
197
|
|
192
198
|
it "should handle a statistics entry" do
|
193
|
-
expected = "0.13.
|
199
|
+
expected = "0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
|
194
200
|
actual = Appstats::Logger.entry_to_s("address_search")
|
195
201
|
actual.should == expected
|
196
202
|
end
|
197
203
|
|
198
204
|
it "should handle numbers" do
|
199
|
-
expected = "0.13.
|
205
|
+
expected = "0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=1 : note=2.2"
|
200
206
|
actual = Appstats::Logger.entry_to_s(1,:note => 2.2)
|
201
207
|
actual.should == expected
|
202
208
|
end
|
203
209
|
|
204
210
|
it "should handle default contexts" do
|
205
211
|
Appstats::Logger.default_contexts[:app_name] = "market"
|
206
|
-
expected = "0.13.
|
212
|
+
expected = "0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : app_name=market"
|
207
213
|
actual = Appstats::Logger.entry_to_s("address_search")
|
208
214
|
actual.should == expected
|
209
215
|
end
|
210
216
|
|
211
217
|
it "should handle contexts (and sort them by symbol)" do
|
212
|
-
expected = "0.13.
|
218
|
+
expected = "0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
|
213
219
|
actual = Appstats::Logger.entry_to_s("address_filter", { :server => "Live", :app_name => 'Market' })
|
214
220
|
actual.should == expected
|
215
221
|
end
|
216
222
|
|
217
223
|
it "should handle actions with the delimiter (and change the delimiter)" do
|
218
|
-
expected = "0.13.
|
224
|
+
expected = "0.13.4 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n"
|
219
225
|
actual = Appstats::Logger.entry_to_s("address:=search-n")
|
220
226
|
actual.should == expected
|
221
227
|
|
222
|
-
expected = "0.13.
|
228
|
+
expected = "0.13.4 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n"
|
223
229
|
actual = Appstats::Logger.entry_to_s("address::search==--n")
|
224
230
|
actual.should == expected
|
225
231
|
end
|
226
232
|
|
227
233
|
it "should handle contexts with the delimiter (and change the delimiter)" do
|
228
|
-
expected = "0.13.
|
234
|
+
expected = "0.13.4 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n"
|
229
235
|
actual = Appstats::Logger.entry_to_s("address", :server => 'market:eval=-n')
|
230
236
|
actual.should == expected
|
231
237
|
end
|
232
238
|
|
233
239
|
it "should ignore spaces" do
|
234
|
-
expected = "0.13.
|
240
|
+
expected = "0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address search"
|
235
241
|
actual = Appstats::Logger.entry_to_s("address search")
|
236
242
|
actual.should == expected
|
237
243
|
end
|
238
244
|
|
239
245
|
it "should convert newlines in action" do
|
240
|
-
expected = "0.13.
|
246
|
+
expected = "0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_-nsearch"
|
241
247
|
actual = Appstats::Logger.entry_to_s("address_\nsearch")
|
242
248
|
actual.should == expected
|
243
249
|
end
|
244
250
|
|
245
251
|
it "should convert newlines in context" do
|
246
|
-
expected = "0.13.
|
252
|
+
expected = "0.13.4 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : blah=some-nlong-nstatement"
|
247
253
|
actual = Appstats::Logger.entry_to_s("address_search",:blah => "some\nlong\nstatement")
|
248
254
|
actual.should == expected
|
249
255
|
end
|
250
256
|
|
251
257
|
it "should convert newlines based on the delimiter" do
|
252
|
-
expected = "0.13.
|
258
|
+
expected = "0.13.4 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=--nsearch-n"
|
253
259
|
actual = Appstats::Logger.entry_to_s("address:=\nsearch-n")
|
254
260
|
actual.should == expected
|
255
261
|
end
|
data/spec/query_spec.rb
CHANGED
@@ -93,6 +93,20 @@ module Appstats
|
|
93
93
|
Appstats::Entry.create(:action => "myblahs")
|
94
94
|
query.run.count.should == 2
|
95
95
|
end
|
96
|
+
|
97
|
+
it "should not double count an entry with multiple contexts" do
|
98
|
+
Appstats::Entry.create_from_logger("myblahs",:app_name => ["a","b"])
|
99
|
+
query = Appstats::Query.new(:query => "# myblahs where app_name='a' or app_name = 'b'")
|
100
|
+
query.run.count.should == 1
|
101
|
+
|
102
|
+
Appstats::Entry.create_from_logger("myblahs",:app_name => ["a","c"])
|
103
|
+
Appstats::Entry.create_from_logger("myblahs",:app_name => ["b","d"])
|
104
|
+
Appstats::Entry.create_from_logger("myblahs",:app_name => ["c","d"])
|
105
|
+
query = Appstats::Query.new(:query => "# myblahs where app_name='a' or app_name = 'b'")
|
106
|
+
query.run.count.should == 3
|
107
|
+
|
108
|
+
end
|
109
|
+
|
96
110
|
|
97
111
|
it "should perform the action search" do
|
98
112
|
Appstats::Entry.create_from_logger("myblahs", :one => "11", :two => "222")
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appstats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 35
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 13
|
9
|
-
-
|
10
|
-
version: 0.13.
|
9
|
+
- 4
|
10
|
+
version: 0.13.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andrew Forward
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-28 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|