Class: Livecheck

Inherits:
Object show all
Extended by:
Forwardable
Defined in:
livecheck.rb,
sorbet/rbi/parlour.rbi

Overview

The Livecheck class implements the DSL methods used in a formula’s, cask’s or resource’s livecheck block and stores related instance variables. Most of these methods also return the related instance variable when no argument is provided.

This information is used by the brew livecheck command to control its behavior. Example livecheck blocks can be found in the brew livecheck documentation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(package_or_resource) ⇒ void

Parameters:



23
24
25
26
27
28
29
30
31
32
33
34
# File 'livecheck.rb', line 23

def initialize(package_or_resource)
  @package_or_resource = package_or_resource
  @referenced_cask_name = nil
  @referenced_formula_name = nil
  @regex = nil
  @skip = false
  @skip_msg = nil
  @strategy = nil
  @strategy_block = nil
  @throttle = nil
  @url = nil
end

Instance Attribute Details

#skip_msgString? (readonly)

A very brief description of why the formula/cask/resource is skipped (e.g. No longer developed or maintained).

Returns:



20
21
22
# File 'livecheck.rb', line 20

def skip_msg
  @skip_msg
end

#strategy_blockProc? (readonly)

Returns:

  • (Proc, nil)


137
138
139
# File 'livecheck.rb', line 137

def strategy_block
  @strategy_block
end

Instance Method Details

#arch(*args, **options, &block) ⇒ T.untyped

Parameters:

  • args (T.untyped)
  • options (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


235
# File 'sorbet/rbi/parlour.rbi', line 235

def arch(*args, **options, &block); end

#cask(cask_name = T.unsafe(nil)) ⇒ String?

Sets the @referenced_cask_name instance variable to the provided String or returns the @referenced_cask_name instance variable when no argument is provided. Inherited livecheck values from the referenced cask (e.g. regex) can be overridden in the livecheck block.

Parameters:

  • cask_name (String) (defaults to: T.unsafe(nil))

Returns:



46
47
48
49
50
51
52
53
# File 'livecheck.rb', line 46

def cask(cask_name = T.unsafe(nil))
  case cask_name
  when nil
    @referenced_cask_name
  when String
    @referenced_cask_name = cask_name
  end
end

#formula(formula_name = T.unsafe(nil)) ⇒ String?

Sets the @referenced_formula_name instance variable to the provided String or returns the @referenced_formula_name instance variable when no argument is provided. Inherited livecheck values from the referenced formula (e.g. regex) can be overridden in the livecheck block.

Parameters:

  • formula_name (String) (defaults to: T.unsafe(nil))

Returns:



65
66
67
68
69
70
71
72
# File 'livecheck.rb', line 65

def formula(formula_name = T.unsafe(nil))
  case formula_name
  when nil
    @referenced_formula_name
  when String
    @referenced_formula_name = formula_name
  end
end

#regex(pattern = T.unsafe(nil)) ⇒ Regexp?

Sets the @regex instance variable to the provided Regexp or returns the @regex instance variable when no argument is provided.

Parameters:

  • pattern (Regexp) (defaults to: T.unsafe(nil))

Returns:

  • (Regexp, nil)


82
83
84
85
86
87
88
89
# File 'livecheck.rb', line 82

def regex(pattern = T.unsafe(nil))
  case pattern
  when nil
    @regex
  when Regexp
    @regex = pattern
  end
end

#skip(skip_msg = T.unsafe(nil)) ⇒ Boolean

Sets the @skip instance variable to true and sets the @skip_msg instance variable if a String is provided. @skip is used to indicate that the formula/cask/resource should be skipped and the skip_msg very briefly describes why it is skipped (e.g. “No longer developed or maintained”).

Parameters:

  • skip_msg (String) (defaults to: T.unsafe(nil))

Returns:

  • (Boolean)


102
103
104
105
106
# File 'livecheck.rb', line 102

def skip(skip_msg = T.unsafe(nil))
  @skip_msg = skip_msg if skip_msg.is_a?(String)

  @skip = true
end

#skip?Boolean

Should livecheck skip this formula/cask/resource?

Returns:

  • (Boolean)


110
111
112
# File 'livecheck.rb', line 110

def skip?
  @skip
end

#strategy(symbol = T.unsafe(nil), &block) ⇒ Symbol?

Sets the @strategy instance variable to the provided Symbol or returns the @strategy instance variable when no argument is provided. The strategy symbols use snake case (e.g. :page_match) and correspond to the strategy file name.

Parameters:

  • symbol (Symbol) (defaults to: T.unsafe(nil))
  • block (Proc, nil)

Returns:



125
126
127
128
129
130
131
132
133
134
# File 'livecheck.rb', line 125

def strategy(symbol = T.unsafe(nil), &block)
  @strategy_block = block if block

  case symbol
  when nil
    @strategy
  when Symbol
    @strategy = symbol
  end
end

#throttle(rate = T.unsafe(nil)) ⇒ Integer?

Sets the @throttle instance variable to the provided Integer or returns the @throttle instance variable when no argument is provided.

Parameters:

  • rate (Integer) (defaults to: T.unsafe(nil))

Returns:

  • (Integer, nil)


147
148
149
150
151
152
153
154
# File 'livecheck.rb', line 147

def throttle(rate = T.unsafe(nil))
  case rate
  when nil
    @throttle
  when Integer
    @throttle = rate
  end
end

#to_hashHash{String => T.untyped}

Returns a Hash of all instance variable values.

Returns:



184
185
186
187
188
189
190
191
192
193
194
195
# File 'livecheck.rb', line 184

def to_hash
  {
    "cask"     => @referenced_cask_name,
    "formula"  => @referenced_formula_name,
    "regex"    => @regex,
    "skip"     => @skip,
    "skip_msg" => @skip_msg,
    "strategy" => @strategy,
    "throttle" => @throttle,
    "url"      => @url,
  }
end

#url(url = T.unsafe(nil)) ⇒ String, ...

Sets the @url instance variable to the provided argument or returns the @url instance variable when no argument is provided. The argument can be a String (a URL) or a supported Symbol corresponding to a URL in the formula/cask/resource (e.g. :stable, :homepage, :head, :url).

Parameters:

Returns:



166
167
168
169
170
171
172
173
174
175
# File 'livecheck.rb', line 166

def url(url = T.unsafe(nil))
  case url
  when nil
    @url
  when String, :head, :homepage, :stable, :url
    @url = url
  when Symbol
    raise ArgumentError, "#{url.inspect} is not a valid URL shorthand"
  end
end

#version(*args, **options, &block) ⇒ T.untyped

Parameters:

  • args (T.untyped)
  • options (T.untyped)
  • block (T.untyped)

Returns:

  • (T.untyped)


232
# File 'sorbet/rbi/parlour.rbi', line 232

def version(*args, **options, &block); end