Class: Semverve::PublishedVersion

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(configuration, current_version) ⇒ Semverve::PublishedVersion

Initializes a published-version check.

Parameters:



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.

Returns:

  • (#call)


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

#checkvoid

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.

Returns:

  • (Boolean)


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