qo 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,9 +100,9 @@
100
100
  </div>
101
101
 
102
102
  <div id="footer">
103
- Generated on Sun Apr 15 20:29:44 2018 by
103
+ Generated on Sun Aug 5 20:52:09 2018 by
104
104
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
- 0.9.12 (ruby-2.4.4).
105
+ 0.9.12 (ruby-2.5.1).
106
106
  </div>
107
107
 
108
108
  </div>
data/img/qo_logo.png CHANGED
Binary file
data/lib/qo.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # Wildcard matching
2
+ require 'any'
3
+
1
4
  require "qo/version"
2
5
 
3
6
  # Matchers
@@ -18,8 +21,6 @@ require 'qo/exceptions'
18
21
  require 'qo/public_api'
19
22
 
20
23
  module Qo
21
- WILDCARD_MATCH = :*
22
-
23
24
  extend Qo::Exceptions
24
25
  extend Qo::Helpers
25
26
  extend Qo::PublicApi
@@ -76,7 +76,6 @@ module Qo
76
76
  #
77
77
  # @return [Boolean] Match status
78
78
  private def match_value?(target, matcher)
79
- wildcard_match?(matcher) ||
80
79
  case_match?(target, matcher) ||
81
80
  method_matches?(target, matcher)
82
81
  end
@@ -66,18 +66,6 @@ module Qo
66
66
  collection.all?(&fn)
67
67
  end
68
68
 
69
- # Wraps wildcard in case we want to do anything fun with it later
70
- #
71
- # @param value [Any] Value to test against the wild card
72
- #
73
- # @note The rescue is because some classes override `==` to do silly things,
74
- # like IPAddr, and I kinda want to use that.
75
- #
76
- # @return [Boolean]
77
- private def wildcard_match?(value)
78
- value == WILDCARD_MATCH rescue false
79
- end
80
-
81
69
  # Wraps a case equality statement to make it a bit easier to read. The
82
70
  # typical left bias of `===` can be confusing reading down a page, so
83
71
  # more of a clarity thing than anything. Also makes for nicer stack traces.
@@ -65,7 +65,6 @@ module Qo
65
65
  # @return [Boolean] Match status
66
66
  private def match_hash_value?(target, match_key, matcher)
67
67
  return false unless target.key?(match_key)
68
- return true if wildcard_match?(matcher)
69
68
 
70
69
  return hash_recurse(target[match_key], matcher) if target.is_a?(Hash) && matcher.is_a?(Hash)
71
70
 
@@ -83,7 +82,6 @@ module Qo
83
82
  private def match_object_value?(target, match_property, matcher)
84
83
  return false unless target.respond_to?(match_property)
85
84
 
86
- wildcard_match?(matcher) ||
87
85
  hash_method_case_match?(target, match_property, matcher)
88
86
  end
89
87
 
data/lib/qo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Qo
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -1,4 +1,4 @@
1
- Running on Qo v0.3.0 at rev 77eb2544c41b33361a561178b145d33fa2409bde
1
+ Running on Qo v0.4.0 at rev 96607b76bba3fea60d46e118a67fa5b4c76d5c72
2
2
  - Ruby ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
3
3
 
4
4
  Array * Array - Literal
@@ -8,15 +8,15 @@ Vanilla result: true
8
8
  Qo.and result: true
9
9
 
10
10
  Warming up --------------------------------------
11
- Vanilla 275.791k i/100ms
12
- Qo.and 77.679k i/100ms
11
+ Vanilla 275.772k i/100ms
12
+ Qo.and 77.013k i/100ms
13
13
  Calculating -------------------------------------
14
- Vanilla 8.805M1.6%) i/s - 44.127M in 5.012793s
15
- Qo.and 987.041k2.8%) i/s - 4.971M in 5.040741s
14
+ Vanilla 8.911M2.0%) i/s - 44.675M in 5.015740s
15
+ Qo.and 992.994k1.7%) i/s - 5.006M in 5.042624s
16
16
 
17
17
  Comparison:
18
- Vanilla: 8805260.8 i/s
19
- Qo.and: 987041.0 i/s - 8.92x slower
18
+ Vanilla: 8910560.1 i/s
19
+ Qo.and: 992994.3 i/s - 8.97x slower
20
20
 
21
21
 
22
22
  Array * Array - Index pattern match
@@ -26,15 +26,15 @@ Vanilla result: true
26
26
  Qo.and result: true
27
27
 
28
28
  Warming up --------------------------------------
29
- Vanilla 45.347k i/100ms
30
- Qo.and 21.225k i/100ms
29
+ Vanilla 48.662k i/100ms
30
+ Qo.and 22.868k i/100ms
31
31
  Calculating -------------------------------------
32
- Vanilla 550.096k2.4%) i/s - 2.766M in 5.031463s
33
- Qo.and 226.391k4.2%) i/s - 1.146M in 5.072495s
32
+ Vanilla 569.942k1.6%) i/s - 2.871M in 5.038819s
33
+ Qo.and 247.240k2.8%) i/s - 1.258M in 5.091282s
34
34
 
35
35
  Comparison:
36
- Vanilla: 550096.4 i/s
37
- Qo.and: 226391.4 i/s - 2.43x slower
36
+ Vanilla: 569942.4 i/s
37
+ Qo.and: 247239.9 i/s - 2.31x slower
38
38
 
39
39
 
40
40
  Array * Object - Predicate match
@@ -44,15 +44,15 @@ Vanilla result: false
44
44
  Qo.and result: false
45
45
 
46
46
  Warming up --------------------------------------
47
- Vanilla 139.508k i/100ms
48
- Qo.and 27.451k i/100ms
47
+ Vanilla 142.790k i/100ms
48
+ Qo.and 28.458k i/100ms
49
49
  Calculating -------------------------------------
50
- Vanilla 2.148M3.3%) i/s - 10.742M in 5.007009s
51
- Qo.and 303.118k2.0%) i/s - 1.537M in 5.073596s
50
+ Vanilla 2.251M1.8%) i/s - 11.280M in 5.012252s
51
+ Qo.and 315.757k1.8%) i/s - 1.594M in 5.048759s
52
52
 
53
53
  Comparison:
54
- Vanilla: 2147916.4 i/s
55
- Qo.and: 303118.1 i/s - 7.09x slower
54
+ Vanilla: 2251336.4 i/s
55
+ Qo.and: 315757.2 i/s - 7.13x slower
56
56
 
57
57
 
58
58
  Array * Array - Select index pattern match
@@ -62,15 +62,15 @@ Vanilla result: [["Robert", 22], ["Roberta", 22]]
62
62
  Qo.and result: [["Robert", 22], ["Roberta", 22]]
63
63
 
64
64
  Warming up --------------------------------------
65
- Vanilla 12.651k i/100ms
66
- Qo.and 7.024k i/100ms
65
+ Vanilla 14.162k i/100ms
66
+ Qo.and 7.559k i/100ms
67
67
  Calculating -------------------------------------
68
- Vanilla 141.337k8.3%) i/s - 708.456k in 5.067441s
69
- Qo.and 73.799k2.9%) i/s - 372.272k in 5.048946s
68
+ Vanilla 150.748k1.7%) i/s - 764.748k in 5.074423s
69
+ Qo.and 78.082k1.6%) i/s - 393.068k in 5.035396s
70
70
 
71
71
  Comparison:
72
- Vanilla: 141336.5 i/s
73
- Qo.and: 73799.3 i/s - 1.92x slower
72
+ Vanilla: 150748.3 i/s
73
+ Qo.and: 78082.2 i/s - 1.93x slower
74
74
 
75
75
 
76
76
  Hash * Hash - Hash intersection
@@ -80,15 +80,15 @@ Vanilla result: [{:name=>"Robert", :age=>22}, {:name=>"Roberta", :age=>22}]
80
80
  Qo.and result: [{:name=>"Robert", :age=>22}, {:name=>"Roberta", :age=>22}]
81
81
 
82
82
  Warming up --------------------------------------
83
- Vanilla 34.600k i/100ms
84
- Qo.and 4.851k i/100ms
83
+ Vanilla 35.977k i/100ms
84
+ Qo.and 5.112k i/100ms
85
85
  Calculating -------------------------------------
86
- Vanilla 392.298k2.6%) i/s - 1.972M in 5.030828s
87
- Qo.and 48.213k4.8%) i/s - 242.550k in 5.043068s
86
+ Vanilla 410.483k1.3%) i/s - 2.087M in 5.084305s
87
+ Qo.and 51.860k1.6%) i/s - 260.712k in 5.028458s
88
88
 
89
89
  Comparison:
90
- Vanilla: 392298.2 i/s
91
- Qo.and: 48213.1 i/s - 8.14x slower
90
+ Vanilla: 410483.2 i/s
91
+ Qo.and: 51860.4 i/s - 7.92x slower
92
92
 
93
93
 
94
94
  Hash * Object - Property match
@@ -98,13 +98,13 @@ Vanilla result: [#<struct Person name="Robert", age=22>, #<struct Person name="R
98
98
  Qo.and result: [#<struct Person name="Robert", age=22>, #<struct Person name="Roberta", age=22>]
99
99
 
100
100
  Warming up --------------------------------------
101
- Vanilla 32.783k i/100ms
102
- Qo.and 4.422k i/100ms
101
+ Vanilla 36.219k i/100ms
102
+ Qo.and 5.415k i/100ms
103
103
  Calculating -------------------------------------
104
- Vanilla 361.140k9.7%) i/s - 1.803M in 5.053763s
105
- Qo.and 46.667k10.8%) i/s - 229.944k in 5.002258s
104
+ Vanilla 412.314k1.3%) i/s - 2.064M in 5.007920s
105
+ Qo.and 55.712k 1.6%) i/s - 281.580k in 5.055626s
106
106
 
107
107
  Comparison:
108
- Vanilla: 361140.4 i/s
109
- Qo.and: 46667.1 i/s - 7.74x slower
108
+ Vanilla: 412313.9 i/s
109
+ Qo.and: 55711.7 i/s - 7.40x slower
110
110
 
data/qo.gemspec CHANGED
@@ -28,4 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "benchmark-ips"
29
29
  spec.add_development_dependency "yard"
30
30
  spec.add_development_dependency "redcarpet"
31
+
32
+ spec.add_runtime_dependency "any", '0.1.0'
31
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Weaver
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-26 00:00:00.000000000 Z
11
+ date: 2018-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: any
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 0.1.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 0.1.0
125
139
  description:
126
140
  email:
127
141
  - keystonelemur@gmail.com
@@ -145,6 +159,7 @@ files:
145
159
  - docs/.gitkeep
146
160
  - docs/Qo.html
147
161
  - docs/Qo/Exceptions.html
162
+ - docs/Qo/Exceptions/MultipleElseClauses.html
148
163
  - docs/Qo/Exceptions/MultipleMatchersProvided.html
149
164
  - docs/Qo/Exceptions/NoMatchersProvided.html
150
165
  - docs/Qo/Exceptions/NotAllGuardMatchersProvided.html
@@ -155,6 +170,7 @@ files:
155
170
  - docs/Qo/Matchers/GuardBlockMatcher.html
156
171
  - docs/Qo/Matchers/HashMatcher.html
157
172
  - docs/Qo/Matchers/PatternMatch.html
173
+ - docs/Qo/Matchers/PatternMatchBlock.html
158
174
  - docs/Qo/PublicApi.html
159
175
  - docs/_config.yml
160
176
  - docs/_index.html
@@ -166,6 +182,7 @@ files:
166
182
  - docs/file_list.html
167
183
  - docs/frames.html
168
184
  - docs/img/qo_logo.png
185
+ - docs/img/whoa_lemur.png
169
186
  - docs/index.html
170
187
  - docs/js/app.js
171
188
  - docs/js/full_list.js