Sha256: ca9fb0f726091cf25c45baa7da6d708bd906c1472cf4481c9b99d77edb648e87

Contents?: true

Size: 980 Bytes

Versions: 5

Compression:

Stored size: 980 Bytes

Contents

module DeployGate
  class Deploy
    class NotLoginError < StandardError
    end
    class NotFileExistError < StandardError
    end
    class UploadError < StandardError
    end

    class << self

      # @param [String] file_path
      # @param [String] target_user
      # @param [String] message
      # @param [Boolean] disable_notify
      # @yield Upload process block
      # @return [Hash]
      def push(file_path, target_user, message, disable_notify = false, &process_block)
        raise NotFileExistError, 'Target file is not found' if file_path.nil? || !File.exist?(file_path)

        session = DeployGate::Session.new()
        raise NotLoginError, 'Must login user' unless session.login?
        token = session.token


        data = API::V1::Push.upload(file_path, target_user, token, message, disable_notify) { process_block.call unless process_block.nil? }
        raise UploadError, data[:message] if data[:error]

        data
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

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