cli-mastermind 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 661c3f66382c7e6fb62eb1c01c265c93fe2e62b45340307c6912e8618621026f
4
- data.tar.gz: 775edbb8a13283c46a91bdbc7698e3e322aa9022b29285ada8e5d56884b855b0
3
+ metadata.gz: 10729271d3db58b9b063db4da11c4e96c96e59b5ffa53b5088b54f63c46ddaf2
4
+ data.tar.gz: aa7e9c1600070cbb7f154e389a23bfacf6176324e8882acb6107c9a2cb3164d5
5
5
  SHA512:
6
- metadata.gz: a8b725781d38d56a9153f1d4bbb4216dffcca02c69a8bb19296218543c1e790bc7f9f11159012bc3a673d75ef8c83b2639536704daee65404c20e9bab04c51bd
7
- data.tar.gz: 1a267b4f96d51da4a02ac6044b330fc8b2f97cc8d87066e650e3578b44afd4f1cb2f427b6ab0719c17919507166a28d4cd15abf2679b7f40cebce1d3bd863b3d
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
- # If this namespace isn't taken just add the plan
35
- if @children.has_key? plan.name
34
+ @children[plan.name] = resolve_conflicts(plan.name, plan)
36
35
 
37
- # Otherwise, we need to handle a name collision
38
- existing_plan = @children[plan.name]
36
+ plan.aliases.each do |a|
37
+ @children[a] = resolve_conflicts(a, plan)
38
+ end
39
+ end
39
40
 
40
- # If both plans have children, we merge them together
41
- if existing_plan.has_children? and plan.has_children?
42
- existing_plan.add_children plan.children.values
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
- return existing_plan
45
- end
45
+ # Otherwise, we need to handle a name collision
46
+ existing_plan = @children[key]
46
47
 
47
- # Otherwise, the plan defined later wins and overwrites the existing plan
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
- # Warn the user that this is happening, unless we're running tests.
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
- @children[plan.name] = plan
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
@@ -8,7 +8,7 @@ module CLI
8
8
  module VERSION
9
9
  RELEASE = 1
10
10
  MAJOR = 2
11
- MINOR = 0
11
+ MINOR = 1
12
12
  PATCH = nil
13
13
 
14
14
  STRING = [RELEASE, MAJOR, MINOR, PATCH].compact.join('.').freeze
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cli-mastermind
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hall