Use ActiveSupport Object#blank? and #present?

This commit is contained in:
Mike McQuaid 2018-09-14 17:02:19 +01:00
parent a4d9b4816d
commit 955214abc0
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
7 changed files with 7 additions and 7 deletions

View File

@ -75,7 +75,7 @@ module Cask
ohai "Homebrew Cask Taps:"
[default_tap, *alt_taps].each do |tap|
if tap.path.nil? || tap.path.to_s.empty?
if tap.path.blank?
puts none_string
else
puts "#{tap.path} (#{cask_count_for_tap(tap)})"

View File

@ -961,7 +961,7 @@ module Homebrew
def audit_version
if version.nil?
problem "missing version"
elsif version.to_s.empty?
elsif version.blank?
problem "version is set to an empty string"
elsif !version.detected_from_url?
version_text = version

View File

@ -453,7 +453,7 @@ module Homebrew
tag = tag.to_s.delete ":"
unless tag.empty?
if !bottle_hash["bottle"]["tags"][tag].to_s.empty?
if bottle_hash["bottle"]["tags"][tag].present?
mismatches << "#{key} => #{tag}"
else
bottle.send(key, old_value => tag.to_sym)

View File

@ -1109,7 +1109,7 @@ class BazaarDownloadStrategy < VCSDownloadStrategy
def source_modified_time
out, = system_command("bzr", args: ["log", "-l", "1", "--timezone=utc", cached_location])
timestamp = out.chomp
raise "Could not get any timestamps from bzr!" if timestamp.to_s.empty?
raise "Could not get any timestamps from bzr!" if timestamp.blank?
Time.parse(timestamp)
end

View File

@ -35,7 +35,7 @@ module Homebrew
end
def check_xdg_data_dirs
return if ENV["XDG_DATA_DIRS"].to_s.empty?
return if ENV["XDG_DATA_DIRS"].blank?
return if ENV["XDG_DATA_DIRS"].split("/").include?(HOMEBREW_PREFIX/"share")
<<~EOS
Homebrew's share was not found in your XDG_DATA_DIRS but you have

View File

@ -130,6 +130,7 @@ require "extend/pathname"
require "extend/module"
require "extend/predicable"
require "extend/string"
require "active_support/core_ext/object/blank"
require "constants"
require "exceptions"

View File

@ -142,8 +142,7 @@ module Homebrew
hash, short_hash, *commit_message, relative_path =
Utils.popen_read(log_command).gsub("\\n", "\n").lines.map(&:chomp)
if hash.to_s.empty? || short_hash.to_s.empty? ||
relative_path.to_s.empty?
if hash.blank? || short_hash.blank? || relative_path.blank?
ofail "No previously deleted formula found." unless silent
return
end