Class: Livecheck

Inherits:
Object
  • Object
show all
Defined in:
brew/Library/Homebrew/livecheck.rb

Overview

Livecheck can be used to check for newer versions of the software. The livecheck DSL specified in the formula is evaluated the methods of this class, which set the instance variables accordingly. The information is used by brew livecheck when checking for newer versions of the software.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(formula) ⇒ Livecheck

Returns a new instance of Livecheck.



13
14
15
16
17
18
19
# File 'brew/Library/Homebrew/livecheck.rb', line 13

def initialize(formula)
  @formula = formula
  @regex = nil
  @skip = false
  @skip_msg = nil
  @url = nil
end

Instance Attribute Details

#skip_msgObject (readonly)

The reason for skipping livecheck for the formula. e.g. Not maintained



11
12
13
# File 'brew/Library/Homebrew/livecheck.rb', line 11

def skip_msg
  @skip_msg
end

Instance Method Details

#regex(pattern = nil) ⇒ Object

Sets the regex instance variable to the argument given, returns the regex instance variable when no argument is given.



23
24
25
26
27
# File 'brew/Library/Homebrew/livecheck.rb', line 23

def regex(pattern = nil)
  return @regex if pattern.nil?

  @regex = pattern
end

#skip(skip_msg = nil) ⇒ Object

Sets the skip instance variable to true, indicating that livecheck must be skipped for the formula. If an argument is given and present, its value is assigned to the skip_msg instance variable, else nil is assigned.



33
34
35
36
# File 'brew/Library/Homebrew/livecheck.rb', line 33

def skip(skip_msg = nil)
  @skip = true
  @skip_msg = skip_msg.presence
end

#skip?Boolean

Should livecheck be skipped for the formula?

Returns:

  • (Boolean)


39
40
41
# File 'brew/Library/Homebrew/livecheck.rb', line 39

def skip?
  @skip
end

#to_hashObject

Returns a Hash of all instance variable values.



59
60
61
62
63
64
65
66
# File 'brew/Library/Homebrew/livecheck.rb', line 59

def to_hash
  {
    "regex"    => @regex,
    "skip"     => @skip,
    "skip_msg" => @skip_msg,
    "url"      => @url,
  }
end

#url(val = nil) ⇒ Object

Sets the url instance variable to the argument given, returns the url instance variable when no argument is given.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'brew/Library/Homebrew/livecheck.rb', line 45

def url(val = nil)
  return @url if val.nil?

  @url = case val
  when :head, :stable, :devel
    @formula.send(val).url
  when :homepage
    @formula.homepage
  else
    val
  end
end