graphql-analyzer 0.1.1 → 0.1.2

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: 54473f98c98849d98f903aecb9b5d7cc8884814f
4
- data.tar.gz: bd20e305c491fbe3e2995e1557e235b0c2d629c5
3
+ metadata.gz: 495b6fc8f408e0e735bba5da4c41d0f5e2ccabeb
4
+ data.tar.gz: 1aac9d6076edeb2a18fa860de1bb8075ee6b7f4f
5
5
  SHA512:
6
- metadata.gz: dbfd0003f66c9af1f6a39b77508acd9b837c3232318245733c9c29fc93bcb6d7237a267762a642d04c413277f1659bab678d916259438836f615b362b1592141
7
- data.tar.gz: 2cffb2f07dd330c17b543acedc9c114ab4722f7fa951e3f21260f3bd43335a0218e230a670c0f697e12951e5ccd638fb2c73a68df65ac8700e62867b04ed064d
6
+ metadata.gz: 81b1e60dd96bbbe51d5e22dc1082b79525d3230fb2ead1c7c58a464f83613fea5c37e3afa1b94abe296d0ecb4d91a37606f05afec68e3b157c41b0ce0b85b9e8
7
+ data.tar.gz: 87aa1755c052f2a6450b9c26a8d541969ff09d591bbe7744366d5a5e6c7e0007dafdb47fbc9df8f49df174820783f63659c12dfb880d2252e32d9f9e54d94ead
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # GraphQL::Analyzer
2
2
 
3
3
  [![Build Status](https://travis-ci.org/GraphQL-Query-Planner/graphql-analyzer.svg?branch=master)](https://travis-ci.org/GraphQL-Query-Planner/graphql-analyzer)
4
+ [![Gem Version](https://badge.fury.io/rb/graphql-analyzer.svg)](https://rubygems.org/gems/graphql-analyzer)
5
+
4
6
 
5
7
  GraphQL Analyzer is a [GraphQL](https://github.com/rmosolgo/graphql-ruby) extension for tracking datastore queries.
6
8
 
@@ -5,15 +5,25 @@ module GraphQL
5
5
  private
6
6
 
7
7
  def parse
8
- root, keys, *values, _ = explain_output.split("\n").reject { |line| line =~ /^\+.*\+$/ }
9
- fields = keys[1..-1].split('|').map(&:strip).map(&:downcase)
8
+ explained_output_by_query = explain_output.split(/^EXPLAIN.*$/).map(&:chomp).reject(&:empty?)
9
+ queries = explain_output.split("\n").select { |l| l =~ /^EXPLAIN.*$/ }
10
+
11
+ results = []
12
+ queries.each.with_index do |query, i|
13
+ keys, *values, _ = explained_output_by_query[i]
14
+ .split("\n")
15
+ .map(&:chomp)
16
+ .reject { |line| line.empty? || line =~ /^\+.*\+$/ }
17
+ fields = keys[1..-1].split('|').map(&:strip).map(&:downcase)
10
18
 
11
- explained_queries = values.map do |value|
12
- parsed_value = value[1..-1].split("|").map(&:strip)
13
- fields.zip(parsed_value).to_h
14
- end
19
+ explained_queries = values.map do |value|
20
+ parsed_value = value[1..-1].split("|").map(&:strip)
21
+ fields.zip(parsed_value).to_h
22
+ end
15
23
 
16
- Result.new(root, explained_queries)
24
+ results << Result.new(query, explained_queries)
25
+ end
26
+ results
17
27
  end
18
28
  end
19
29
  end
@@ -6,7 +6,7 @@ module GraphQL
6
6
 
7
7
  def parse
8
8
  root, *values, _ = explain_output.split("\n").reject { |line| line =~ /(QUERY\ PLAN)|-{5,}/ }
9
- Result.new(root, [values.join("\n")])
9
+ [Result.new(root, [values.join("\n")])]
10
10
  end
11
11
  end
12
12
  end
@@ -9,7 +9,7 @@ module GraphQL
9
9
  def parse
10
10
  root, *values = explain_output.split("\n")
11
11
  explained_queries = values.map { |value| FIELDS.zip(value.split("|").map(&:strip)).to_h }
12
- Result.new(root, explained_queries)
12
+ [Result.new(root, explained_queries)]
13
13
  end
14
14
  end
15
15
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  class Analyzer
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - DerekStride
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-12 00:00:00.000000000 Z
11
+ date: 2018-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql