From e722a906f4c916241c66cd067c669897c1f03103 Mon Sep 17 00:00:00 2001 From: Christian Bernard Date: Wed, 23 Jan 2019 11:45:19 -0700 Subject: [PATCH 1/4] Added missing method to_a to Cask::DSL:ConflictsWith class. --- Library/Homebrew/cask/dsl/conflicts_with.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Library/Homebrew/cask/dsl/conflicts_with.rb b/Library/Homebrew/cask/dsl/conflicts_with.rb index fa05f584c1..f2945d6b99 100644 --- a/Library/Homebrew/cask/dsl/conflicts_with.rb +++ b/Library/Homebrew/cask/dsl/conflicts_with.rb @@ -25,6 +25,9 @@ module Cask instance_variable_set("@#{key}", instance_variable_get("@#{key}").merge([*value])) end end + def to_a + (@pairs.values) + end end end end From 57fd624d251734ab9f712f47649dd245aca8986b Mon Sep 17 00:00:00 2001 From: Christian Bernard Date: Wed, 23 Jan 2019 12:21:15 -0700 Subject: [PATCH 2/4] Fix style issues based on brew style guide --- Library/Homebrew/cask/dsl/conflicts_with.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/dsl/conflicts_with.rb b/Library/Homebrew/cask/dsl/conflicts_with.rb index f2945d6b99..ea4065e21d 100644 --- a/Library/Homebrew/cask/dsl/conflicts_with.rb +++ b/Library/Homebrew/cask/dsl/conflicts_with.rb @@ -25,8 +25,9 @@ module Cask instance_variable_set("@#{key}", instance_variable_get("@#{key}").merge([*value])) end end + def to_a - (@pairs.values) + @pairs.values end end end From cadb193e3b58a8ad4b31c6f45236daa53e3ec7d6 Mon Sep 17 00:00:00 2001 From: Christian Bernard Date: Fri, 25 Jan 2019 08:05:13 -0700 Subject: [PATCH 3/4] Update to convert pairs to hash k=>v during to_a in Cask::DSL::ConflictsWith#to_a --- Library/Homebrew/cask/dsl/conflicts_with.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cask/dsl/conflicts_with.rb b/Library/Homebrew/cask/dsl/conflicts_with.rb index ea4065e21d..75242b9490 100644 --- a/Library/Homebrew/cask/dsl/conflicts_with.rb +++ b/Library/Homebrew/cask/dsl/conflicts_with.rb @@ -27,7 +27,9 @@ module Cask end def to_a - @pairs.values + conflicts={} + @pairs.each { |k, v| conflicts[k]=v } + conflicts end end end From 97ca5932cfb43fd687aff0587654ea21b0ab7358 Mon Sep 17 00:00:00 2001 From: Christian Bernard Date: Sat, 26 Jan 2019 10:15:45 -0700 Subject: [PATCH 4/4] Updated Cask::Cask#to_h to call Conflicts#to_h instead of to_a. Updated ConflictsWith#to_h to iterate over VALID_KEYS. --- Library/Homebrew/cask/cask.rb | 2 +- Library/Homebrew/cask/dsl/conflicts_with.rb | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cask/cask.rb b/Library/Homebrew/cask/cask.rb index 12d578df81..f279630487 100644 --- a/Library/Homebrew/cask/cask.rb +++ b/Library/Homebrew/cask/cask.rb @@ -133,7 +133,7 @@ module Cask end, "caveats" => caveats, "depends_on" => depends_on, - "conflicts_with" => conflicts_with.to_a, + "conflicts_with" => conflicts_with.to_h, "container" => container, "auto_updates" => auto_updates, } diff --git a/Library/Homebrew/cask/dsl/conflicts_with.rb b/Library/Homebrew/cask/dsl/conflicts_with.rb index 75242b9490..e9db95fd27 100644 --- a/Library/Homebrew/cask/dsl/conflicts_with.rb +++ b/Library/Homebrew/cask/dsl/conflicts_with.rb @@ -26,10 +26,8 @@ module Cask end end - def to_a - conflicts={} - @pairs.each { |k, v| conflicts[k]=v } - conflicts + def to_h + Hash[VALID_KEYS.map { |key| [key, instance_variable_get("@#{key}").to_a] }] end end end