cli-mastermind 1.2.0 → 1.2.1
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/lib/cli/mastermind/parent_plan.rb +24 -17
- data/lib/cli/mastermind/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10729271d3db58b9b063db4da11c4e96c96e59b5ffa53b5088b54f63c46ddaf2
|
4
|
+
data.tar.gz: aa7e9c1600070cbb7f154e389a23bfacf6176324e8882acb6107c9a2cb3164d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cecf65b1e9ab90abe21027ed98fd0fe2bdf14dae7c2439deb9c67dcb873c266c2b3d2496f6c823455b013a78ea3a23978b2caba211aad2da2653a7aa3409fdf
|
7
|
+
data.tar.gz: de633722765fd552f8b861ac62d89308c41d7d984aa6bbc8589a1fce466b2ceb878081a901bde9b7b88248f4bd23ddc698451085f930944817676999778b3169
|
@@ -31,30 +31,37 @@ module CLI
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def incorporate_plan(plan)
|
34
|
-
|
35
|
-
if @children.has_key? plan.name
|
34
|
+
@children[plan.name] = resolve_conflicts(plan.name, plan)
|
36
35
|
|
37
|
-
|
38
|
-
|
36
|
+
plan.aliases.each do |a|
|
37
|
+
@children[a] = resolve_conflicts(a, plan)
|
38
|
+
end
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
41
|
+
def resolve_conflicts(key, plan)
|
42
|
+
# If this namespace isn't taken we're good
|
43
|
+
return plan unless @children.has_key?(key)
|
43
44
|
|
44
|
-
|
45
|
-
|
45
|
+
# Otherwise, we need to handle a name collision
|
46
|
+
existing_plan = @children[key]
|
46
47
|
|
47
|
-
|
48
|
+
# If both plans have children, we merge them together
|
49
|
+
if existing_plan.has_children? and plan.has_children?
|
50
|
+
existing_plan.add_children plan.children.values
|
48
51
|
|
49
|
-
|
50
|
-
warn <<~PLAN_COLLISON.strip unless defined? RSpec
|
51
|
-
Plan name collision encountered when loading plans from "#{plan.filename}" that cannot be merged.
|
52
|
-
"#{plan.name}" was previously defined in "#{existing_plan.filename}".
|
53
|
-
Plans from "#{plan.filename}" will be used instead.
|
54
|
-
PLAN_COLLISON
|
52
|
+
return existing_plan
|
55
53
|
end
|
56
54
|
|
57
|
-
|
55
|
+
# Otherwise, the plan defined later wins and overwrites the existing plan
|
56
|
+
|
57
|
+
# Warn the user that this is happening, unless we're running tests.
|
58
|
+
warn <<~PLAN_COLLISON.strip unless defined? RSpec
|
59
|
+
Plan name collision encountered when loading plans from "#{plan.filename}" that cannot be merged.
|
60
|
+
"#{key}" was previously defined in "#{existing_plan.filename}".
|
61
|
+
Plan "#{key}" from "#{plan.filename}" will be used instead.
|
62
|
+
PLAN_COLLISON
|
63
|
+
|
64
|
+
plan
|
58
65
|
end
|
59
66
|
end
|
60
67
|
end
|