spring_onion 1.0.0 → 1.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3d2f2a889573516f94fa1f5fb4a3276a26c31de830a9dabc56785e35c715c57
4
- data.tar.gz: de4ca5c79ffdf0455552f54fb95d0316cf5eb075bb281c975e1db3bd0d6a3655
3
+ metadata.gz: 639bf7cf4782c01ed75b4446250720807264d91e37584e19c5a4e82596c6735a
4
+ data.tar.gz: '0812c1365e66ea9f674fc5a8e32d3960ed9e84ebed6f95f24f3d1137ed56a19e'
5
5
  SHA512:
6
- metadata.gz: 247a3d06f4f82854f0fa3a395a5f5ba224362772c3f3c40273029009db5f10babaf5a70de589d1ce08b2c242ec4d1072ab038d0dfb92196262c2527094f879ea
7
- data.tar.gz: 6754099ea2ffb1d6ce713d665954dfb7ebce6f74a51141f85006ff06e4b0bc32083ea155e2c116d22a59552a97d69efa62655935f79337d5736e1883fb448c8d
6
+ metadata.gz: 948099cba36db08f3fc566fbe712600de78c6a85f5231ac91b84135daf477454496a5d1406b9cfe083021409112970461b7011b010c6bff4835d9a1df44647e5
7
+ data.tar.gz: f1b93d8b03884f85bfdb284c3a4af28713b65165654be8928595886085f7645f482fb2befd3e5cb11182864f61dce9e4b34f07862b43209907d6035bc9269fed
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
 
13
13
  # Appraisal Gemfile.lock
14
14
  /gemfiles/*.lock
15
+
16
+ /test.rb
@@ -1,6 +1,7 @@
1
1
  AllCops:
2
2
  Exclude:
3
3
  - "gemfiles/**/*"
4
+ - "test.rb"
4
5
  TargetRubyVersion: 2.5
5
6
  Style/Documentation:
6
7
  Enabled: false
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spring_onion (1.0.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.3)
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
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'logger'
4
- require 'coderay'
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
@@ -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', $stdout.tty?.to_s)
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,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SpringOnion
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.5'
5
5
  end
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.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-19 00:00:00.000000000 Z
11
+ date: 2020-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord