Sha256: 0a57087810e60fbaa0b25844ca9cff5fc4e557b1e800a9ea42ddf2fd505c44b6

Contents?: true

Size: 1.92 KB

Versions: 4

Compression:

Stored size: 1.92 KB

Contents

module DeployGate
  module Commands
    module Deploy
      class Push
        BASE_URL = 'https://deploygate.com'

        class << self

          # @param [Array] args
          # @param [Commander::Command::Options] options
          # @return [void]
          def upload(args, options)
            session = DeployGate::Session.new()
            unless session.login?
              Init.login
              session = DeployGate::Session.new()
            end

            message        = options.message
            owner          = options.user || session.name
            open           = options.open
            disable_notify = options.disable_notify
            file_path      = args.first

            data = nil
            print "Uploading to #{owner}.."
            begin
              data = DeployGate::Deploy.push(file_path, owner, message, disable_notify) {
                print '.'
                sleep 0.2
              }
            rescue => e
              upload_error(e)
            end

            upload_success(data, open)
          end

          # @return [Boolean]
          def openable?
            RbConfig::CONFIG['host_os'].include?('darwin')
          end

          # @param [Hash] data
          # @param [Boolean] open
          # @return [void]
          def upload_success(data, open)
            Message::Success.print('done')
            data_message = <<EOS
Name: \t\t #{data[:application_name]}
Owner: \t\t #{data[:owner_name]}
Package: \t #{data[:package_name]}
Revision: \t #{data[:revision]}
URL: \t\t #{data[:web_url]}
EOS
            puts(data_message)
            if((open || data[:revision] == 1) && openable?)
              system "open #{data[:web_url]}"
            end
          end

          # @param [StandardError] error
          # @return [void]
          def upload_error(error)
            Message::Error.print('failed')
            raise error
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
deploygate-0.0.4 lib/deploygate/commands/deploy/push.rb
deploygate-0.0.3 lib/deploygate/commands/deploy/push.rb
deploygate-0.0.2 lib/deploygate/commands/deploy/push.rb
deploygate-0.0.1 lib/deploygate/commands/deploy/push.rb