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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d7024a1b0e295509049d0a46a29bb31f6d2a8602
4
- data.tar.gz: 5b49a4664bb1bd3c157a1c09dfb50cbbd315c9f9
3
+ metadata.gz: f43ba5786448a3054481f52d10dbfbd2f269ae21
4
+ data.tar.gz: aee5894a286b7ad90e11b7e9fca0a6e2f0f24454
5
5
  SHA512:
6
- metadata.gz: eea2e1f0d790873b215aaceed35c080fd258319dd5100582471d3b88bf28e225aadf9826c553f0bfd13b6a3c517c12240ba25ec33a3c422dcb99dcb3c94a0494
7
- data.tar.gz: e3f1edeb1d5a3ad57774f3bf1a3039e5d39ff6344190492793e0e4696e393892b6570c3b010a9daf342869973230808041b3936f59a456a4d15f9f4534fdfa41
6
+ metadata.gz: e60fcf2e6f84e53d760b6a26c60c863282dee35a521ac50a72839671b70be02696ab997615378bff1e26dd538c4680aeb527126778a41b017708ed9445ba8273
7
+ data.tar.gz: 9d63706259da8a3feaa1bd262551bc1433f307b6fee9d19fde39f477813a69d1e3222a7258236bab27dab81bc67f671cd41db4a283fd0daf1dd871ec804607cc
@@ -1,3 +1,3 @@
1
1
  class ExplainParser
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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, :key, :key_len, :len, :ref, :rows, :filtered, :extra
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(&:strip).reject(&:empty?).map {|val| val == 'NULL' ? nil : val }
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
- @exlpain.to_a
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.0
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-08 00:00:00.000000000 Z
11
+ date: 2014-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler