spring_onion 0.2.5 → 1.0.4
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/.rspec +0 -1
- data/.rubocop.yml +5 -0
- data/.travis.yml +17 -1
- data/Appraisals +9 -0
- data/Dockerfile +14 -0
- data/Gemfile.lock +3 -3
- data/README.md +12 -3
- data/Rakefile +6 -1
- data/docker-compose.yml +15 -0
- data/gemfiles/ar52.gemfile +9 -0
- data/gemfiles/ar60.gemfile +9 -0
- data/lib/spring_onion.rb +9 -1
- data/lib/spring_onion/config.rb +3 -3
- data/lib/spring_onion/explainer.rb +2 -0
- data/lib/spring_onion/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 325954f6357509048bdbf57ac733617bdc0762d07e3e220daf15dbe38148b793
|
4
|
+
data.tar.gz: 3883f9e7ea4a760efb8db2533fb75dc4750b7d4f0721e6528b33cc3d3c847684
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e94c491d1621b82f0956c63d72460e035f47d7bf71cf034516ef2f0be3757098de511d12ca703e70583eeb4757b8ad59d5327787ea64ad6d4bf3d0f1fa39cf0
|
7
|
+
data.tar.gz: 820a0b5d10b006fbb42a31490dd64425b99c6d9ba81faa9808877c0ac874a8f2c3318db5277b80fecb9baf4afdc9bd3573f3029d6a08bea1f5df5c160e0522ca
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,9 +1,12 @@
|
|
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
|
8
|
+
Style/TrailingCommaInArrayLiteral:
|
9
|
+
EnforcedStyleForMultiline: consistent_comma
|
7
10
|
Style/TrailingCommaInHashLiteral:
|
8
11
|
EnforcedStyleForMultiline: consistent_comma
|
9
12
|
Metrics/AbcSize:
|
@@ -12,6 +15,8 @@ Metrics/CyclomaticComplexity:
|
|
12
15
|
Enabled: false
|
13
16
|
Metrics/MethodLength:
|
14
17
|
Enabled: false
|
18
|
+
Metrics/BlockLength:
|
19
|
+
Enabled: false
|
15
20
|
Layout/LineLength:
|
16
21
|
Enabled: false
|
17
22
|
|
data/.travis.yml
CHANGED
@@ -2,5 +2,21 @@
|
|
2
2
|
language: ruby
|
3
3
|
cache: bundler
|
4
4
|
rvm:
|
5
|
+
- 2.5.8
|
5
6
|
- 2.6.6
|
6
|
-
|
7
|
+
- 2.7.1
|
8
|
+
gemfile:
|
9
|
+
- gemfiles/ar52.gemfile
|
10
|
+
- gemfiles/ar60.gemfile
|
11
|
+
services:
|
12
|
+
- mysql
|
13
|
+
env:
|
14
|
+
- DATABASE_URL=mysql2://travis@localhost/sakila
|
15
|
+
before_install:
|
16
|
+
- gem install bundler -v 2.1.2
|
17
|
+
- curl -sSfL https://downloads.mysql.com/docs/sakila-db.tar.gz -o - | tar zxf -
|
18
|
+
- cd sakila-db
|
19
|
+
- mysql < sakila-schema.sql
|
20
|
+
- mysql < sakila-data.sql
|
21
|
+
script:
|
22
|
+
- bundle exec rake
|
data/Appraisals
ADDED
data/Dockerfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
FROM rubylang/ruby:2.5-bionic
|
2
|
+
|
3
|
+
RUN apt-get update && \
|
4
|
+
apt-get install -y \
|
5
|
+
mysql-client \
|
6
|
+
libmysqlclient-dev \
|
7
|
+
rubygems \
|
8
|
+
curl
|
9
|
+
|
10
|
+
COPY ./ /mnt/
|
11
|
+
WORKDIR /mnt
|
12
|
+
RUN gem update bundler -f && \
|
13
|
+
bundle install && \
|
14
|
+
bundle exec appraisal install
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
spring_onion (0.
|
4
|
+
spring_onion (1.0.4)
|
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)
|
@@ -83,4 +83,4 @@ DEPENDENCIES
|
|
83
83
|
spring_onion!
|
84
84
|
|
85
85
|
BUNDLED WITH
|
86
|
-
2.1.
|
86
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# SpringOnion
|
2
2
|
|
3
3
|
Log MySQL queries with EXPLAIN that may be slow.
|
4
|
+
|
4
5
|
Inspired by [MySQLCasualLog.pm](https://gist.github.com/kamipo/839e8a5b6d12bddba539).
|
5
6
|
|
7
|
+
[![Build Status](https://travis-ci.org/winebarrel/spring_onion.svg?branch=master)](https://travis-ci.org/winebarrel/spring_onion)
|
8
|
+
|
6
9
|
## Installation
|
7
10
|
|
8
11
|
Add this line to your application's Gemfile:
|
@@ -25,16 +28,15 @@ Or install it yourself as:
|
|
25
28
|
#!/usr/bin/env ruby
|
26
29
|
require 'active_record'
|
27
30
|
require 'spring_onion'
|
28
|
-
require 'logger'
|
29
31
|
|
30
32
|
ActiveRecord::Base.establish_connection(
|
31
33
|
adapter: 'mysql2',
|
32
34
|
username: 'root',
|
33
|
-
database: 'employees'
|
35
|
+
database: 'employees'
|
34
36
|
)
|
35
37
|
|
36
38
|
SpringOnion.enabled = true # or `SPRING_ONION_ENABLED=1`
|
37
|
-
SpringOnion.connection = ActiveRecord::Base.connection.raw_connection
|
39
|
+
SpringOnion.connection = ActiveRecord::Base.connection.raw_connection # or `SPRING_ONION_DATABASE_URL=mysql2://...`
|
38
40
|
SpringOnion.source_filter_re = //
|
39
41
|
|
40
42
|
class Employee < ActiveRecord::Base; end
|
@@ -75,3 +77,10 @@ p Employee.all.to_a.count
|
|
75
77
|
]
|
76
78
|
}
|
77
79
|
```
|
80
|
+
|
81
|
+
## Test
|
82
|
+
|
83
|
+
```sh
|
84
|
+
docker-compose build
|
85
|
+
docker-compose run client bundle exec appraisal ar60 rake
|
86
|
+
```
|
data/Rakefile
CHANGED
@@ -2,7 +2,12 @@
|
|
2
2
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
5
6
|
|
6
7
|
RSpec::Core::RakeTask.new(:spec)
|
7
8
|
|
8
|
-
|
9
|
+
RuboCop::RakeTask.new do |task|
|
10
|
+
task.options = %w[-c .rubocop.yml]
|
11
|
+
end
|
12
|
+
|
13
|
+
task default: %i[rubocop spec]
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
version: "3.8"
|
2
|
+
services:
|
3
|
+
client:
|
4
|
+
build: .
|
5
|
+
environment:
|
6
|
+
MYSQL_PING_ATTEMPTS: "10"
|
7
|
+
DATABASE_URL: mysql2://root@db/sakila
|
8
|
+
volumes:
|
9
|
+
- ./:/mnt
|
10
|
+
depends_on:
|
11
|
+
- db
|
12
|
+
db:
|
13
|
+
image: budougumi0617/mysql-sakila:5.7
|
14
|
+
environment:
|
15
|
+
MYSQL_ALLOW_EMPTY_PASSWORD: "1"
|
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
|
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: 0.
|
4
|
+
version: 1.0.4
|
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
|
@@ -133,11 +133,16 @@ files:
|
|
133
133
|
- ".rspec"
|
134
134
|
- ".rubocop.yml"
|
135
135
|
- ".travis.yml"
|
136
|
+
- Appraisals
|
137
|
+
- Dockerfile
|
136
138
|
- Gemfile
|
137
139
|
- Gemfile.lock
|
138
140
|
- LICENSE.txt
|
139
141
|
- README.md
|
140
142
|
- Rakefile
|
143
|
+
- docker-compose.yml
|
144
|
+
- gemfiles/ar52.gemfile
|
145
|
+
- gemfiles/ar60.gemfile
|
141
146
|
- lib/spring_onion.rb
|
142
147
|
- lib/spring_onion/config.rb
|
143
148
|
- lib/spring_onion/error.rb
|