Sha256: 266e96047a6e94d667d4f7466346d2f6775df478cccf67cdd6053523081de8b2

Contents?: true

Size: 953 Bytes

Versions: 4

Compression:

Stored size: 953 Bytes

Contents

require 'contracts'
require 'concourse-fuselage'
require 'concourse-resource/rubygems/core'
require 'concourse-resource/rubygems/gem_not_found'
require 'gems'

module ConcourseResource
  module RubyGems
    # Check Step
    class Check < Fuselage::Check
      include Core

      Contract None => ArrayOf[HashOf[String, String]]
      def versions
        ::Gems
          .versions(gem)
          .tap { |response| raise GemNotFound, response if response.is_a? String }
          .sort_by { |version| version['created_at'] }
          .map { |version| { 'version' => version.fetch('number') } }
      rescue GemNotFound => message
        STDERR.puts message
        abort
      end

      Contract None => HashOf[String, String]
      def latest
        versions.last
      end

      Contract HashOf[String, String] => ArrayOf[HashOf[String, String]]
      def since(version)
        versions[versions.index(version)..-1]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
concourse-resource-rubygems-0.3.1 lib/concourse-resource/rubygems/check.rb
concourse-resource-rubygems-0.3.0 lib/concourse-resource/rubygems/check.rb
concourse-resource-rubygems-0.2.0 lib/concourse-resource/rubygems/check.rb
concourse-resource-rubygems-0.1.7 lib/concourse-resource/rubygems/check.rb