Class: Appraisal::Matrix::RubygemsHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/appraisal/matrix/rubygems_helper.rb

Class Method Summary collapse

Class Method Details

.versions_to_test(gem_name, version_requirement, step) ⇒ Set

Returns a set of versions to test against for a given gem.

Parameters:

  • gem_name (String, Symbol)

    The name of the gem.

  • version_requirement (Gem::Requirement)

    The version requirement for the gem.

  • step (Symbol)

    The step value.

Returns:

  • (Set)

    A set of versions to test against.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/appraisal/matrix/rubygems_helper.rb', line 17

def versions_to_test(gem_name, version_requirement, step)
  # Generate a set to store the versions to test against 
  versions_to_test = Set.new

  # Load versions from rubygems api
  URI.parse("https://rubygems.org/api/v1/versions/#{gem_name}.json").open do |raw_version_data|
    JSON.parse(raw_version_data.read).each do |version_data|
      version = Gem::Version.new(version_data['number'])
      versions_to_test << version_for_step(version, step) if include_version?(version, version_requirement)
    end
  end

  versions_to_test
end