Class: Aspera::Agent::Factory

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/aspera/agent/factory.rb

Overview

Factory for Agents

Constant Summary collapse

ALL =

Available agents: :long : Capitalized name string, :short : single character symbol

Dir.children(File.dirname(File.expand_path(__FILE__)))
  .select{ |file| file.end_with?(Environment::RB_EXT)}
  .map{ |file| File.basename(file, Environment::RB_EXT).to_sym}
  .reject{ |item| IGNORED_ITEMS.include?(item)}.each_with_object({}) do |agent_sym, hash|
  hash[agent_sym] = {
    long:  agent_sym.to_s.capitalize,
    short: agent_sym.eql?(:direct) ? :a : agent_sym.to_s[0].to_sym
  }.freeze
end.freeze

Instance Method Summary collapse

Instance Method Details

#create(agent, options) ⇒ Object

Create new agent



13
14
15
16
17
# File 'lib/aspera/agent/factory.rb', line 13

def create(agent, options)
  Log.dump(:options, options)
  require "aspera/agent/#{agent}"
  Aspera::Agent.const_get(agent.to_s.capitalize).new(**options)
end