Class: Aspera::Agent::Base
- Inherits:
-
Object
- Object
- Aspera::Agent::Base
- Defined in:
- lib/aspera/agent/base.rb
Overview
Base class for transfer agents
Constant Summary collapse
- RUBY_EXT =
'.rb'
Class Method Summary collapse
-
.agent_list ⇒ Object
discover available agents.
- .factory_create(agent, options) ⇒ Object
-
.to_move_options(default:, options:) ⇒ Object
compute options from user provided and default options.
Instance Method Summary collapse
-
#wait_for_completion ⇒ Object
Wait for all sessions to terminate and return the status of each session.
Class Method Details
.agent_list ⇒ Object
discover available agents
34 35 36 37 38 39 |
# File 'lib/aspera/agent/base.rb', line 34 def agent_list base_class = File.basename(__FILE__) Dir.entries(File.dirname(File.(__FILE__))).select do |file| file.end_with?(RUBY_EXT) && !file.eql?(base_class) end.map{|file|file[0..(-1 - RUBY_EXT.length)].to_sym} end |
.factory_create(agent, options) ⇒ Object
11 12 13 14 15 |
# File 'lib/aspera/agent/base.rb', line 11 def factory_create(agent, ) # Aspera.assert_values(agent, agent_list) require "aspera/agent/#{agent}" Aspera::Agent.const_get(agent.to_s.capitalize).new(**) end |
.to_move_options(default:, options:) ⇒ Object
compute options from user provided and default options
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/aspera/agent/base.rb', line 18 def (default:, options:) result = .symbolize_keys available = default.map{|k, v|"#{k}(#{v})"}.join(', ') result.each_key do |k| Aspera.assert_values(k, default.keys){"transfer agent parameter: #{k}"} # check it is the expected type: too limiting, as we can have an Integer or Float, or symbol and string # raise "Invalid value for transfer agent parameter: #{k}, expect #{default[k].class.name}" unless default[k].nil? || v.is_a?(default[k].class) end default.each do |k, v| raise "Missing required agent parameter: #{k}. Parameters: #{available}" if v.eql?(:required) && !result.key?(k) result[k] = v unless result.key?(k) end return result end |
Instance Method Details
#wait_for_completion ⇒ Object
Wait for all sessions to terminate and return the status of each session
43 44 45 46 47 48 49 50 |
# File 'lib/aspera/agent/base.rb', line 43 def wait_for_completion # list of: :success or "error message string" statuses = wait_for_transfers_completion @progress&.reset Aspera.assert_type(statuses, Array) Aspera.assert(statuses.none?{|i|!i.eql?(:success) && !i.is_a?(StandardError)}){"bad statuses content: #{statuses}"} return statuses end |