Class: Aspera::Rest::Parameters
- Inherits:
-
Object
- Object
- Aspera::Rest::Parameters
- 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
-
#download_partial_suffix ⇒ String
Suffix of file being downloaded, removed when download is complete.
-
#progress_bar ⇒ Object?
Progress bar, receives
eventcalls during download. -
#retry_max ⇒ Integer
Maximum number of retries on error (first call not included).
-
#retry_on_error ⇒ Boolean
Retry on any error (network or HTTP).
-
#retry_on_timeout ⇒ Boolean
Retry on connection timeout.
-
#retry_on_unavailable ⇒ Boolean
Retry on HTTP code 503 (service unavailable).
-
#retry_sleep ⇒ Integer
Seconds to wait before retry.
-
#session_cb ⇒ Proc?
Called on new HTTP session, with the
Net::HTTPas argument, e.g. -
#spinner_cb ⇒ Proc
Called with
(title = nil, action: :spin)to display progress of long operations (default: no display). -
#user_agent ⇒ String
HTTP request header:
User-Agent.
Class Method Summary collapse
-
.instance ⇒ Parameters
Returns the singleton instance of Parameters.
Instance Attribute Details
#download_partial_suffix ⇒ String
Returns Suffix of file being downloaded, removed when download is complete.
23 24 25 |
# File 'lib/aspera/rest/parameters.rb', line 23 def download_partial_suffix @download_partial_suffix end |
#progress_bar ⇒ Object?
Returns Progress bar, receives event calls during download.
37 38 39 |
# File 'lib/aspera/rest/parameters.rb', line 37 def @progress_bar end |
#retry_max ⇒ Integer
Returns Maximum number of retries on error (first call not included).
31 32 33 |
# File 'lib/aspera/rest/parameters.rb', line 31 def retry_max @retry_max end |
#retry_on_error ⇒ Boolean
Returns Retry on any error (network or HTTP).
25 26 27 |
# File 'lib/aspera/rest/parameters.rb', line 25 def retry_on_error @retry_on_error end |
#retry_on_timeout ⇒ Boolean
Returns Retry on connection timeout.
27 28 29 |
# File 'lib/aspera/rest/parameters.rb', line 27 def retry_on_timeout @retry_on_timeout end |
#retry_on_unavailable ⇒ Boolean
Returns Retry on HTTP code 503 (service unavailable).
29 30 31 |
# File 'lib/aspera/rest/parameters.rb', line 29 def retry_on_unavailable @retry_on_unavailable end |
#retry_sleep ⇒ Integer
Returns Seconds to wait before retry.
33 34 35 |
# File 'lib/aspera/rest/parameters.rb', line 33 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.
35 36 37 |
# File 'lib/aspera/rest/parameters.rb', line 35 def session_cb @session_cb end |
#spinner_cb ⇒ Proc
Returns Called with (title = nil, action: :spin) to display progress of long operations (default: no display).
39 40 41 |
# File 'lib/aspera/rest/parameters.rb', line 39 def spinner_cb @spinner_cb end |
#user_agent ⇒ String
Returns HTTP request header: User-Agent.
21 22 23 |
# File 'lib/aspera/rest/parameters.rb', line 21 def user_agent @user_agent end |
Class Method Details
.instance ⇒ Parameters
Returns the singleton instance of Parameters
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 54 55 56 |
# File 'lib/aspera/rest/parameters.rb', line 17 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] Called with `(title = nil, action: :spin)` to display progress of long operations (default: no display) 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 = ->(_title = nil, action: :spin) {} end end |