appstats 0.22.2 → 0.22.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- appstats (0.22.2)
4
+ appstats (0.22.3)
5
5
  daemons
6
6
  net-scp
7
7
  rails (>= 2.3.0)
data/Gemfile.lock.rails2 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- appstats (0.22.2)
4
+ appstats (0.22.3)
5
5
  daemons
6
6
  net-scp
7
7
  rails (>= 2.3.0)
@@ -3,11 +3,11 @@ class AddAppstatsResultsLatestFlag < ActiveRecord::Migration
3
3
  add_column :appstats_results, :is_latest, :boolean
4
4
  add_index :appstats_results, :is_latest
5
5
 
6
- ActiveRecord::Base.connection.update('update appstats_results set is_latest = false')
7
- all = ActiveRecord::Base.connection.select_all("select concat(id,' ',max(updated_at)) as id_and_date from appstats_results group by query")
6
+ Appstats.connection.update('update appstats_results set is_latest = false')
7
+ all = Appstats.connection.select_all("select concat(id,' ',max(updated_at)) as id_and_date from appstats_results group by query")
8
8
  return if all.empty?
9
9
  ids = all.each.collect { |e| e["id_and_date"].split[0] }.compact
10
- ActiveRecord::Base.connection.update("update appstats_results set is_latest = '1' where id in (#{ids.join(',')})")
10
+ Appstats.connection.update("update appstats_results set is_latest = '1' where id in (#{ids.join(',')})")
11
11
  end
12
12
 
13
13
  def self.down
@@ -9,7 +9,7 @@ module Appstats
9
9
  def self.update_actions
10
10
  sql = "select distinct(action) from appstats_entries where action not in (select name from appstats_actions)"
11
11
  count = 0
12
- ActiveRecord::Base.connection.execute(sql).each do |row|
12
+ Appstats.connection.execute(sql).each do |row|
13
13
  Appstats::Action.create(:name => row[0], :plural_name => row[0].pluralize, :status => 'derived')
14
14
  count += 1
15
15
  end
@@ -13,7 +13,7 @@ module Appstats
13
13
  where (action,context_key) not in (select action_name, context_key from appstats_action_context_keys)
14
14
  group by action,context_key"
15
15
  count = 0
16
- ActiveRecord::Base.connection.execute(sql).each do |row|
16
+ Appstats.connection.execute(sql).each do |row|
17
17
  Appstats::ActionContextKey.create(:action_name => row[0], :context_key => row[1], :status => 'derived')
18
18
  count += 1
19
19
  end
@@ -44,7 +44,7 @@ module Appstats
44
44
  end
45
45
 
46
46
  def db_connection
47
- ActiveRecord::Base.connection
47
+ Appstats.connection
48
48
  end
49
49
 
50
50
  def self.available_action?(action)
@@ -7,20 +7,20 @@ module Appstats
7
7
 
8
8
  def self.rename(old_key,new_key)
9
9
  sql = ["update appstats_context_keys set name = ?, updated_at = ? where name = ?",new_key,Time.now,old_key]
10
- ActiveRecord::Base.connection.update(ActiveRecord::Base.send(:sanitize_sql_array, sql))
10
+ Appstats.connection.update(ActiveRecord::Base.send(:sanitize_sql_array, sql))
11
11
 
12
12
  sql = ["update appstats_contexts set context_key = ?, updated_at = ? where context_key = ?",new_key,Time.now,old_key]
13
- ActiveRecord::Base.connection.update(ActiveRecord::Base.send(:sanitize_sql_array, sql))
13
+ Appstats.connection.update(ActiveRecord::Base.send(:sanitize_sql_array, sql))
14
14
 
15
15
  sql = ["update appstats_action_context_keys set context_key = ?, updated_at = ? where context_key = ?",new_key,Time.now,old_key]
16
- ActiveRecord::Base.connection.update(ActiveRecord::Base.send(:sanitize_sql_array, sql))
16
+ Appstats.connection.update(ActiveRecord::Base.send(:sanitize_sql_array, sql))
17
17
 
18
18
  end
19
19
 
20
20
  def self.update_context_keys
21
21
  sql = "select distinct(context_key) from appstats_contexts where context_key not in (select name from appstats_context_keys)"
22
22
  count = 0
23
- ActiveRecord::Base.connection.execute(sql).each do |row|
23
+ Appstats.connection.execute(sql).each do |row|
24
24
  Appstats::ContextKey.create(:name => row[0], :status => 'derived')
25
25
  count += 1
26
26
  end
@@ -8,7 +8,7 @@ module Appstats
8
8
  def self.update_context_values
9
9
  sql = "select distinct(context_value) from appstats_contexts where context_value not in (select name from appstats_context_values)"
10
10
  count = 0
11
- ActiveRecord::Base.connection.execute(sql).each do |row|
11
+ Appstats.connection.execute(sql).each do |row|
12
12
  Appstats::ContextValue.create(:name => row[0], :status => 'derived')
13
13
  count += 1
14
14
  end
data/lib/appstats/host.rb CHANGED
@@ -8,7 +8,7 @@ module Appstats
8
8
  def self.update_hosts
9
9
  sql = "select distinct(host) from appstats_log_collectors where host not in (select name from appstats_hosts)"
10
10
  count = 0
11
- ActiveRecord::Base.connection.execute(sql).each do |row|
11
+ Appstats.connection.execute(sql).each do |row|
12
12
  Appstats::Host.create(:name => row[0], :status => 'derived')
13
13
  count += 1
14
14
  end
@@ -204,8 +204,8 @@ module Appstats
204
204
  private
205
205
 
206
206
  def db_connection
207
- return ActiveRecord::Base.connection if @custom_query.nil?
208
- @backup_config = ActiveRecord::Base.connection.instance_variable_get(:@config)
207
+ return Appstats.connection if @custom_query.nil?
208
+ @backup_config = Appstats.connection.instance_variable_get(:@config)
209
209
  custom_connection = @custom_query.db_connection
210
210
  end
211
211
 
@@ -220,7 +220,7 @@ module Appstats
220
220
  timer = FriendlyTimer.new
221
221
  results = yield db_connection
222
222
  timer.stop
223
- db_config = ActiveRecord::Base.connection.instance_variable_get(:@config)
223
+ db_config = Appstats.connection.instance_variable_get(:@config)
224
224
  restore_connection
225
225
  data = { :results => results, :db_config => db_config, :duration => timer.duration }
226
226
  return data
@@ -69,11 +69,11 @@ module Appstats
69
69
  alias_method :eql?, :==
70
70
 
71
71
  def self.fix_all_is_latest
72
- ActiveRecord::Base.connection.update('update appstats_results set is_latest = false')
73
- all = ActiveRecord::Base.connection.select_all("select concat(id,' ',max(updated_at)) as id_and_date from appstats_results group by query")
72
+ connection.update('update appstats_results set is_latest = false')
73
+ all = connection.select_all("select concat(id,' ',max(updated_at)) as id_and_date from appstats_results group by query")
74
74
  return if all.empty?
75
75
  ids = all.each.collect { |e| e["id_and_date"].split[0] }.compact
76
- ActiveRecord::Base.connection.update("update appstats_results set is_latest = '1' where id in (#{ids.join(',')})")
76
+ connection.update("update appstats_results set is_latest = '1' where id in (#{ids.join(',')})")
77
77
  end
78
78
 
79
79
  def self.calculate_count_to_s(raw_count,data = {})
@@ -94,14 +94,14 @@ module Appstats
94
94
 
95
95
  def update_is_latest
96
96
  sql = ["update appstats_results set is_latest = false where query = ?",query]
97
- ActiveRecord::Base.connection.update(ActiveRecord::Base.send(:sanitize_sql_array, sql))
97
+ connection.update(ActiveRecord::Base.send(:sanitize_sql_array, sql))
98
98
 
99
99
  sql = ["select id from appstats_results where query = ? order by updated_at DESC",query]
100
- first = ActiveRecord::Base.connection.select_one(ActiveRecord::Base.send(:sanitize_sql_array, sql))
100
+ first = connection.select_one(ActiveRecord::Base.send(:sanitize_sql_array, sql))
101
101
  return if first.nil?
102
102
 
103
103
  sql = ["update appstats_results set is_latest = '1' where id = ?",first["id"]]
104
- ActiveRecord::Base.connection.update(ActiveRecord::Base.send(:sanitize_sql_array, sql))
104
+ connection.update(ActiveRecord::Base.send(:sanitize_sql_array, sql))
105
105
  end
106
106
 
107
107
  def self.add_commas(num)
@@ -14,7 +14,7 @@ module Appstats
14
14
  dbconfig = YAML::load(File.open('db/config.yml'))
15
15
  ActiveRecord::Base.establish_connection(dbconfig['development']).connection
16
16
  else
17
- ActiveRecord::Base.connection
17
+ Appstats.connection
18
18
  end
19
19
  end
20
20
 
@@ -29,7 +29,7 @@ module Appstats
29
29
  end
30
30
 
31
31
  def db_connection
32
- ActiveRecord::Base.connection
32
+ Appstats.connection
33
33
  end
34
34
 
35
35
  end
@@ -44,7 +44,7 @@ module Appstats
44
44
  end
45
45
 
46
46
  def db_connection
47
- ActiveRecord::Base.connection
47
+ Appstats.connection
48
48
  end
49
49
 
50
50
  end
@@ -55,7 +55,7 @@ module Appstats
55
55
  attr_accessor :query
56
56
  def process_query; end
57
57
  def db_connection
58
- ActiveRecord::Base.connection
58
+ Appstats.connection
59
59
  end
60
60
 
61
61
  end
@@ -72,7 +72,7 @@ module Appstats
72
72
 
73
73
 
74
74
  def db_connection
75
- ActiveRecord::Base.connection
75
+ Appstats.connection
76
76
  end
77
77
 
78
78
  end
@@ -84,6 +84,6 @@ class YetAnotherTestQuery
84
84
  attr_accessor :query
85
85
  def process_query; end
86
86
  def db_connection
87
- ActiveRecord::Base.connection
87
+ Appstats.connection
88
88
  end
89
89
  end
@@ -4,6 +4,6 @@ class UnloadedQuery
4
4
  attr_accessor :query
5
5
  def process_query; end
6
6
  def db_connection
7
- ActiveRecord::Base.connection
7
+ Appstats.connection
8
8
  end
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module Appstats
2
- VERSION = "0.22.2"
2
+ VERSION = "0.22.3"
3
3
  end
data/lib/appstats.rb CHANGED
@@ -52,5 +52,8 @@ module Appstats
52
52
  Appstats::Action.respond_to?(:where)
53
53
  end
54
54
 
55
+ def self.connection
56
+ Appstats::Entry.new.connection
57
+ end
55
58
 
56
59
  end
@@ -49,7 +49,7 @@ while($running) do
49
49
  end
50
50
 
51
51
  last_processed_at = Time.now
52
- ActiveRecord::Base.connection.reconnect!
52
+ Appstats.connection.reconnect!
53
53
  appstats_config["remote_servers"].each do |remote_server|
54
54
  Appstats::LogCollector.find_remote_files(remote_server,remote_server[:path],remote_server[:template])
55
55
  end
@@ -65,5 +65,5 @@ while($running) do
65
65
  Appstats::ContextValue.update_context_values
66
66
  Appstats::ActionContextKey.update_action_context_keys
67
67
  Appstats::LogCollector.remove_remote_files(appstats_config["remote_servers"])
68
- ActiveRecord::Base.connection.disconnect!
68
+ Appstats.connection.disconnect!
69
69
  end
@@ -146,7 +146,7 @@ module Appstats
146
146
 
147
147
  it "should use the extract_env" do
148
148
  @appstats_query.query = Appstats::Query.new(:query => "# blahs on blah")
149
- @appstats_query.db_connection.should == ActiveRecord::Base.connection
149
+ @appstats_query.db_connection.should == Appstats.connection
150
150
  end
151
151
 
152
152
  end
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.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
196
+ entry = Entry.create_from_logger_string("0.22.3 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.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
199
+ entry.raw_entry.should == "0.22.3 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.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
204
+ entry = Entry.create_from_logger_string("0.22.3 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.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
207
+ entry.raw_entry.should == "0.22.3 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.22.2 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : action=save_ovcen : app_name=cdb')
217
+ entry = Entry.create_from_logger_string('0.22.3 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.22.2 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : action=save_ovcen : app_name=cdb"
220
+ entry.raw_entry.should == "0.22.3 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.22.2 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : app_name=market : app_name=cdb')
231
+ entry = Entry.create_from_logger_string('0.22.3 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.22.2 setup[:,=,-n] 2011-02-24 12:59:57 action=page-view : app_name=market : app_name=cdb"
234
+ entry.raw_entry.should == "0.22.3 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
@@ -122,12 +122,12 @@ module Appstats
122
122
 
123
123
  it "should accept numbers" do
124
124
  Appstats::Logger.entry(5, :blah => 6)
125
- Appstats::Logger.raw_read.should == ["0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=5 : blah=6"]
125
+ Appstats::Logger.raw_read.should == ["0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=5 : blah=6"]
126
126
  end
127
127
 
128
128
  it "should accept arrays" do
129
129
  Appstats::Logger.entry('search', :provider => [ 'one', 'two' ])
130
- Appstats::Logger.raw_read.should == ["0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=search : provider=one : provider=two"]
130
+ Appstats::Logger.raw_read.should == ["0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=search : provider=one : provider=two"]
131
131
  end
132
132
 
133
133
 
@@ -137,7 +137,7 @@ module Appstats
137
137
 
138
138
  it "should look similar to regular entry" do
139
139
  Appstats::Logger.exception_entry(RuntimeError.new("blah"),:on => "login")
140
- Appstats::Logger.raw_read.should == ["0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=appstats-exception : error=blah : on=login"]
140
+ Appstats::Logger.raw_read.should == ["0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=appstats-exception : error=blah : on=login"]
141
141
  end
142
142
 
143
143
  end
@@ -154,47 +154,47 @@ module Appstats
154
154
 
155
155
  it "should handle a statistics entry" do
156
156
  expected = { :action => "address_search", :timestamp => "2010-09-21 23:15:20" }
157
- actual = Appstats::Logger.entry_to_hash("0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
157
+ actual = Appstats::Logger.entry_to_hash("0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search")
158
158
  actual.should == expected
159
159
  end
160
160
 
161
161
  it "should handle contexts" do
162
162
  expected = { :action => "address_filter", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
163
- actual = Appstats::Logger.entry_to_hash("0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
163
+ actual = Appstats::Logger.entry_to_hash("0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live")
164
164
  actual.should == expected
165
165
  end
166
166
 
167
167
  it "should handle multiple actions" do
168
168
  expected = { :action => ["address_filter", "blah"], :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
169
- actual = Appstats::Logger.entry_to_hash("0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : action=blah : app_name=Market : server=Live")
169
+ actual = Appstats::Logger.entry_to_hash("0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : action=blah : app_name=Market : server=Live")
170
170
  actual.should == expected
171
171
  end
172
172
 
173
173
  it "should handle multiple of same context" do
174
174
  expected = { :action => "address_filter", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => ['Sin','Market'] }
175
- actual = Appstats::Logger.entry_to_hash("0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Sin : app_name=Market : server=Live")
175
+ actual = Appstats::Logger.entry_to_hash("0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Sin : app_name=Market : server=Live")
176
176
  actual.should == expected
177
177
  end
178
178
 
179
179
  it "should handle no actions" do
180
180
  expected = { :action => "UNKNOWN_ACTION", :timestamp => "2010-09-21 23:15:20", :server => "Live", :app_name => 'Market' }
181
- actual = Appstats::Logger.entry_to_hash("0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 app_name=Market : server=Live")
181
+ actual = Appstats::Logger.entry_to_hash("0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 app_name=Market : server=Live")
182
182
  actual.should == expected
183
183
  end
184
184
 
185
185
  it "should handle actions with the delimiter (and change the delimiter)" do
186
186
  expected = { :action => "address:=search-n", :timestamp => "2010-09-21 23:15:20" }
187
- actual = Appstats::Logger.entry_to_hash("0.22.2 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n")
187
+ actual = Appstats::Logger.entry_to_hash("0.22.3 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n")
188
188
  actual.should == expected
189
189
 
190
190
  expected = { :action => "address::search==--n", :timestamp => "2010-09-21 23:15:20" }
191
- actual = Appstats::Logger.entry_to_hash("0.22.2 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n")
191
+ actual = Appstats::Logger.entry_to_hash("0.22.3 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n")
192
192
  actual.should == expected
193
193
  end
194
194
 
195
195
  it "should handle contexts with the delimiter (and change the delimiter)" do
196
196
  expected = { :action => "address", :timestamp => "2010-09-21 23:15:20", :server => "market:eval=-n" }
197
- actual = Appstats::Logger.entry_to_hash("0.22.2 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n")
197
+ actual = Appstats::Logger.entry_to_hash("0.22.3 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n")
198
198
  actual.should == expected
199
199
  end
200
200
 
@@ -203,66 +203,66 @@ module Appstats
203
203
  describe "#entry_to_s" do
204
204
 
205
205
  it "should handle a statistics entry" do
206
- expected = "0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
206
+ expected = "0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search"
207
207
  actual = Appstats::Logger.entry_to_s("address_search")
208
208
  actual.should == expected
209
209
  end
210
210
 
211
211
  it "should handle numbers" do
212
- expected = "0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=1 : note=2.2"
212
+ expected = "0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=1 : note=2.2"
213
213
  actual = Appstats::Logger.entry_to_s(1,:note => 2.2)
214
214
  actual.should == expected
215
215
  end
216
216
 
217
217
  it "should handle default contexts" do
218
218
  Appstats::Logger.default_contexts[:app_name] = "market"
219
- expected = "0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : app_name=market"
219
+ expected = "0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : app_name=market"
220
220
  actual = Appstats::Logger.entry_to_s("address_search")
221
221
  actual.should == expected
222
222
  end
223
223
 
224
224
  it "should handle contexts (and sort them by symbol)" do
225
- expected = "0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
225
+ expected = "0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_filter : app_name=Market : server=Live"
226
226
  actual = Appstats::Logger.entry_to_s("address_filter", { :server => "Live", :app_name => 'Market' })
227
227
  actual.should == expected
228
228
  end
229
229
 
230
230
  it "should handle actions with the delimiter (and change the delimiter)" do
231
- expected = "0.22.2 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n"
231
+ expected = "0.22.3 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=search-n"
232
232
  actual = Appstats::Logger.entry_to_s("address:=search-n")
233
233
  actual.should == expected
234
234
 
235
- expected = "0.22.2 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n"
235
+ expected = "0.22.3 setup[:::,===,---n] 2010-09-21 23:15:20 action===address::search==--n"
236
236
  actual = Appstats::Logger.entry_to_s("address::search==--n")
237
237
  actual.should == expected
238
238
  end
239
239
 
240
240
  it "should handle contexts with the delimiter (and change the delimiter)" do
241
- expected = "0.22.2 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n"
241
+ expected = "0.22.3 setup[::,==,--n] 2010-09-21 23:15:20 action==address :: server==market:eval=-n"
242
242
  actual = Appstats::Logger.entry_to_s("address", :server => 'market:eval=-n')
243
243
  actual.should == expected
244
244
  end
245
245
 
246
246
  it "should ignore spaces" do
247
- expected = "0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address search"
247
+ expected = "0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address search"
248
248
  actual = Appstats::Logger.entry_to_s("address search")
249
249
  actual.should == expected
250
250
  end
251
251
 
252
252
  it "should convert newlines in action" do
253
- expected = "0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_-nsearch"
253
+ expected = "0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_-nsearch"
254
254
  actual = Appstats::Logger.entry_to_s("address_\nsearch")
255
255
  actual.should == expected
256
256
  end
257
257
 
258
258
  it "should convert newlines in context" do
259
- expected = "0.22.2 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : blah=some-nlong-nstatement"
259
+ expected = "0.22.3 setup[:,=,-n] 2010-09-21 23:15:20 action=address_search : blah=some-nlong-nstatement"
260
260
  actual = Appstats::Logger.entry_to_s("address_search",:blah => "some\nlong\nstatement")
261
261
  actual.should == expected
262
262
  end
263
263
 
264
264
  it "should convert newlines based on the delimiter" do
265
- expected = "0.22.2 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=--nsearch-n"
265
+ expected = "0.22.3 setup[::,==,--n] 2010-09-21 23:15:20 action==address:=--nsearch-n"
266
266
  actual = Appstats::Logger.entry_to_s("address:=\nsearch-n")
267
267
  actual.should == expected
268
268
  end
data/spec/query_spec.rb CHANGED
@@ -558,7 +558,7 @@ module Appstats
558
558
  result.query_type.should == "Appstats::BadTestQuery"
559
559
  result.count.should == nil
560
560
 
561
- ActiveRecord::Base.connection.current_database.should == YAML::load(File.open('db/config.yml'))["test"]["database"]
561
+ Appstats.connection.current_database.should == YAML::load(File.open('db/config.yml'))["test"]["database"]
562
562
  end
563
563
 
564
564
 
data/spec/result_spec.rb CHANGED
@@ -249,7 +249,7 @@ module Appstats
249
249
  another_new_result = Appstats::Result.create(:query => '# y')
250
250
  Time.stub!(:now).and_return(Time.parse('2010-09-21 23:15:20'))
251
251
  another_old_result = Appstats::Result.create(:query => '# y')
252
- ActiveRecord::Base.connection.update('update appstats_results set is_latest = null')
252
+ Appstats.connection.update('update appstats_results set is_latest = null')
253
253
 
254
254
  old_result = Appstats::Result.create(:query => '# x')
255
255
 
@@ -278,7 +278,7 @@ module Appstats
278
278
  Time.stub!(:now).and_return(Time.parse('2010-09-21 23:15:20'))
279
279
  old_result = Appstats::Result.create(:query => '# x')
280
280
  another_result = Appstats::Result.create(:query => '# y')
281
- ActiveRecord::Base.connection.update('update appstats_results set is_latest = null')
281
+ Appstats.connection.update('update appstats_results set is_latest = null')
282
282
 
283
283
  Appstats::Result.fix_all_is_latest
284
284
 
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: 67
4
+ hash: 65
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 22
9
- - 2
10
- version: 0.22.2
9
+ - 3
10
+ version: 0.22.3
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-07-19 00:00:00 Z
18
+ date: 2011-07-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rails