aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/requirements/x11_dependency.rb
blob: 5f7e4b52610f138175704ce8a147c4a5cb34719c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require "requirement"

class X11Dependency < Requirement
  include Comparable
  attr_reader :min_version

  fatal true
  cask "xquartz"
  download "https://xquartz.macosforge.org"

  env { ENV.x11 }

  def initialize(name="x11", tags=[])
    @name = name
    if /(\d\.)+\d/ === tags.first
      @min_version = Version.new(tags.shift)
      @min_version_string = " #{@min_version}"
    else
      @min_version = Version.new("0.0.0")
      @min_version_string = ""
    end
    super(tags)
  end

  satisfy :build_env => false do
    MacOS::XQuartz.installed? && min_version <= Version.new(MacOS::XQuartz.version)
  end

  def message
    s = "XQuartz#{@min_version_string} is required to install this formula."
    s += super
    s
  end

  def <=> other
    return unless X11Dependency === other
    min_version <=> other.min_version
  end

  def eql?(other)
    super && min_version == other.min_version
  end

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