From f3fba8185e713b7ef80400d37dfdacaddf47f30d Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Wed, 21 Mar 2018 12:42:48 +0000 Subject: [PATCH] tab: cleanup various methods. Use some newer Ruby syntax and improve readability. --- Library/Homebrew/tab.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 0fed724a8..02a727668 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -38,12 +38,12 @@ class Tab < OpenStruct end, "source" => { "path" => formula.specified_path.to_s, - "tap" => formula.tap ? formula.tap.name : nil, + "tap" => formula.tap&.name, "spec" => formula.active_spec_sym.to_s, "versions" => { - "stable" => formula.stable ? formula.stable.version.to_s : nil, - "devel" => formula.devel ? formula.devel.version.to_s : nil, - "head" => formula.head ? formula.head.version.to_s : nil, + "stable" => formula.stable&.version.to_s, + "devel" => formula.devel&.version.to_s, + "head" => formula.head&.version.to_s, "version_scheme" => formula.version_scheme, }, }, @@ -66,7 +66,7 @@ class Tab < OpenStruct attributes["source"] ||= {} tapped_from = attributes["tapped_from"] - unless tapped_from.nil? || tapped_from == "path or URL" + if !tapped_from.nil? && tapped_from != "path or URL" attributes["source"]["tap"] = attributes.delete("tapped_from") end @@ -156,12 +156,12 @@ class Tab < OpenStruct tab.unused_options = f.options.as_flags tab.source = { "path" => f.specified_path.to_s, - "tap" => f.tap ? f.tap.name : f.tap, + "tap" => f.tap&.name, "spec" => f.active_spec_sym.to_s, "versions" => { - "stable" => f.stable ? f.stable.version.to_s : nil, - "devel" => f.devel ? f.devel.version.to_s : nil, - "head" => f.head ? f.head.version.to_s : nil, + "stable" => f.stable&.version.to_s, + "devel" => f.devel&.version.to_s, + "head" => f.head&.version.to_s, "version_scheme" => f.version_scheme, }, }