spring_onion 1.0.0 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -0
- data/Gemfile.lock +2 -2
- data/README.md +2 -3
- data/lib/spring_onion.rb +9 -1
- data/lib/spring_onion/config.rb +4 -4
- data/lib/spring_onion/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 639bf7cf4782c01ed75b4446250720807264d91e37584e19c5a4e82596c6735a
|
4
|
+
data.tar.gz: '0812c1365e66ea9f674fc5a8e32d3960ed9e84ebed6f95f24f3d1137ed56a19e'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 948099cba36db08f3fc566fbe712600de78c6a85f5231ac91b84135daf477454496a5d1406b9cfe083021409112970461b7011b010c6bff4835d9a1df44647e5
|
7
|
+
data.tar.gz: f1b93d8b03884f85bfdb284c3a4af28713b65165654be8928595886085f7645f482fb2befd3e5cb11182864f61dce9e4b34f07862b43209907d6035bc9269fed
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
spring_onion (1.0.
|
4
|
+
spring_onion (1.0.5)
|
5
5
|
activerecord
|
6
6
|
coderay
|
7
7
|
mysql2
|
@@ -28,7 +28,7 @@ GEM
|
|
28
28
|
coderay (1.1.3)
|
29
29
|
concurrent-ruby (1.1.6)
|
30
30
|
diff-lcs (1.4.4)
|
31
|
-
i18n (1.8.
|
31
|
+
i18n (1.8.4)
|
32
32
|
concurrent-ruby (~> 1.0)
|
33
33
|
minitest (5.14.1)
|
34
34
|
mysql2 (0.5.3)
|
data/README.md
CHANGED
@@ -28,16 +28,15 @@ Or install it yourself as:
|
|
28
28
|
#!/usr/bin/env ruby
|
29
29
|
require 'active_record'
|
30
30
|
require 'spring_onion'
|
31
|
-
require 'logger'
|
32
31
|
|
33
32
|
ActiveRecord::Base.establish_connection(
|
34
33
|
adapter: 'mysql2',
|
35
34
|
username: 'root',
|
36
|
-
database: 'employees'
|
35
|
+
database: 'employees'
|
37
36
|
)
|
38
37
|
|
39
38
|
SpringOnion.enabled = true # or `SPRING_ONION_ENABLED=1`
|
40
|
-
SpringOnion.connection = ActiveRecord::Base.connection.raw_connection
|
39
|
+
SpringOnion.connection = ActiveRecord::Base.connection.raw_connection # or `SPRING_ONION_DATABASE_URL=mysql2://...`
|
41
40
|
SpringOnion.source_filter_re = //
|
42
41
|
|
43
42
|
class Employee < ActiveRecord::Base; end
|
data/lib/spring_onion.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'logger'
|
4
|
-
|
4
|
+
|
5
5
|
require 'active_support'
|
6
|
+
require 'coderay'
|
7
|
+
require 'mysql2'
|
6
8
|
|
7
9
|
require 'spring_onion/config'
|
8
10
|
require 'spring_onion/error'
|
@@ -11,6 +13,12 @@ require 'spring_onion/json_logger'
|
|
11
13
|
require 'spring_onion/version'
|
12
14
|
|
13
15
|
ActiveSupport.on_load :active_record do
|
16
|
+
if ENV['SPRING_ONION_DATABASE_URL'] && !SpringOnion.connection
|
17
|
+
SpringOnion.connection = Mysql2::Client.new(
|
18
|
+
ActiveRecord::ConnectionAdapters::ConnectionSpecification::ConnectionUrlResolver.new(ENV['SPRING_ONION_DATABASE_URL']).to_hash
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
14
22
|
require 'active_record/connection_adapters/abstract_mysql_adapter'
|
15
23
|
ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter.prepend SpringOnion::Explainer
|
16
24
|
end
|
data/lib/spring_onion/config.rb
CHANGED
@@ -28,13 +28,13 @@ module SpringOnion
|
|
28
28
|
@enabled = (/\A(1|true)\z/i =~ ENV['SPRING_ONION_ENABLED'])
|
29
29
|
|
30
30
|
@sql_filter_re = ENV['SPRING_ONION_SQL_FILTER_RE'].yield_self do |re|
|
31
|
-
re ? Regexp.new(re) : //
|
31
|
+
re ? Regexp.new(re, Regexp::IGNORECASE) : //
|
32
32
|
end
|
33
33
|
|
34
34
|
@ignore_sql_filter_re = Regexp.union(
|
35
35
|
[/\binformation_schema\b/].tap do |ary|
|
36
36
|
re = ENV['SPRING_ONION_IGNORE_SQL_FILTER_RE']
|
37
|
-
ary << Regexp.new(re) if re
|
37
|
+
ary << Regexp.new(re, Regexp::IGNORECASE) if re
|
38
38
|
end
|
39
39
|
)
|
40
40
|
|
@@ -59,7 +59,7 @@ module SpringOnion
|
|
59
59
|
idx ? backtrace_lines.slice(idx..-1) : []
|
60
60
|
end
|
61
61
|
|
62
|
-
@logger = Logger.new($stdout).tap do |logger|
|
62
|
+
@logger = Logger.new(ENV['SPRING_ONION_LOG'] || $stdout).tap do |logger|
|
63
63
|
logger.formatter = lambda do |severity, datetime, _progname, msg|
|
64
64
|
"\n#{self}\t#{severity}\t#{datetime}\t#{msg}\n"
|
65
65
|
end
|
@@ -67,7 +67,7 @@ module SpringOnion
|
|
67
67
|
|
68
68
|
@trace_len = 3
|
69
69
|
@json_pretty = (/\A(1|true)\z/i =~ ENV['SPRING_ONION_JSON_PRETTY'])
|
70
|
-
@color = /\A(1|true)\z/i =~ ENV.fetch('SPRING_ONION_COLOR',
|
70
|
+
@color = /\A(1|true)\z/i =~ ENV.fetch('SPRING_ONION_COLOR', @logger.instance_variable_get(:@logdev)&.dev&.tty?&.to_s)
|
71
71
|
|
72
72
|
class << self
|
73
73
|
attr_accessor :enabled,
|
data/lib/spring_onion/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spring_onion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winebarrel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|