explain_parser 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/explain_parser/version.rb +1 -1
- data/lib/explain_parser.rb +28 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f43ba5786448a3054481f52d10dbfbd2f269ae21
|
4
|
+
data.tar.gz: aee5894a286b7ad90e11b7e9fca0a6e2f0f24454
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e60fcf2e6f84e53d760b6a26c60c863282dee35a521ac50a72839671b70be02696ab997615378bff1e26dd538c4680aeb527126778a41b017708ed9445ba8273
|
7
|
+
data.tar.gz: 9d63706259da8a3feaa1bd262551bc1433f307b6fee9d19fde39f477813a69d1e3222a7258236bab27dab81bc67f671cd41db4a283fd0daf1dd871ec804607cc
|
data/lib/explain_parser.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
require "explain_parser/version"
|
2
2
|
|
3
|
+
unless defined?(::Mysql2::Result)
|
4
|
+
module Mysql2; class Result; end; end
|
5
|
+
end
|
6
|
+
|
3
7
|
class ExplainParser
|
4
8
|
|
5
9
|
class Explain
|
6
10
|
COLUMNS = [
|
7
|
-
:id, :select_type, :table, :type, :possible_keys,
|
11
|
+
:id, :select_type, :table, :type, :possible_keys,
|
12
|
+
:key, :key_len, :len, :ref, :rows, :filtered, :extra
|
8
13
|
].freeze
|
9
14
|
|
10
15
|
def initialize(params)
|
@@ -77,7 +82,27 @@ class ExplainParser
|
|
77
82
|
end
|
78
83
|
|
79
84
|
def cleanup_values(dirty_values)
|
80
|
-
dirty_values.map
|
85
|
+
dirty_values.map do |val|
|
86
|
+
case val
|
87
|
+
when String
|
88
|
+
stripped_value = val.strip
|
89
|
+
case stripped_value
|
90
|
+
when 'NULL'
|
91
|
+
nil
|
92
|
+
when /\d+/
|
93
|
+
stripped_value.to_i
|
94
|
+
else
|
95
|
+
stripped_value
|
96
|
+
end
|
97
|
+
else
|
98
|
+
val
|
99
|
+
end
|
100
|
+
end.reject do |val|
|
101
|
+
case val
|
102
|
+
when String
|
103
|
+
val.empty?
|
104
|
+
end
|
105
|
+
end
|
81
106
|
end
|
82
107
|
|
83
108
|
def build
|
@@ -99,7 +124,7 @@ class ExplainParser
|
|
99
124
|
end
|
100
125
|
|
101
126
|
def values_list
|
102
|
-
@
|
127
|
+
@explain.to_a
|
103
128
|
end
|
104
129
|
end
|
105
130
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: explain_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ainame
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|