Sha256: 02982884ae53313e8ca5fab8934c45525afe03ff012e569b409aa3644bde08b8

Contents?: true

Size: 950 Bytes

Versions: 2

Compression:

Stored size: 950 Bytes

Contents

require 'concourse-fuselage'
require 'contracts'
require 'gems'
require_relative 'ambiguous_glob'
require_relative 'core'
require_relative 'support/source'

module ConcourseResource
  module RubyGems
    class Out < Fuselage::Out
      include Core
      include Support::Source

      Contract None => String
      def glob
        @glob ||= params.fetch('glob') { "pkg/#{gem}-*.gem" }
      end

      Contract None => ArrayOf[String]
      def files
        @files ||= Dir.glob(glob).tap do |matches|
          raise AmbiguousGlob, matches if matches.size > 1
        end
      rescue AmbiguousGlob => error
        STDERR.puts "Glob #{glob} matches too many files", error.message
        abort
      end

      Contract None => Any
      def configure!
        Gems.configure do |api|
          api.key = api_key
        end
      end

      def update!
        configure!
        files.each { |file| Gems.push file }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
concourse-resource-rubygems-0.4.6 lib/concourse-resource/rubygems/out.rb
concourse-resource-rubygems-0.4.5 lib/concourse-resource/rubygems/out.rb