Class: Aspera::Rest::Parameters

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/aspera/rest/parameters.rb

Overview

Global settings for Rest::Client For example to remove certificate verification globally: Parameters.instance.session_cb = lambda{|http|http.verify_mode=OpenSSL::SSL::VERIFY_NONE}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#download_partial_suffix ⇒ String

Returns Suffix of file being downloaded, removed when download is complete.

Returns:

  • (String) —

    Suffix of file being downloaded, removed when download is complete



20
21
22
# File 'lib/aspera/rest/parameters.rb', line 20

def download_partial_suffix
  @download_partial_suffix
end

#progress_bar ⇒ Object?

Returns Progress bar, receives event calls during download.

Returns:

  • (Object, nil) —

    Progress bar, receives event calls during download



34
35
36
# File 'lib/aspera/rest/parameters.rb', line 34

def progress_bar
  @progress_bar
end

#retry_max ⇒ Integer

Returns Maximum number of retries on error (first call not included).

Returns:

  • (Integer) —

    Maximum number of retries on error (first call not included)



28
29
30
# File 'lib/aspera/rest/parameters.rb', line 28

def retry_max
  @retry_max
end

#retry_on_error ⇒ Boolean

Returns Retry on any error (network or HTTP).

Returns:

  • (Boolean) —

    Retry on any error (network or HTTP)



22
23
24
# File 'lib/aspera/rest/parameters.rb', line 22

def retry_on_error
  @retry_on_error
end

#retry_on_timeout ⇒ Boolean

Returns Retry on connection timeout.

Returns:

  • (Boolean) —

    Retry on connection timeout



24
25
26
# File 'lib/aspera/rest/parameters.rb', line 24

def retry_on_timeout
  @retry_on_timeout
end

#retry_on_unavailable ⇒ Boolean

Returns Retry on HTTP code 503 (service unavailable).

Returns:

  • (Boolean) —

    Retry on HTTP code 503 (service unavailable)



26
27
28
# File 'lib/aspera/rest/parameters.rb', line 26

def retry_on_unavailable
  @retry_on_unavailable
end

#retry_sleep ⇒ Integer

Returns Seconds to wait before retry.

Returns:

  • (Integer) —

    Seconds to wait before retry



30
31
32
# File 'lib/aspera/rest/parameters.rb', line 30

def retry_sleep
  @retry_sleep
end

#session_cb ⇒ Proc?

Returns Called on new HTTP session, with the Net::HTTP as argument, e.g. to set timeouts or certificate verification.

Returns:

  • (Proc, nil) —

    Called on new HTTP session, with the Net::HTTP as argument, e.g. to set timeouts or certificate verification



32
33
34
# File 'lib/aspera/rest/parameters.rb', line 32

def session_cb
  @session_cb
end

#spinner_cb ⇒ Proc?

Returns Called with (title = nil, action: :spin) to display progress of long operations.

Returns:

  • (Proc, nil) —

    Called with (title = nil, action: :spin) to display progress of long operations



36
37
38
# File 'lib/aspera/rest/parameters.rb', line 36

def spinner_cb
  @spinner_cb
end

#user_agent ⇒ String

Returns HTTP request header: User-Agent.

Returns:

  • (String) —

    HTTP request header: User-Agent



18
19
20
# File 'lib/aspera/rest/parameters.rb', line 18

def user_agent
  @user_agent
end

Class Method Details

.instance ⇒ Parameters

Returns the singleton instance of Parameters

Returns:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/aspera/rest/parameters.rb', line 14

class Parameters
  include Singleton

  # @return [String] HTTP request header: `User-Agent`
  attr_accessor :user_agent
  # @return [String] Suffix of file being downloaded, removed when download is complete
  attr_accessor :download_partial_suffix
  # @return [Boolean] Retry on any error (network or HTTP)
  attr_accessor :retry_on_error
  # @return [Boolean] Retry on connection timeout
  attr_accessor :retry_on_timeout
  # @return [Boolean] Retry on HTTP code 503 (service unavailable)
  attr_accessor :retry_on_unavailable
  # @return [Integer] Maximum number of retries on error (first call not included)
  attr_accessor :retry_max
  # @return [Integer] Seconds to wait before retry
  attr_accessor :retry_sleep
  # @return [Proc, nil] Called on new HTTP session, with the `Net::HTTP` as argument, e.g. to set timeouts or certificate verification
  attr_accessor :session_cb
  # @return [Object, nil] Progress bar, receives `event` calls during download
  attr_accessor :progress_bar
  # @return [Proc, nil] Called with `(title = nil, action: :spin)` to display progress of long operations
  attr_accessor :spinner_cb

  private

  # Set default values
  def initialize
    @user_agent = 'RubyAsperaRest'
    @download_partial_suffix = '.http_partial'
    @retry_on_error = false
    @retry_on_timeout = true
    @retry_on_unavailable = true
    @retry_max = 1
    @retry_sleep = 4
    @session_cb = nil
    @progress_bar = nil
    @spinner_cb = nil
  end
end