Sha256: 9988ee7d01c03642aa217a9253a3cc44c69615d04f40ea472c2bb5fe0476e3dd

Contents?: true

Size: 918 Bytes

Versions: 4

Compression:

Stored size: 918 Bytes

Contents

require 'celluloid'
require 'mime/types'

module Buildbox
  class Artifact::Uploader
    include Celluloid
    include Celluloid::Logger

    def initialize(api, access_token, build, artifacts)
      @api          = api
      @access_token = access_token
      @build        = build
      @artifacts    = artifacts
    end

    def prepare_and_upload
      info "Preparing #{@artifacts.count} artifacts for upload"

      responses = @api.create_artifacts(@access_token, @build, @artifacts)
      responses.each do |response|
        artifact = @artifacts.find { |artifact| artifact.id == response['id'] }

        artifact.remote_id           = response['artifact']['id']
        artifact.upload_instructions = response['artifact']['uploader']
      end

      @artifacts.each do |artifact|
        Celluloid::Actor[:artifact_poster_pool].async.post(@api, @access_token, @build, artifact)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
buildbox-0.6.2 lib/buildbox/artifact/uploader.rb
buildbox-0.6.1 lib/buildbox/artifact/uploader.rb
buildbox-0.6 lib/buildbox/artifact/uploader.rb
buildbox-0.6.beta3 lib/buildbox/artifact/uploader.rb