refinement 0.6.0 → 0.7.0
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 +4 -4
- data/CHANGELOG.md +16 -0
- data/VERSION +1 -1
- data/exe/refine +1 -1
- data/lib/cocoapods_plugin.rb +2 -2
- data/lib/refinement.rb +6 -27
- data/lib/sq/refinement/analyzer.rb +396 -0
- data/lib/sq/refinement/annotated_target.rb +82 -0
- data/lib/sq/refinement/changeset/file_modification.rb +144 -0
- data/lib/sq/refinement/changeset.rb +225 -0
- data/lib/sq/refinement/cli.rb +121 -0
- data/lib/sq/refinement/cocoapods_post_install_writer.rb +129 -0
- data/lib/sq/refinement/setup.rb +22 -0
- data/lib/sq/refinement/used_path.rb +156 -0
- data/lib/sq/refinement/version.rb +8 -0
- metadata +15 -27
- data/lib/refinement/analyzer.rb +0 -395
- data/lib/refinement/annotated_target.rb +0 -78
- data/lib/refinement/changeset/file_modification.rb +0 -138
- data/lib/refinement/changeset.rb +0 -223
- data/lib/refinement/cli.rb +0 -119
- data/lib/refinement/cocoapods_post_install_writer.rb +0 -126
- data/lib/refinement/used_path.rb +0 -154
- data/lib/refinement/version.rb +0 -6
data/lib/refinement/used_path.rb
DELETED
@@ -1,154 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Refinement
|
4
|
-
# Represents a path that some target depends upon.
|
5
|
-
class UsedPath
|
6
|
-
# @return [Pathname] the absolute path to the file
|
7
|
-
attr_reader :path
|
8
|
-
private :path
|
9
|
-
|
10
|
-
# @return [String] the reason why this path is being used by a target
|
11
|
-
attr_reader :inclusion_reason
|
12
|
-
private :inclusion_reason
|
13
|
-
|
14
|
-
def initialize(path:, inclusion_reason:)
|
15
|
-
@path = path
|
16
|
-
@inclusion_reason = inclusion_reason
|
17
|
-
end
|
18
|
-
|
19
|
-
# @return [Nil, String] If the path has been modified, a string explaining the modification
|
20
|
-
# @param changeset [Changeset] the changeset to search for a modification to this path
|
21
|
-
def find_in_changeset(changeset)
|
22
|
-
add_reason changeset.find_modification_for_path(absolute_path: path), changeset: changeset
|
23
|
-
end
|
24
|
-
|
25
|
-
# @return [Nil, String] If the path has been modified, a string explaining the modification
|
26
|
-
# @param changesets [Array<Changeset>] the changesets to search for a modification to this path
|
27
|
-
def find_in_changesets(changesets)
|
28
|
-
raise ArgumentError, 'Must provide at least one changeset' if changesets.empty?
|
29
|
-
|
30
|
-
changesets.reduce(true) do |explanation, changeset|
|
31
|
-
explanation && find_in_changeset(changeset)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# @return [String]
|
36
|
-
# @visibility private
|
37
|
-
def to_s
|
38
|
-
"#{path.to_s.inspect} (#{inclusion_reason})"
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
# @return [Nil, String] A string suitable for user display that explains
|
44
|
-
# why the given modification means a target is modified
|
45
|
-
# @param modification [Nil, FileModification]
|
46
|
-
# @param changeset [Changeset]
|
47
|
-
def add_reason(modification, changeset:)
|
48
|
-
return unless modification
|
49
|
-
|
50
|
-
add_changeset_description "#{modification.path} (#{inclusion_reason}) #{modification.type}", changeset: changeset
|
51
|
-
end
|
52
|
-
|
53
|
-
# @return [String] A string suitable for user display that explains
|
54
|
-
# why the given modification means a target is modified, including the description
|
55
|
-
# of the changeset that contains the modification
|
56
|
-
# @param description [String]
|
57
|
-
# @param changeset [Nil, Changeset]
|
58
|
-
def add_changeset_description(description, changeset:)
|
59
|
-
return description unless changeset&.description
|
60
|
-
|
61
|
-
description + " (#{changeset.description})"
|
62
|
-
end
|
63
|
-
|
64
|
-
# Represents a path to a YAML file that some target depends upon,
|
65
|
-
# but where only a subset of the YAML is needed to determine a change.
|
66
|
-
class YAML < UsedPath
|
67
|
-
# @return [Array] the keypath to search for modifications in a YAML document
|
68
|
-
attr_reader :yaml_keypath
|
69
|
-
private :yaml_keypath
|
70
|
-
|
71
|
-
def initialize(yaml_keypath:, **kwargs)
|
72
|
-
super(**kwargs)
|
73
|
-
@yaml_keypath = yaml_keypath
|
74
|
-
end
|
75
|
-
|
76
|
-
# (see UsedPath#find_in_changeset)
|
77
|
-
def find_in_changeset(changeset)
|
78
|
-
modification, _yaml_diff = changeset.find_modification_for_yaml_keypath(absolute_path: path, keypath: yaml_keypath)
|
79
|
-
add_reason modification, changeset: changeset
|
80
|
-
end
|
81
|
-
|
82
|
-
# (see UsedPath#to_s)
|
83
|
-
def to_s
|
84
|
-
"#{path.to_s.inspect} @ #{yaml_keypath.join('.')} (#{inclusion_reason})"
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
# (see UsedPath#add_reason)
|
90
|
-
def add_reason(modification, changeset:)
|
91
|
-
return unless modification
|
92
|
-
|
93
|
-
keypath_string =
|
94
|
-
if yaml_keypath.empty?
|
95
|
-
''
|
96
|
-
else
|
97
|
-
' @ ' + yaml_keypath.map { |path| path.to_s =~ /\A[a-zA-Z0-9_]+\z/ ? path : path.inspect }.join('.')
|
98
|
-
end
|
99
|
-
add_changeset_description "#{modification.path}#{keypath_string} (#{inclusion_reason}) #{modification.type}", changeset: changeset
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
# Represents a glob that some target depends upon.
|
105
|
-
class UsedGlob
|
106
|
-
# @return [String] a relative path glob
|
107
|
-
attr_reader :glob
|
108
|
-
private :glob
|
109
|
-
|
110
|
-
# (see UsedPath#inclusion_reason)
|
111
|
-
attr_reader :inclusion_reason
|
112
|
-
private :inclusion_reason
|
113
|
-
|
114
|
-
def initialize(glob:, inclusion_reason:)
|
115
|
-
@glob = glob
|
116
|
-
@inclusion_reason = inclusion_reason
|
117
|
-
end
|
118
|
-
|
119
|
-
# (see UsedPath#find_in_changeset)
|
120
|
-
def find_in_changeset(changeset)
|
121
|
-
add_reason changeset.find_modification_for_glob(absolute_glob: glob), changeset: changeset
|
122
|
-
end
|
123
|
-
|
124
|
-
# (see UsedPath#find_in_changesets)
|
125
|
-
def find_in_changesets(changesets)
|
126
|
-
raise ArgumentError, 'Must provide at least one changeset' if changesets.empty?
|
127
|
-
|
128
|
-
changesets.reduce(true) do |explanation, changeset|
|
129
|
-
explanation && find_in_changeset(changeset)
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
# (see UsedPath#to_s)
|
134
|
-
def to_s
|
135
|
-
"#{glob.to_s.inspect} (#{inclusion_reason})"
|
136
|
-
end
|
137
|
-
|
138
|
-
private
|
139
|
-
|
140
|
-
# (see UsedPath#add_reason)
|
141
|
-
def add_reason(modification, changeset:)
|
142
|
-
return unless modification
|
143
|
-
|
144
|
-
add_changeset_description "#{modification.path} (#{inclusion_reason}) #{modification.type}", changeset: changeset
|
145
|
-
end
|
146
|
-
|
147
|
-
# (see UsedPath#add_changeset_description)
|
148
|
-
def add_changeset_description(description, changeset:)
|
149
|
-
return description unless changeset&.description
|
150
|
-
|
151
|
-
description + " (#{changeset.description})"
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|