mongo_clarify 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: 36c90f7e00b8374b12af01bc1a4dccfea1e5a0794ca8de73f15f37857368acbd
4
- data.tar.gz: d17f50a9ef3f588ee32df9a2dc072f6185e46c2e2a85f88de1795595bcd6b5f8
3
+ metadata.gz: c5eaf57ef80937dc7775a997adfaf20fcf38cf8b3c86a4168762277208c59a09
4
+ data.tar.gz: 83c783004ec9759ca32dc75402d400572828af989c9c446aaf1ba43af3b944f5
5
5
  SHA512:
6
- metadata.gz: d54511d77bba0f73c50098f3f71ca5f815a0652d0fe4ff4793bc5e7d0a1546e03f312641039243039205537ed41477ed914547dc62a166b0b1c5e55492019ded
7
- data.tar.gz: 24d6d711bbbdb8cba7c1a2aebc1826cbb255cab637da14477eb75d6b6813ee97e04d466c9f4a4f30a45f96292074198f6553524260d0602446cdd3b0a6687308
6
+ metadata.gz: 3ab45003e8f4d9316b106e38aeb3c7da813c35b3602b1d68c0e030e420e1ab98ba5a9384a518e3cde610448b703b8a4a28e26c3e40c6c164acb83749e2b96a8c
7
+ data.tar.gz: 4267879d0f6d076bd93f613414a92a75e695ef28aee46abe8dd5e164043cd370612854526ffa36fed5c9cde627f0aaaa30fdbd1df04b9f6a7a1607a4e577f632
@@ -4,7 +4,7 @@ AllCops:
4
4
  Exclude:
5
5
  - "vendor/**/*"
6
6
  - "spec/spec_helper.rb"
7
- - "lib/mongo_clarify/investigate_ruby2_7.rb"
7
+ - "lib/mongo_clarify/investigate_with_pattern_matching.rb"
8
8
 
9
9
  Style/Documentation:
10
10
  Enabled: false
@@ -17,4 +17,4 @@ Metrics/LineLength:
17
17
 
18
18
  Style/LambdaCall:
19
19
  Exclude:
20
- - "lib/mongo_clarify/investigate.rb"
20
+ - "lib/mongo_clarify/investigate_without_pattern_matching.rb"
@@ -1,5 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.5.1
5
- before_install: gem install bundler -v 1.16.1
4
+ - 2.6
5
+ - ruby-head
6
+
7
+ script: bundle exec rspec
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mongo_clarify (0.1.0)
4
+ mongo_clarify (0.1.1)
5
5
  pattern-match
6
6
 
7
7
  GEM
@@ -97,4 +97,4 @@ DEPENDENCIES
97
97
  rubocop-performance
98
98
 
99
99
  BUNDLED WITH
100
- 1.16.1
100
+ 1.17.2
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+
2
3
  # frozen_string_literal: true
3
4
 
4
5
  $LOAD_PATH.unshift("#{__dir__}/../lib")
@@ -1,41 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'pattern-match/experimental'
4
-
5
- module MongoClarify
6
- class Investigate
7
- using PatternMatch
8
-
9
- def initialize(explain)
10
- @explain = explain
11
- end
3
+ if Gem::Version.create(RUBY_VERSION) >= Gem::Version.create('2.7')
4
+ require_relative 'investigate_with_pattern_matching'
5
+ else
6
+ require_relative 'investigate_without_pattern_matching'
7
+ end
12
8
 
13
- def operation_method
14
- match(@explain) do
15
- with(Hash.(queryPlanner: Hash.(winningPlan: Hash.(stage: 'COLLSCAN')))) do
16
- 'Collection Scan'
17
- end
18
- with(Hash.(queryPlanner: Hash.(winningPlan: Hash.(stage: 'FETCH', inputStage: Hash.(stage: 'IXSCAN', indexName: index_name))))) do
19
- "Index Scan (Index Name: #{index_name})"
20
- end
21
- end
22
- rescue PatternMatch::NoMatchingPatternError
23
- nil
24
- end
25
9
 
26
- def execution_stats
27
- match(@explain) do
28
- with(Hash.(executionStats: Hash.(nReturned: n, executionTimeMillis: msec, totalKeysExamined: keys, totalDocsExamined: docs))) do
29
- {
30
- n_returned: n,
31
- execution_time_millis: msec,
32
- total_keys_examined: keys,
33
- total_docs_examined: docs
34
- }
35
- end
36
- end
37
- rescue PatternMatch::NoMatchingPatternError
38
- nil
39
- end
40
- end
41
- end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MongoClarify
4
- class InvestigateRuby2_7
4
+ class Investigate
5
5
  def initialize(explain)
6
6
  @explain = explain
7
7
  end
@@ -13,7 +13,7 @@ module MongoClarify
13
13
  in { queryPlanner: { winningPlan: { stage: 'FETCH', inputStage: { stage: 'IXSCAN', indexName: index_name } } } }
14
14
  "Index Scan (Index Name: #{index_name})"
15
15
  else
16
- 'Unknown'
16
+ nil
17
17
  end
18
18
  end
19
19
 
@@ -21,6 +21,7 @@ module MongoClarify
21
21
  case @explain
22
22
  in { executionStats: { nReturned: n, executionTimeMillis: msec, totalKeysExamined: keys, totalDocsExamined: docs } }
23
23
  else
24
+ return
24
25
  end
25
26
  { n_returned: n, execution_time_millis: msec, total_keys_examined: keys, total_docs_examined: docs }
26
27
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pattern-match/experimental'
4
+
5
+ module MongoClarify
6
+ class Investigate
7
+ using PatternMatch
8
+
9
+ def initialize(explain)
10
+ @explain = explain
11
+ end
12
+
13
+ def operation_method
14
+ match(@explain) do
15
+ with(Hash.(queryPlanner: Hash.(winningPlan: Hash.(stage: 'COLLSCAN')))) do
16
+ 'Collection Scan'
17
+ end
18
+ with(Hash.(queryPlanner: Hash.(winningPlan: Hash.(stage: 'FETCH', inputStage: Hash.(stage: 'IXSCAN', indexName: index_name))))) do
19
+ "Index Scan (Index Name: #{index_name})"
20
+ end
21
+ end
22
+ rescue PatternMatch::NoMatchingPatternError
23
+ nil
24
+ end
25
+
26
+ def execution_stats
27
+ match(@explain) do
28
+ with(Hash.(executionStats: Hash.(nReturned: n, executionTimeMillis: msec, totalKeysExamined: keys, totalDocsExamined: docs))) do
29
+ {
30
+ n_returned: n,
31
+ execution_time_millis: msec,
32
+ total_keys_examined: keys,
33
+ total_docs_examined: docs
34
+ }
35
+ end
36
+ end
37
+ rescue PatternMatch::NoMatchingPatternError
38
+ nil
39
+ end
40
+ end
41
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MongoClarify
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_clarify
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
  - morihirok
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-29 00:00:00.000000000 Z
11
+ date: 2019-10-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pattern-match
@@ -90,7 +90,8 @@ files:
90
90
  - exe/mongo_clarify
91
91
  - lib/mongo_clarify.rb
92
92
  - lib/mongo_clarify/investigate.rb
93
- - lib/mongo_clarify/investigate_ruby2_7.rb
93
+ - lib/mongo_clarify/investigate_with_pattern_matching.rb
94
+ - lib/mongo_clarify/investigate_without_pattern_matching.rb
94
95
  - lib/mongo_clarify/output.rb
95
96
  - lib/mongo_clarify/version.rb
96
97
  - mongo_clarify.gemspec
@@ -113,8 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  - !ruby/object:Gem::Version
114
115
  version: '0'
115
116
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.7.6
117
+ rubygems_version: 3.0.3
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Make MongoDB's explain results more understandable.