Class: Bundler::Overrule::Swap
- Defined in:
- lib/bundler/overrule/rule.rb
Overview
swap 'httpclient', with: 'byroot-httpclient' — point every edge at a
different gem instead.
The substitute defaults to >= 0 rather than inheriting the original
edge's requirement: a fork's version numbers are its own lineage, and
carrying ~> 2.8 onto a fork that restarted at 1.0 would be
unresolvable for reasons the user never wrote down. Pass version: to
constrain it.
Constant Summary collapse
- DEFAULT_REQUIREMENT =
">= 0"
Instance Attribute Summary collapse
-
#replacement ⇒ Object
readonly
Returns the value of attribute replacement.
-
#requirement ⇒ Object
readonly
Returns the value of attribute requirement.
Attributes inherited from Rule
Instance Method Summary collapse
- #comparable_requirement ⇒ Object
-
#initialize(name, replacement, version: nil, reason: nil) ⇒ Swap
constructor
A new instance of Swap.
-
#pinned? ⇒ Boolean
True when the caller pinned the substitute, rather than taking
>= 0. - #to_s ⇒ Object
- #type ⇒ Object
Methods inherited from Rule
Constructor Details
#initialize(name, replacement, version: nil, reason: nil) ⇒ Swap
Returns a new instance of Swap.
124 125 126 127 128 |
# File 'lib/bundler/overrule/rule.rb', line 124 def initialize(name, replacement, version: nil, reason: nil) @replacement = normalize_replacement(replacement, name) @requirement = build_requirement(version || DEFAULT_REQUIREMENT) super(name, reason: reason) end |
Instance Attribute Details
#replacement ⇒ Object (readonly)
Returns the value of attribute replacement.
122 123 124 |
# File 'lib/bundler/overrule/rule.rb', line 122 def replacement @replacement end |
#requirement ⇒ Object (readonly)
Returns the value of attribute requirement.
122 123 124 |
# File 'lib/bundler/overrule/rule.rb', line 122 def requirement @requirement end |
Instance Method Details
#comparable_requirement ⇒ Object
134 135 136 |
# File 'lib/bundler/overrule/rule.rb', line 134 def comparable_requirement "#{replacement} #{requirement}" end |
#pinned? ⇒ Boolean
True when the caller pinned the substitute, rather than taking >= 0.
139 140 141 |
# File 'lib/bundler/overrule/rule.rb', line 139 def pinned? requirement != ::Gem::Requirement.create(DEFAULT_REQUIREMENT) end |
#to_s ⇒ Object
143 144 145 |
# File 'lib/bundler/overrule/rule.rb', line 143 def to_s pinned? ? "swap #{name} with #{replacement} #{requirement}" : "swap #{name} with #{replacement}" end |
#type ⇒ Object
130 131 132 |
# File 'lib/bundler/overrule/rule.rb', line 130 def type :swap end |