qo 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +40 -84
- data/docs/Qo.html +4 -9
- data/docs/Qo/Exceptions.html +3 -3
- data/docs/Qo/Exceptions/MultipleElseClauses.html +257 -0
- data/docs/Qo/Exceptions/MultipleMatchersProvided.html +2 -2
- data/docs/Qo/Exceptions/NoMatchersProvided.html +2 -2
- data/docs/Qo/Exceptions/NotAllGuardMatchersProvided.html +2 -2
- data/docs/Qo/Helpers.html +2 -2
- data/docs/Qo/Matchers.html +4 -4
- data/docs/Qo/Matchers/ArrayMatcher.html +2 -2
- data/docs/Qo/Matchers/BaseMatcher.html +2 -2
- data/docs/Qo/Matchers/GuardBlockMatcher.html +2 -2
- data/docs/Qo/Matchers/HashMatcher.html +2 -2
- data/docs/Qo/Matchers/PatternMatch.html +2 -2
- data/docs/Qo/Matchers/PatternMatchBlock.html +832 -0
- data/docs/Qo/PublicApi.html +77 -19
- data/docs/_index.html +16 -2
- data/docs/class_list.html +1 -1
- data/docs/file.README.html +92 -78
- data/docs/img/qo_logo.png +0 -0
- data/docs/img/whoa_lemur.png +0 -0
- data/docs/index.html +92 -78
- data/docs/method_list.html +77 -29
- data/docs/top-level-namespace.html +2 -2
- data/img/qo_logo.png +0 -0
- data/lib/qo.rb +3 -2
- data/lib/qo/matchers/array_matcher.rb +0 -1
- data/lib/qo/matchers/base_matcher.rb +0 -12
- data/lib/qo/matchers/hash_matcher.rb +0 -2
- data/lib/qo/version.rb +1 -1
- data/performance_report.txt +37 -37
- data/qo.gemspec +2 -0
- metadata +19 -2
@@ -100,9 +100,9 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on Sun
|
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.
|
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
|
@@ -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
data/performance_report.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Running on Qo v0.
|
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.
|
12
|
-
Qo.and 77.
|
11
|
+
Vanilla 275.772k i/100ms
|
12
|
+
Qo.and 77.013k i/100ms
|
13
13
|
Calculating -------------------------------------
|
14
|
-
Vanilla 8.
|
15
|
-
Qo.and
|
14
|
+
Vanilla 8.911M (± 2.0%) i/s - 44.675M in 5.015740s
|
15
|
+
Qo.and 992.994k (± 1.7%) i/s - 5.006M in 5.042624s
|
16
16
|
|
17
17
|
Comparison:
|
18
|
-
Vanilla:
|
19
|
-
Qo.and:
|
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
|
30
|
-
Qo.and
|
29
|
+
Vanilla 48.662k i/100ms
|
30
|
+
Qo.and 22.868k i/100ms
|
31
31
|
Calculating -------------------------------------
|
32
|
-
Vanilla
|
33
|
-
Qo.and
|
32
|
+
Vanilla 569.942k (± 1.6%) i/s - 2.871M in 5.038819s
|
33
|
+
Qo.and 247.240k (± 2.8%) i/s - 1.258M in 5.091282s
|
34
34
|
|
35
35
|
Comparison:
|
36
|
-
Vanilla:
|
37
|
-
Qo.and:
|
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
|
48
|
-
Qo.and
|
47
|
+
Vanilla 142.790k i/100ms
|
48
|
+
Qo.and 28.458k i/100ms
|
49
49
|
Calculating -------------------------------------
|
50
|
-
Vanilla 2.
|
51
|
-
Qo.and
|
50
|
+
Vanilla 2.251M (± 1.8%) i/s - 11.280M in 5.012252s
|
51
|
+
Qo.and 315.757k (± 1.8%) i/s - 1.594M in 5.048759s
|
52
52
|
|
53
53
|
Comparison:
|
54
|
-
Vanilla:
|
55
|
-
Qo.and:
|
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
|
66
|
-
Qo.and 7.
|
65
|
+
Vanilla 14.162k i/100ms
|
66
|
+
Qo.and 7.559k i/100ms
|
67
67
|
Calculating -------------------------------------
|
68
|
-
Vanilla
|
69
|
-
Qo.and
|
68
|
+
Vanilla 150.748k (± 1.7%) i/s - 764.748k in 5.074423s
|
69
|
+
Qo.and 78.082k (± 1.6%) i/s - 393.068k in 5.035396s
|
70
70
|
|
71
71
|
Comparison:
|
72
|
-
Vanilla:
|
73
|
-
Qo.and:
|
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
|
84
|
-
Qo.and
|
83
|
+
Vanilla 35.977k i/100ms
|
84
|
+
Qo.and 5.112k i/100ms
|
85
85
|
Calculating -------------------------------------
|
86
|
-
Vanilla
|
87
|
-
Qo.and
|
86
|
+
Vanilla 410.483k (± 1.3%) i/s - 2.087M in 5.084305s
|
87
|
+
Qo.and 51.860k (± 1.6%) i/s - 260.712k in 5.028458s
|
88
88
|
|
89
89
|
Comparison:
|
90
|
-
Vanilla:
|
91
|
-
Qo.and:
|
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
|
102
|
-
Qo.and
|
101
|
+
Vanilla 36.219k i/100ms
|
102
|
+
Qo.and 5.415k i/100ms
|
103
103
|
Calculating -------------------------------------
|
104
|
-
Vanilla
|
105
|
-
Qo.and
|
104
|
+
Vanilla 412.314k (± 1.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:
|
109
|
-
Qo.and:
|
108
|
+
Vanilla: 412313.9 i/s
|
109
|
+
Qo.and: 55711.7 i/s - 7.40x slower
|
110
110
|
|
data/qo.gemspec
CHANGED
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.
|
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-
|
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
|