Class: Semverve::PublishedVersion
- Inherits:
-
Object
- Object
- Semverve::PublishedVersion
- Defined in:
- lib/semverve/published_version.rb
Overview
Checks whether the current gem version already exists on a RubyGems-compatible host.
Class Attribute Summary collapse
-
.http_getter ⇒ #call
Returns the HTTP response fetcher.
Instance Method Summary collapse
-
#check ⇒ void
Raises if the current version already exists.
-
#initialize(configuration, current_version) ⇒ Semverve::PublishedVersion
constructor
Initializes a published-version check.
-
#published? ⇒ Boolean
Whether the current version already exists on the configured host.
Constructor Details
#initialize(configuration, current_version) ⇒ Semverve::PublishedVersion
Initializes a published-version check.
38 39 40 41 |
# File 'lib/semverve/published_version.rb', line 38 def initialize(configuration, current_version) @configuration = configuration @current_version = current_version end |
Class Attribute Details
.http_getter ⇒ #call
Returns the HTTP response fetcher.
26 27 28 |
# File 'lib/semverve/published_version.rb', line 26 def http_getter @http_getter ||= ->(uri) { Net::HTTP.get_response(uri) } end |
Instance Method Details
#check ⇒ void
This method returns an undefined value.
Raises if the current version already exists.
55 56 57 58 59 |
# File 'lib/semverve/published_version.rb', line 55 def check if published? raise Error, "#{configuration.gem_name} #{current_version} already exists on #{configuration.rubygems_host}." end end |
#published? ⇒ Boolean
Whether the current version already exists on the configured host.
47 48 49 |
# File 'lib/semverve/published_version.rb', line 47 def published? versions.any? { |version| version.fetch("number", nil).to_s == current_version.to_s } end |