Class: Aspera::Agent::Factory
- Inherits:
-
Object
- Object
- Aspera::Agent::Factory
- 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.(__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)}.to_h do |agent_sym| [agent_sym, { long: agent_sym.to_s.capitalize, short: agent_sym.eql?(:direct) ? :a : agent_sym.to_s[0].to_sym }.freeze] end.freeze
Class Method Summary collapse
-
.instance ⇒ Factory
Returns the singleton instance of Factory.
Instance Method Summary collapse
-
#create(agent, options) ⇒ Object
Create new agent.
Class Method Details
.instance ⇒ Factory
Returns the singleton instance of Factory
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/aspera/agent/factory.rb', line 13 class Factory include Singleton # Create new agent def create(agent, ) Log.dump(:options, ) require "aspera/agent/#{agent}" Aspera::Agent.const_get(agent.to_s.capitalize).new(**) end IGNORED_ITEMS = %i[factory base] # Available agents: :long : Capitalized name string, :short : single character symbol ALL = Dir.children(File.dirname(File.(__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)}.to_h do |agent_sym| [agent_sym, { long: agent_sym.to_s.capitalize, short: agent_sym.eql?(:direct) ? :a : agent_sym.to_s[0].to_sym }.freeze] end.freeze private_constant :IGNORED_ITEMS end |