Class: Ccs::Commands::Copy

Inherits:
Object
  • Object
show all
Defined in:
lib/ccs/commands/copy.rb

Overview

The copy command, responsible for copying a target to a destination, performing encryption and decryption as necessary.

The target and destinations can be:

  • STDIN/STDOUT: a ‘-` sign is interpreted as these standard streams

  • The Occson server: strings beginning with ‘ccs://` or `http(s)://` are interpreted as such

  • local files: everything not matching the previous descriptions is assumed to be a path on the local system

Instance Method Summary collapse

Constructor Details

#initialize(source, destination, access_token, passphrase, force: false) ⇒ Copy

Builds an instance of the Copy command.

Parameters:

  • source (String)

    ‘-` for STDIN, an URI or a local file path

  • destination (String)

    ‘-` for STDOUT, an URI or a local file path

  • access_token (String)

    Occson access token

  • passphrase (String)

    Passphrase used for encryption of the document

  • force (Boolean) (defaults to: false)

    Whether to overwrite target document in Occson, if any. Default ‘false`.



24
25
26
27
28
29
30
# File 'lib/ccs/commands/copy.rb', line 24

def initialize(source, destination, access_token, passphrase, force: false)
  @source = source
  @destination = destination
  @access_token = access_token
  @passphrase = passphrase
  @force = force
end

Instance Method Details

#callObject

Performs a transfer between locations - an upload if ‘@source` is local or STDIN, a download if `@source` is an URI.

No guarantees are made about the return values of this method.



36
37
38
# File 'lib/ccs/commands/copy.rb', line 36

def call
  download? ? download : upload
end