Sha256: 4dc4e1759d5ad4952d560ed3466822947535605fe32bc12420b6f705057d8f8f

Contents?: true

Size: 832 Bytes

Versions: 1

Compression:

Stored size: 832 Bytes

Contents

require 'em-eventsource'

module Gisha
  class Commands::Deploy
    attr_accessor :url, :key_id, :repo_path, :revision

    def initialize(url, key_id, repo_path, revision)
      @url = url
      @key_id = key_id
      @repo_path = repo_path
      @revision = revision
    end

    def exec
      EM.run do
        source = EventMachine::EventSource.new(url)

        source.on('progress') do |message|
          write(message)
        end

        source.on('completed') do |message|
          source.close
          EM.stop
        end

        source.error do |error|
          write(error)
          source.close
          EM.stop
        end
        source.start
      end

    end

    private

    def repo_name
      repo_path.split('/').last
    end

    def write(msg)
      puts "\e[1G-----> #{msg}\n"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gisha-0.0.5 lib/gisha/commands/deploy.rb