Class: Aspera::Cli::Context
- Inherits:
-
Object
- Object
- Aspera::Cli::Context
- Defined in:
- lib/aspera/cli/context.rb
Overview
Global objects shared with plugins
Constant Summary collapse
- MEMBERS =
Members that must be non-nil after bootstrap (validated in #validate)
%i[options transfer config formatter persistency man_header presets http_config main_folder mailer secret_finder].freeze
Instance Attribute Summary collapse
-
#pac_executor ⇒ Object
Optional: nil when no PAC script is configured.
-
#progress_bar ⇒ Object
Optional: nil when progress bar is disabled.
Instance Method Summary collapse
-
#initialize ⇒ nil
constructor
Initialize all members to nil, so that they are defined and can be validated later.
-
#only_manual! ⇒ Symbol
Set the context to manual-only mode.
-
#only_manual? ⇒ Boolean
Check if the context is in manual-only mode.
-
#validate ⇒ nil
Validate that all mandatory members are non-nil (detect bootstrap bugs).
Constructor Details
#initialize ⇒ nil
Initialize all members to nil, so that they are defined and can be validated later
42 43 44 45 46 |
# File 'lib/aspera/cli/context.rb', line 42 def initialize MEMBERS.each { |i| instance_variable_set(:"@#{i}", nil) } @progress_bar = nil @pac_executor = nil end |
Instance Attribute Details
#pac_executor ⇒ Object
Optional: nil when no PAC script is configured
38 39 40 |
# File 'lib/aspera/cli/context.rb', line 38 def pac_executor @pac_executor end |
#progress_bar ⇒ Object
Optional: nil when progress bar is disabled
36 37 38 |
# File 'lib/aspera/cli/context.rb', line 36 def @progress_bar end |
Instance Method Details
#only_manual! ⇒ Symbol
Set the context to manual-only mode
66 67 68 |
# File 'lib/aspera/cli/context.rb', line 66 def only_manual! @transfer = :only_manual end |
#only_manual? ⇒ Boolean
Check if the context is in manual-only mode
60 61 62 |
# File 'lib/aspera/cli/context.rb', line 60 def only_manual? transfer.eql?(:only_manual) end |
#validate ⇒ nil
Validate that all mandatory members are non-nil (detect bootstrap bugs)
51 52 53 54 55 56 |
# File 'lib/aspera/cli/context.rb', line 51 def validate MEMBERS.each do |i| Aspera.assert(instance_variable_defined?(:"@#{i}")) { "context member @#{i} is not defined" } Aspera.assert(!instance_variable_get(:"@#{i}").nil?) { "context member @#{i} is nil" } end end |