check_please 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/check_please.rb +12 -11
- data/lib/check_please/comparison.rb +1 -1
- data/lib/check_please/diffs.rb +5 -0
- data/lib/check_please/path.rb +8 -7
- data/lib/check_please/path_segment.rb +9 -23
- data/lib/check_please/path_segment_matcher.rb +44 -0
- data/lib/check_please/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bd44bf6bcc771bf5d0179fa562f5ddff80f0ed4bb2420ede197d60007d8057d
|
4
|
+
data.tar.gz: 7c0725d4b8cf3d03d7c8ffd2e8df51a8e5a1616e86c4cad02695dca73921340f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0add2fc010b651ae30a1309c3df9b26c1280e40fc7c45b5214ad22922fb3103c533f0f0ebbf26d46c3dbfb97b09d36ded3c9a419818039437aed2d198ced4669
|
7
|
+
data.tar.gz: 88611e7acca8a803f69e48ddefddfbc208faeae359fc3417b0f0faa0aae11e853a45891919290abd062f503558f0caedc3b05fa037397f3b4142b11a3905245c
|
data/Gemfile.lock
CHANGED
data/lib/check_please.rb
CHANGED
@@ -7,17 +7,18 @@ require "check_please/error"
|
|
7
7
|
require "check_please/version"
|
8
8
|
|
9
9
|
module CheckPlease
|
10
|
-
autoload :Reification,
|
11
|
-
autoload :CLI,
|
12
|
-
autoload :Comparison,
|
13
|
-
autoload :Diff,
|
14
|
-
autoload :Diffs,
|
15
|
-
autoload :Flag,
|
16
|
-
autoload :Flags,
|
17
|
-
autoload :Path,
|
18
|
-
autoload :PathSegment,
|
19
|
-
autoload :
|
20
|
-
autoload :
|
10
|
+
autoload :Reification, "check_please/reification"
|
11
|
+
autoload :CLI, "check_please/cli"
|
12
|
+
autoload :Comparison, "check_please/comparison"
|
13
|
+
autoload :Diff, "check_please/diff"
|
14
|
+
autoload :Diffs, "check_please/diffs"
|
15
|
+
autoload :Flag, "check_please/flag"
|
16
|
+
autoload :Flags, "check_please/flags"
|
17
|
+
autoload :Path, "check_please/path"
|
18
|
+
autoload :PathSegment, "check_please/path_segment"
|
19
|
+
autoload :PathSegmentMatcher, "check_please/path_segment_matcher"
|
20
|
+
autoload :Printers, "check_please/printers"
|
21
|
+
autoload :Refinements, "check_please/refinements"
|
21
22
|
end
|
22
23
|
|
23
24
|
|
data/lib/check_please/diffs.rb
CHANGED
@@ -47,6 +47,11 @@ module CheckPlease
|
|
47
47
|
@list.map(&:attributes)
|
48
48
|
end
|
49
49
|
|
50
|
+
def filter_by_flags(flags)
|
51
|
+
new_list = @list.reject { |diff| Path.new(diff.path).excluded?(flags) }
|
52
|
+
self.class.new(new_list, flags: flags)
|
53
|
+
end
|
54
|
+
|
50
55
|
def to_s(flags = {})
|
51
56
|
CheckPlease::Printers.render(self, flags)
|
52
57
|
end
|
data/lib/check_please/path.rb
CHANGED
@@ -17,7 +17,12 @@ module CheckPlease
|
|
17
17
|
def initialize(name_or_segments = [])
|
18
18
|
case name_or_segments
|
19
19
|
when String, Symbol, Numeric, nil
|
20
|
-
|
20
|
+
string = name_or_segments.to_s
|
21
|
+
if string =~ %r(//)
|
22
|
+
raise InvalidPath, "paths cannot have empty segments"
|
23
|
+
end
|
24
|
+
|
25
|
+
names = string.split(SEPARATOR)
|
21
26
|
names.shift until names.empty? || names.first =~ /\S/
|
22
27
|
segments = PathSegment.reify(names)
|
23
28
|
when Array
|
@@ -26,10 +31,6 @@ module CheckPlease
|
|
26
31
|
raise InvalidPath, "not sure what to do with #{name_or_segments.inspect}"
|
27
32
|
end
|
28
33
|
|
29
|
-
if segments.any?(&:empty?)
|
30
|
-
raise InvalidPath, "#{self.class.name} cannot contain empty segments"
|
31
|
-
end
|
32
|
-
|
33
34
|
@segments = Array(segments)
|
34
35
|
|
35
36
|
@to_s = SEPARATOR + @segments.join(SEPARATOR)
|
@@ -124,7 +125,7 @@ module CheckPlease
|
|
124
125
|
# (as of this writing, this should never actually happen, but I'm being thorough)
|
125
126
|
def ancestor_on_list?(paths)
|
126
127
|
paths.any? { |path|
|
127
|
-
ancestors.any? { |ancestor| ancestor
|
128
|
+
ancestors.any? { |ancestor| ancestor.match?(path) }
|
128
129
|
}
|
129
130
|
end
|
130
131
|
|
@@ -153,7 +154,7 @@ module CheckPlease
|
|
153
154
|
|
154
155
|
# O(n) check to see if the path itself is on a list
|
155
156
|
def self_on_list?(paths)
|
156
|
-
paths.any? { |path| self
|
157
|
+
paths.any? { |path| self.match?(path) }
|
157
158
|
end
|
158
159
|
|
159
160
|
def too_deep?(flags)
|
@@ -30,19 +30,16 @@ module CheckPlease
|
|
30
30
|
|
31
31
|
def initialize(name = nil)
|
32
32
|
@name = name.to_s.strip
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
|
34
|
+
case @name
|
35
|
+
when "", /\s/ # blank or has any whitespace
|
36
|
+
raise InvalidPathSegment, "#{name.inspect} is not a valid #{self.class} name"
|
37
37
|
end
|
38
|
+
|
38
39
|
parse_key_and_value
|
39
40
|
freeze
|
40
41
|
end
|
41
42
|
|
42
|
-
def empty?
|
43
|
-
name.empty?
|
44
|
-
end
|
45
|
-
|
46
43
|
def key_expr?
|
47
44
|
name.match?(KEY_EXPR)
|
48
45
|
end
|
@@ -52,23 +49,12 @@ module CheckPlease
|
|
52
49
|
end
|
53
50
|
|
54
51
|
def match?(other_segment_or_string)
|
55
|
-
other =
|
56
|
-
|
57
|
-
match_types = [ self.match_type, other.match_type ]
|
58
|
-
case match_types
|
59
|
-
when [ :plain, :plain ] ; self.name == other.name
|
60
|
-
when [ :key, :key_value ] ; self.key == other.key
|
61
|
-
when [ :key_value, :key ] ; self.key == other.key
|
62
|
-
else ; false
|
63
|
-
end
|
52
|
+
other = reify(other_segment_or_string)
|
53
|
+
PathSegmentMatcher.call(self, other)
|
64
54
|
end
|
65
55
|
|
66
|
-
|
67
|
-
|
68
|
-
def match_type
|
69
|
-
return :key if key_expr?
|
70
|
-
return :key_value if key_val_expr?
|
71
|
-
:plain
|
56
|
+
def splat?
|
57
|
+
name == '*'
|
72
58
|
end
|
73
59
|
|
74
60
|
private
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module CheckPlease
|
2
|
+
|
3
|
+
class PathSegmentMatcher
|
4
|
+
def self.call(a,b)
|
5
|
+
new(a,b).call
|
6
|
+
end
|
7
|
+
|
8
|
+
attr_reader :a, :b, :types
|
9
|
+
def initialize(a, b)
|
10
|
+
@a, @b = a, b
|
11
|
+
@types = [ _type(a), _type(b) ].sort
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
return true if either?(:splat)
|
16
|
+
return a.name == b.name if both?(:plain)
|
17
|
+
return a.key == b.key if key_and_key_value?
|
18
|
+
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def _type(x)
|
25
|
+
return :splat if x.splat?
|
26
|
+
return :key if x.key_expr?
|
27
|
+
return :key_value if x.key_val_expr?
|
28
|
+
:plain
|
29
|
+
end
|
30
|
+
|
31
|
+
def both?(type)
|
32
|
+
types.uniq == [type]
|
33
|
+
end
|
34
|
+
|
35
|
+
def either?(type)
|
36
|
+
types.include?(type)
|
37
|
+
end
|
38
|
+
|
39
|
+
def key_and_key_value?
|
40
|
+
types == [ :key, :key_value ]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
data/lib/check_please/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module CheckPlease
|
2
2
|
# NOTE: 'check_please_rspec_matcher' depends on this,
|
3
3
|
# so try to keep them roughly in sync
|
4
|
-
VERSION = "0.5.
|
4
|
+
VERSION = "0.5.4" # about to release? rerun `bundle lock` to update Gemfile.lock
|
5
5
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: check_please
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Livingston-Gray
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: table_print
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- lib/check_please/flags.rb
|
88
88
|
- lib/check_please/path.rb
|
89
89
|
- lib/check_please/path_segment.rb
|
90
|
+
- lib/check_please/path_segment_matcher.rb
|
90
91
|
- lib/check_please/printers.rb
|
91
92
|
- lib/check_please/printers/base.rb
|
92
93
|
- lib/check_please/printers/json.rb
|