Class: Homebrew::Livecheck::Options Private
- Defined in:
- livecheck/options.rb
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Options to modify livecheck's behavior. These primarily come from
livecheck blocks but they can also be set by livecheck at runtime.
Option values use a nil default to indicate that the value has not been
set.
Instance Attribute Summary collapse
-
#compressed ⇒ false?
private
Whether to request a compressed response.
-
#cookies ⇒ Hash{String => String}?
private
Cookies for curl to use when making a request.
-
#header ⇒ String, ...
private
Header(s) for curl to use when making a request.
-
#homebrew_curl ⇒ true?
private
Whether to use brewed curl.
-
#post_form ⇒ Hash{Symbol => String}?
private
Form data to use when making a
POSTrequest. -
#post_json ⇒ Hash{Symbol => T.anything}?
private
JSON data to use when making a
POSTrequest. -
#referer ⇒ String?
private
Referer for curl to use when making a request.
-
#user_agent ⇒ String, ...
private
User agent for curl to use when making a request.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
private
Whether the object has only default values.
- #initialize(compressed: nil, cookies: nil, header: nil, homebrew_curl: nil, post_form: nil, post_json: nil, referer: nil, user_agent: nil) ⇒ void constructor
-
#merge(other) ⇒ Options
private
Returns a new object formed by merging
othervalues with a copy ofself. -
#merge!(other) ⇒ Options
private
Merges values from
otherintoselfand returnsself. -
#present? ⇒ Boolean
private
Whether the object has any non-default values.
-
#to_h ⇒ Hash{Symbol => T.untyped}
private
Returns a
Hashof all instance variables, usingSymbolkeys. -
#to_hash ⇒ Hash{String => T.untyped}
private
Returns a
Hashof all instance variables, usingStringkeys. -
#url_options ⇒ Hash{Symbol => T.untyped}
private
Returns a
Hashof options that are provided as arguments tourl.
Constructor Details
#initialize(compressed: nil, cookies: nil, header: nil, homebrew_curl: nil, post_form: nil, post_json: nil, referer: nil, user_agent: nil) ⇒ void
|
|
# File '' prop :compressed, T.nilable(FalseClass) prop :cookies, T.nilable(T::Hash[String, String]) prop :header, T.nilable(T.any(String, T::Array[String])) prop :homebrew_curl, T.nilable(TrueClass) prop :post_form, T.nilable(T::Hash[Symbol, String]) prop :post_json, T.nilable(T::Hash[Symbol, T.anything]) prop :referer, T.nilable(String) prop :user_agent, T.nilable(T.any(String, Symbol)) |
Instance Attribute Details
#compressed ⇒ false?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Whether to request a compressed response.
|
|
# File '' prop :compressed, T.nilable(FalseClass) |
#cookies ⇒ Hash{String => String}?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Cookies for curl to use when making a request.
|
|
# File '' prop :cookies, T.nilable(T::Hash[String, String]) |
#header ⇒ String, ...
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Header(s) for curl to use when making a request.
|
|
# File '' prop :header, T.nilable(T.any(String, T::Array[String])) |
#homebrew_curl ⇒ true?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Whether to use brewed curl.
|
|
# File '' prop :homebrew_curl, T.nilable(TrueClass) |
#post_form ⇒ Hash{Symbol => String}?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Form data to use when making a POST request.
|
|
# File '' prop :post_form, T.nilable(T::Hash[Symbol, String]) |
#post_json ⇒ Hash{Symbol => T.anything}?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
JSON data to use when making a POST request.
|
|
# File '' prop :post_json, T.nilable(T::Hash[Symbol, T.anything]) |
#referer ⇒ String?
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Referer for curl to use when making a request.
|
|
# File '' prop :referer, T.nilable(String) |
#user_agent ⇒ String, ...
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
User agent for curl to use when making a request. Symbol arguments should use a value supported by Utils::Curl.curl_args.
|
|
# File '' prop :user_agent, T.nilable(T.any(String, Symbol)) |
Instance Method Details
#empty? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Whether the object has only default values.
123 |
# File 'livecheck/options.rb', line 123 def empty? = to_hash.empty? |
#merge(other) ⇒ Options
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a new object formed by merging other values with a copy of
self.
nil values from other are skipped, as these are uninitialized. This
ensures that existing values in self aren't unexpectedly overwritten
by defaults.
69 |
# File 'livecheck/options.rb', line 69 def merge(other) = deep_dup.merge!(other) |
#merge!(other) ⇒ Options
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Merges values from other into self and returns self.
nil values from other are skipped, as these are uninitialized. This
ensures that existing values in self aren't unexpectedly overwritten
by defaults.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'livecheck/options.rb', line 77 def merge!(other) return self if other.empty? # These options are mutually exclusive, so we can't know which should be # used when `other` has both other_post_form = other.post_form other_post_json = other.post_json if other_post_form && other_post_json raise ArgumentError, "Cannot merge provided options using both `post_form` and `post_json`" end return self if self == other other.instance_variables.each do |ivar| next if (val = T.let(other.instance_variable_get(ivar), Object)).nil? public_send(:"#{ivar.to_s.delete_prefix("@")}=", val.deep_dup) end # Merging one of these options should unset the opposite value in `self` if !other_post_form.nil? self.post_json = nil elsif !other_post_json.nil? self.post_form = nil end self end |
#present? ⇒ Boolean
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Whether the object has any non-default values.
127 |
# File 'livecheck/options.rb', line 127 def present? = !empty? |
#to_h ⇒ Hash{Symbol => T.untyped}
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a Hash of all instance variables, using Symbol keys.
60 |
# File 'livecheck/options.rb', line 60 def to_h = to_hash.transform_keys(&:to_sym) |
#to_hash ⇒ Hash{String => T.untyped}
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a Hash of all instance variables, using String keys.
54 55 56 |
# File 'livecheck/options.rb', line 54 def to_hash T.let(serialize, T::Hash[String, T.untyped]) end |
#url_options ⇒ Hash{Symbol => T.untyped}
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
Returns a Hash of options that are provided as arguments to url.
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'livecheck/options.rb', line 39 def { compressed:, cookies:, header:, homebrew_curl:, post_form:, post_json:, referer:, user_agent:, } end |