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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9fae2e6cc7b44a9befcffb7c710c1f760119a17c
4
- data.tar.gz: fa6a537a7fff153f5e30917c53f0a284f7d81db7
3
+ metadata.gz: 11e4567fb95d4e259e4876a3aaaff7f94843dfc8
4
+ data.tar.gz: b25ee1cb3aca3d49920043c65a7598736bb76dc6
5
5
  SHA512:
6
- metadata.gz: 7b813da44b27582d7be37fd98e5dc4c92cc4b05d00be9f3966cf7e98917f74bea5ff3e20e2f4a5f7885c67f513092082b844031db163a844ca3a1a1803fe2d40
7
- data.tar.gz: 3ff9e7968d16b4462acd859a8280fbb24aad02fe90ed0036e735975ebac311ee882ae2063bda7c56b1cc1859b23e564b5c899c5e7d8ef7065a810e70cceae281
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 'SCHEMA' == payload[:name]
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
- [col.name, v]
74
+ render_bind(col, v)
62
75
  }.inspect
63
76
  end
64
77
 
@@ -1,3 +1,3 @@
1
1
  module TimeBandits
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
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.1
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: 2013-12-28 00:00:00.000000000 Z
11
+ date: 2014-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thread_variables