qo 0.1.8 → 0.1.9

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
- SHA1:
3
- metadata.gz: 594012163edefd5fedd3266382aca2efddd10432
4
- data.tar.gz: aa376733835f2fa1ce1abbe16018e2b2344f96ad
2
+ SHA256:
3
+ metadata.gz: 19be813c32add1fbe376c08a27533e43ca87254aca1b5bd73f146df70408d833
4
+ data.tar.gz: 7876f56688b5a11d0821f368bfbd612c56ecb5e08fdf2dccca6e030d56449a2c
5
5
  SHA512:
6
- metadata.gz: 6db60b6de5c5ab900e6b144ddc3c9ed4eee275781017cc3f36580f1f904b2287ce734378d9d3dc6e0412ac4f62f37166c001c07235ae519373efbb99282c75f6
7
- data.tar.gz: 93404e15e4db2dee338f64769e035d2c33f5945e6f1a2c2d53240d5019c2f11b9eceb08af13dcfdb9a540fbe39aa935fb201f08ef8638c7c5f447ea722456923
6
+ metadata.gz: a13e4be4641782a63e1208053c7e35ee77c665ee5eff80b78af54a43f7e4254bd808a4dc6420c9c7e8bdb8c1070c36134f7192934c8c43c7169be0db81c051c8
7
+ data.tar.gz: 2098317ea5c317a86107902504787a4d47aec8e69e204490bbf72438d2f210a9bd86377b0895672e33bdf4ab8700fc5f26fade3e871d31bd329e0e86050f6711
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
 
14
14
  # built gems
15
15
  *.gem
16
+ repro_cases/*.rb
data/README.md CHANGED
@@ -490,7 +490,7 @@ There are a few functions added for convenience, and it should be noted that bec
490
490
 
491
491
  #### 6.1 - Dig
492
492
 
493
- Dig is used to get in deep at a nested hash value. It takes a dot-path and a `===` respondant matcher:
493
+ Dig is used to get in deep at a nested hash value. It takes a dot-path and a `===` respondent matcher:
494
494
 
495
495
  ```ruby
496
496
  Qo.dig('a.b.c', Qo.or(1..5, 15..25)) === {a: {b: {c: 1}}}
@@ -585,9 +585,9 @@ hosts.select(&Qo[IPAddr.new('192.168.1.1/8')])
585
585
  => [["192.168.1.1", "(Router)"], ["192.168.1.2", "(My Computer)"]]
586
586
  ```
587
587
 
588
- ##### 5.2.2 - `du`
588
+ ##### 5.2.2 - `df`
589
589
 
590
- The nice thing about Unix style commands is that they use headers, which means CSV can get a hold of them for some good formatting. It's also smart enough to deal with space seperators that may vary in length:
590
+ The nice thing about Unix style commands is that they use headers, which means CSV can get a hold of them for some good formatting. It's also smart enough to deal with space separators that may vary in length:
591
591
 
592
592
  ```ruby
593
593
  rows = CSV.new(`df -h`, col_sep: " ", headers: true).read.map(&:to_h)
data/lib/qo/matcher.rb CHANGED
@@ -42,8 +42,8 @@ module Qo
42
42
  # Array -> Bool # Tuple match against targets index
43
43
  # Object -> Bool # Boolean public send
44
44
  private def match_against_array(matchers)
45
- -> match_target {
46
- return true if matchers == match_target
45
+ Proc.new { |match_target|
46
+ next true if matchers == match_target
47
47
 
48
48
  match_target.is_a?(::Array) ?
49
49
  match_with(matchers.each_with_index, array_against_array_matcher(match_target)) :
@@ -61,8 +61,8 @@ module Qo
61
61
  # Hash -> Bool # Value matching against similar keys, will attempt to coerce to_s because JSON
62
62
  # Object -> Bool # Uses keys as methods with public send to `===` match against the value
63
63
  private def match_against_hash(matchers)
64
- -> match_target {
65
- return true if matchers == match_target
64
+ Proc.new { |match_target|
65
+ next true if matchers == match_target
66
66
 
67
67
  match_target.is_a?(::Hash) ?
68
68
  match_with(matchers, hash_against_hash_matcher(match_target)) :
@@ -91,7 +91,7 @@ module Qo
91
91
  # @return [Proc]
92
92
  # Any -> Int -> Bool # Match against wildcard or same position in target array
93
93
  private def array_against_array_matcher(match_target)
94
- -> matcher, i {
94
+ Proc.new { |matcher, i|
95
95
  wildcard_match(matcher) ||
96
96
  case_match(match_target[i], matcher) ||
97
97
  method_matches?(match_target[i], matcher)
@@ -105,7 +105,7 @@ module Qo
105
105
  # @return [Proc]
106
106
  # String | Symbol -> Bool # Match against wildcard or boolean return of a predicate method
107
107
  private def array_against_object_matcher(match_target)
108
- -> matcher {
108
+ Proc.new { |matcher|
109
109
  wildcard_match(matcher) ||
110
110
  case_match(match_target, matcher) ||
111
111
  method_matches?(match_target, matcher)
@@ -119,12 +119,12 @@ module Qo
119
119
  # @return [Proc]
120
120
  # Any -> Any -> Bool # Matches against wildcard or a key and value. Coerces key to_s if no matches for JSON.
121
121
  private def hash_against_hash_matcher(match_target)
122
- -> match_key, match_value {
123
- return false unless match_target.key?(match_key)
122
+ Proc.new { |(match_key, match_value)|
123
+ next false unless match_target.key?(match_key)
124
124
 
125
125
  # If both the match value and target are hashes, descend if the key exists
126
126
  if match_value.is_a?(Hash) && match_target.is_a?(Hash)
127
- return match_against_hash(match_value)[match_target[match_key]]
127
+ next match_against_hash(match_value)[match_target[match_key]]
128
128
  end
129
129
 
130
130
  wildcard_match(match_value) ||
@@ -146,8 +146,8 @@ module Qo
146
146
  # @return [Proc]
147
147
  # Any -> Any -> Bool # Matches against wildcard or match value versus the public send return of the target
148
148
  private def hash_against_object_matcher(match_target)
149
- -> match_key, match_value {
150
- return false unless match_target.respond_to?(match_key)
149
+ Proc.new { |(match_key, match_value)|
150
+ next false unless match_target.respond_to?(match_key)
151
151
 
152
152
  wildcard_match(match_value) ||
153
153
  case_match(method_send(match_target, match_key), match_value) ||
data/lib/qo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qo
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
@@ -3,58 +3,58 @@ Array * Array - Literal
3
3
  =======================
4
4
 
5
5
  Warming up --------------------------------------
6
- Vanilla 289.298k i/100ms
7
- Qo.and 39.896k i/100ms
6
+ Vanilla 255.131k i/100ms
7
+ Qo.and 36.805k i/100ms
8
8
  Calculating -------------------------------------
9
- Vanilla 9.620M (± 2.4%) i/s - 48.313M in 5.025188s
10
- Qo.and 456.077k2.3%) i/s - 2.314M in 5.076462s
9
+ Vanilla 8.462M (± 2.6%) i/s - 42.352M in 5.008310s
10
+ Qo.and 454.565k1.8%) i/s - 2.282M in 5.021661s
11
11
 
12
12
  Comparison:
13
- Vanilla: 9620049.8 i/s
14
- Qo.and: 456077.4 i/s - 21.09x slower
13
+ Vanilla: 8462330.9 i/s
14
+ Qo.and: 454565.2 i/s - 18.62x slower
15
15
 
16
16
 
17
17
  Array * Array - Index pattern match
18
18
  ===================================
19
19
 
20
20
  Warming up --------------------------------------
21
- Vanilla 46.056k i/100ms
22
- Qo.and 14.514k i/100ms
21
+ Vanilla 46.834k i/100ms
22
+ Qo.and 13.827k i/100ms
23
23
  Calculating -------------------------------------
24
- Vanilla 528.961k3.0%) i/s - 2.671M in 5.054671s
25
- Qo.and 154.299k1.9%) i/s - 783.756k in 5.081304s
24
+ Vanilla 551.426k1.6%) i/s - 2.763M in 5.012355s
25
+ Qo.and 146.762k2.3%) i/s - 746.658k in 5.090187s
26
26
 
27
27
  Comparison:
28
- Vanilla: 528961.3 i/s
29
- Qo.and: 154299.4 i/s - 3.43x slower
28
+ Vanilla: 551426.2 i/s
29
+ Qo.and: 146762.1 i/s - 3.76x slower
30
30
 
31
31
 
32
32
  Array * Object - Predicate match
33
33
  ================================
34
34
 
35
35
  Warming up --------------------------------------
36
- Vanilla 148.876k i/100ms
37
- Qo.and 19.598k i/100ms
36
+ Vanilla 133.668k i/100ms
37
+ Qo.and 18.746k i/100ms
38
38
  Calculating -------------------------------------
39
- Vanilla 2.385M (± 1.7%) i/s - 12.059M in 5.058028s
40
- Qo.and 211.780k1.4%) i/s - 1.078M in 5.090600s
39
+ Vanilla 2.198M3.1%) i/s - 11.094M in 5.053049s
40
+ Qo.and 208.117k5.4%) i/s - 1.050M in 5.059694s
41
41
 
42
42
  Comparison:
43
- Vanilla: 2384846.4 i/s
44
- Qo.and: 211780.0 i/s - 11.26x slower
43
+ Vanilla: 2197719.6 i/s
44
+ Qo.and: 208116.8 i/s - 10.56x slower
45
45
 
46
46
 
47
47
  Array * Array - Select index pattern match
48
48
  ==========================================
49
49
 
50
50
  Warming up --------------------------------------
51
- Vanilla 12.366k i/100ms
52
- Qo.and 20.112k i/100ms
51
+ Vanilla 13.222k i/100ms
52
+ Qo.and 20.029k i/100ms
53
53
  Calculating -------------------------------------
54
- Vanilla 128.645k2.1%) i/s - 643.032k in 5.000638s
55
- Qo.and 207.792k7.2%) i/s - 1.046M in 5.061963s
54
+ Vanilla 140.225k3.0%) i/s - 700.766k in 5.002204s
55
+ Qo.and 217.401k8.2%) i/s - 1.082M in 5.036013s
56
56
 
57
57
  Comparison:
58
- Qo.and: 207792.4 i/s
59
- Vanilla: 128645.0 i/s - 1.62x slower
58
+ Qo.and: 217401.0 i/s
59
+ Vanilla: 140224.8 i/s - 1.55x slower
60
60
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Weaver
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  version: '0'
143
143
  requirements: []
144
144
  rubyforge_project:
145
- rubygems_version: 2.5.2
145
+ rubygems_version: 2.7.6
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: Qo is a querying library for Ruby pattern matching