mysql2_query_filter-plugin-casual_log 0.0.1 → 0.0.2

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
  SHA1:
3
- metadata.gz: 7deeddc1b117319fe5c95c760314bee02b69c5b7
4
- data.tar.gz: ab110e16e8da18ef0127373eac9dbe3820fa0bf6
3
+ metadata.gz: 6e6cadd21416ab73e104023ef7080f38f9513928
4
+ data.tar.gz: 33f27ab2020ace4d7ec88f0555db5ba8f28dc97b
5
5
  SHA512:
6
- metadata.gz: f5f74d16993aced999182cf6ec4f242f099c02e2e5b9c46a8f84a63a29a830f3ad7131166e07b64439759a065fefd31158575c93787dd0e8301cef276673f8cb
7
- data.tar.gz: 7c17a7148e4af433c41c5341476ab16cbccd6e5f6b01fb524e729f6f1a1889c3f6a2f07afffeacbcd0d67aeb5899f7b6d105f981acdebc73df178927f3400b90
6
+ metadata.gz: 616b65d944b815c9b03af9aab6c56e59b15993bae94e8f76b9bf86c12aed8c5e015732210c44b05389bb03f6ba1f0861962bfabd889db0b3eb6313029bd24327
7
+ data.tar.gz: f27ae65d3483f39d11e43636e588d9c05e222e7865bf22dbe9eeb419a970fa0c23f4a2fbfc93a66f4601b893cb48765fa99daf685e8c02a22c40a5db1606ef9d
@@ -36,20 +36,10 @@ module Mysql2QueryFilter::Plugin
36
36
  end
37
37
 
38
38
  def filter(sql)
39
- if sql =~ /\Aselect\b/i
39
+ if sql =~ /\A\s*select\b/i
40
40
  result = @client.query("EXPLAIN #{sql}").first
41
41
  badquery = colorize_explain(result)
42
-
43
- if badquery
44
- @out.puts "# #{sql}\n---"
45
- max_key_length = result.keys.map(&:length).max
46
-
47
- result.each do |key, value|
48
- @out.puts "%*s: %s" % [max_key_length, key, value]
49
- end
50
-
51
- @out.puts
52
- end
42
+ output_message(sql, result) if badquery
53
43
  end
54
44
  end
55
45
 
@@ -73,5 +63,16 @@ module Mysql2QueryFilter::Plugin
73
63
  def colored(str)
74
64
  Term::ANSIColor.red(Term::ANSIColor.bold(str))
75
65
  end
66
+
67
+ def output_message(sql, explain)
68
+ message = "# #{sql}\n---\n"
69
+ max_key_length = explain.keys.map(&:length).max
70
+
71
+ explain.each do |key, value|
72
+ message << "%*s: %s\n" % [max_key_length, key, value]
73
+ end
74
+
75
+ @out << message
76
+ end
76
77
  end
77
78
  end
@@ -1,12 +1,12 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = 'mysql2_query_filter-plugin-casual_log'
4
- spec.version = '0.0.1'
4
+ spec.version = '0.0.2'
5
5
  spec.authors = ['Genki Sugawara']
6
6
  spec.email = ['sgwr_dts@yahoo.co.jp']
7
7
  spec.summary = %q{Plug-in that colorize the bad query for Mysql2QueryFilter.}
8
8
  spec.description = %q{Plug-in that colorize the bad query for Mysql2QueryFilter.}
9
- spec.homepage = ''
9
+ spec.homepage = 'https://github.com/winebarrel/mysql2_query_filter-plugin-casual_log'
10
10
  spec.license = 'MIT'
11
11
 
12
12
  spec.files = `git ls-files -z`.split("\x0")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql2_query_filter-plugin-casual_log
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
@@ -80,7 +80,7 @@ files:
80
80
  - Rakefile
81
81
  - lib/mysql2_query_filter/plugin/casual_log.rb
82
82
  - mysql2_query_filter-plugin-casual_log.gemspec
83
- homepage: ''
83
+ homepage: https://github.com/winebarrel/mysql2_query_filter-plugin-casual_log
84
84
  licenses:
85
85
  - MIT
86
86
  metadata: {}