Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update display of requirements #9021

Merged
merged 5 commits into from Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -21,7 +21,7 @@ class OsxfuseRequirement < Requirement
end

def message
msg = "libfuse is required to install this formula.\n"
msg = "libfuse is required for this software.\n"
if libfuse_formula_exists?
<<~EOS
#{msg}Run `brew install libfuse` to install it.
Expand Down
Expand Up @@ -21,4 +21,8 @@ def self.binary_osxfuse_installed?
ENV.append_path "HOMEBREW_INCLUDE_PATHS", "/usr/local/include/osxfuse"
end
end

def message
"FUSE for macOS is required for this software. #{super}"
end
end
Expand Up @@ -17,6 +17,6 @@ def min_version
end

def message
"XQuartz #{min_version} (or newer) is required to install this formula. #{super}"
"XQuartz #{min_version} (or newer) is required for this software. #{super}"
end
end
2 changes: 1 addition & 1 deletion Library/Homebrew/formula.rb
Expand Up @@ -1772,7 +1772,7 @@ def to_hash
"name" => req.name,
"cask" => req.cask,
"download" => req.download,
"version" => req.try(:version),
"version" => req.try(:version) || req.try(:arch),
"contexts" => req.tags,
}
end
Expand Down
6 changes: 3 additions & 3 deletions Library/Homebrew/requirement.rb
Expand Up @@ -48,7 +48,7 @@ def message
if download
s += <<~EOS
You can download from:
#{download}
#{Formatter.url(download)}
EOS
end
s
Expand Down Expand Up @@ -122,11 +122,11 @@ def hash
end

def inspect
"#<#{self.class.name}: #{name.inspect} #{tags.inspect}>"
"#<#{self.class.name}: #{tags.inspect}>"
end

def display_s
name
name.capitalize
end

def mktemp(&block)
Expand Down
12 changes: 9 additions & 3 deletions Library/Homebrew/requirements/arch_requirement.rb
Expand Up @@ -9,20 +9,26 @@
class ArchRequirement < Requirement
fatal true

attr_reader :arch

def initialize(tags)
@arch = tags.shift
super(tags)
end

satisfy(build_env: false) do
case @arch
when :x86_64 then Hardware::CPU.is_64_bit?
when :intel, :ppc then Hardware::CPU.type == @arch
when :x86_64 then Hardware::CPU.intel? && Hardware::CPU.is_64_bit?
when :arm, :intel, :ppc then Hardware::CPU.type == @arch
end
end

def message
"This formula requires an #{@arch} architecture."
"The #{@arch} architecture is required for this software."
end

def inspect
"#<#{self.class.name}: arch=#{@arch.to_s.inspect} #{tags.inspect}>"
end

def display_s
Expand Down
8 changes: 4 additions & 4 deletions Library/Homebrew/requirements/java_requirement.rb
Expand Up @@ -39,13 +39,13 @@ def initialize(tags = [])

def message
version_string = " #{@version}" if @version
s = "Java#{version_string} is required to install this formula.\n"
s = "Java#{version_string} is required for this software.\n"
s += suggestion
s
end

def inspect
"#<#{self.class.name}: #{tags.inspect} version=#{@version.inspect}>"
"#<#{self.class.name}: version=#{@version.inspect} #{tags.inspect}>"
end

def display_s
Expand All @@ -55,9 +55,9 @@ def display_s
else
">="
end
"#{name} #{op} #{version_without_plus}"
"#{name.capitalize} #{op} #{version_without_plus}"
else
name
name.capitalize
end
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/requirements/linux_requirement.rb
Expand Up @@ -10,6 +10,6 @@ class LinuxRequirement < Requirement
satisfy(build_env: false) { OS.linux? }

def message
"Linux is required."
"Linux is required for this software."
end
end
12 changes: 6 additions & 6 deletions Library/Homebrew/requirements/macos_requirement.rb
Expand Up @@ -41,11 +41,11 @@ def version_specified?
end

def message(type: :formula)
return "macOS is required." unless version_specified?
return "macOS is required for this software." unless version_specified?

case @comparator
when ">="
"macOS #{@version.pretty_name} or newer is required."
"macOS #{@version.pretty_name} or newer is required for this software."
when "<="
case type
when :formula
Expand All @@ -59,19 +59,19 @@ def message(type: :formula)
else
if @version.respond_to?(:to_ary)
*versions, last = @version.map(&:pretty_name)
return "macOS #{versions.join(", ")} or #{last} is required."
return "macOS #{versions.join(", ")} or #{last} is required for this software."
end

"macOS #{@version.pretty_name} is required."
"macOS #{@version.pretty_name} is required for this software."
end
end

def inspect
"#<#{self.class.name}: #{tags.inspect} version#{@comparator}#{@version}>"
"#<#{self.class.name}: version#{@comparator}#{@version.to_s.inspect} #{tags.inspect}>"
end

def display_s
return "macOS is required" unless version_specified?
return "macOS" unless version_specified?

"macOS #{@comparator} #{@version}"
end
Expand Down
6 changes: 6 additions & 0 deletions Library/Homebrew/requirements/osxfuse_requirement.rb
Expand Up @@ -7,8 +7,14 @@
#
# @api private
class OsxfuseRequirement < Requirement
extend T::Sig
cask "osxfuse"
fatal true

sig { returns(String) }
def display_s
"FUSE"
end
end

require "extend/os/requirements/osxfuse_requirement"
6 changes: 1 addition & 5 deletions Library/Homebrew/requirements/x11_requirement.rb
Expand Up @@ -39,7 +39,7 @@ def min_xdpyinfo_version
end

def message
"X11 is required to install this formula, either Xorg #{min_version} or " \
"X11 is required for this software, either Xorg #{min_version} or " \
"xdpyinfo #{min_xdpyinfo_version}, or newer. #{super}"
end

Expand All @@ -48,10 +48,6 @@ def <=>(other)

0
end

def inspect
"#<#{self.class.name}: #{tags.inspect}>"
end
end

require "extend/os/requirements/x11_requirement"
8 changes: 7 additions & 1 deletion Library/Homebrew/requirements/xcode_requirement.rb
Expand Up @@ -46,7 +46,13 @@ def message
end

def inspect
"#<#{self.class.name}: #{tags.inspect} version=#{@version.inspect}>"
"#<#{self.class.name}: version>=#{@version.inspect} #{tags.inspect}>"
end

def display_s
return name.capitalize unless @version

"#{name.capitalize} >= #{@version}"
end
end

Expand Down
131 changes: 0 additions & 131 deletions Library/Homebrew/test/java_requirement_spec.rb

This file was deleted.