time_bandits 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/time_bandits/monkey_patches/active_record.rb +16 -3
- data/lib/time_bandits/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11e4567fb95d4e259e4876a3aaaff7f94843dfc8
|
4
|
+
data.tar.gz: b25ee1cb3aca3d49920043c65a7598736bb76dc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 404166f2bb17ccf3f05b3159c44e1e1206f67e1e167b16168232090894edbf89d3506a8b0e887d014cc915796f08d565de73d39aa44d3b4129ea9ef370104a32
|
7
|
+
data.tar.gz: 3df661bf1935fa0f11d2e85a3552f7f6619e166acf2dd9d6b0e2782fd192419021c2e485673c251edecf5b4ece353a3dc229841d0cb4c152b9ec5dd0051ef35e
|
@@ -4,12 +4,13 @@
|
|
4
4
|
# it needs to be adapted to each new rails version
|
5
5
|
|
6
6
|
raise "time_bandits ActiveRecord monkey patch is not compatible with your rails version" unless
|
7
|
-
Rails::VERSION::STRING =~ /^3\.[012]/
|
7
|
+
Rails::VERSION::STRING =~ /^(3\.[012]|4\.[0])/
|
8
8
|
|
9
9
|
require "active_record/log_subscriber"
|
10
10
|
|
11
11
|
module ActiveRecord
|
12
12
|
class LogSubscriber
|
13
|
+
IGNORE_PAYLOAD_NAMES = ["SCHEMA", "EXPLAIN"] unless defined?(IGNORE_PAYLOAD_NAMES)
|
13
14
|
|
14
15
|
def self.call_count=(value)
|
15
16
|
Thread.current.thread_variable_set(:active_record_sql_call_count, value)
|
@@ -41,6 +42,18 @@ module ActiveRecord
|
|
41
42
|
hits
|
42
43
|
end
|
43
44
|
|
45
|
+
def render_bind(column, value)
|
46
|
+
if column
|
47
|
+
if column.binary?
|
48
|
+
value = "<#{value.bytesize} bytes of binary data>"
|
49
|
+
end
|
50
|
+
|
51
|
+
[column.name, value]
|
52
|
+
else
|
53
|
+
[nil, value]
|
54
|
+
end
|
55
|
+
end unless instance_methods.include?(:render_bind)
|
56
|
+
|
44
57
|
def sql(event)
|
45
58
|
self.class.runtime += event.duration
|
46
59
|
self.class.call_count += 1
|
@@ -50,7 +63,7 @@ module ActiveRecord
|
|
50
63
|
|
51
64
|
payload = event.payload
|
52
65
|
|
53
|
-
return if
|
66
|
+
return if IGNORE_PAYLOAD_NAMES.include?(payload[:name])
|
54
67
|
|
55
68
|
name = '%s (%.1fms)' % [payload[:name], event.duration]
|
56
69
|
sql = payload[:sql].squeeze(' ')
|
@@ -58,7 +71,7 @@ module ActiveRecord
|
|
58
71
|
|
59
72
|
unless (payload[:binds] || []).empty?
|
60
73
|
binds = " " + payload[:binds].map { |col,v|
|
61
|
-
|
74
|
+
render_bind(col, v)
|
62
75
|
}.inspect
|
63
76
|
end
|
64
77
|
|
data/lib/time_bandits/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time_bandits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Kaes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread_variables
|