Sha256: 2ae32db104c9a8753d1e0559962a8d365472e7f1f5bb6e2fcae607e4fed563a1

Contents?: true

Size: 925 Bytes

Versions: 2

Compression:

Stored size: 925 Bytes

Contents

require_relative 'fetcher'

module TravisCheckRubies
  class TravisIndex
    ROOT_URL = 'https://rubies.travis-ci.org/'

    def version_strings
      index_urls.select do |url|
        url.start_with?(base_url)
      end.map do |url|
        url[%r{([^/]+)\.tar\.(?:gz|bz2)$}, 1]
      end
    end

  private

    def index_urls
      @index_urls ||= TravisCheckRubies::Fetcher.new(ROOT_URL + 'index.txt').data.split("\n")
    end

    def base_url
      @base_url ||= if ENV['TRAVIS']
        sys_path = `rvm debug`[/(?:system|remote.path):\s*"(.*?)"/, 1]
        "#{ROOT_URL}#{sys_path}/"
      else
        base_ubuntu_url = "#{ROOT_URL}ubuntu/"
        first_ubuntu_url = index_urls.sort.find{ |url| url.start_with?(base_ubuntu_url) }
        fail "First ubuntu url (#{ROOT_URL}ubuntu/*) not fount out of:\n#{index_urls.join("\n")}" unless first_ubuntu_url
        first_ubuntu_url[%r{^.*/}]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
travis_check_rubies-0.5.1 lib/travis_check_rubies/travis_index.rb
travis_check_rubies-0.5.0 lib/travis_check_rubies/travis_index.rb