Class: Chronicle::ETL::CLI::Connectors
- Inherits:
-
SubcommandBase
- Object
- Thor
- CLIBase
- SubcommandBase
- Chronicle::ETL::CLI::Connectors
- Defined in:
- lib/chronicle/etl/cli/connectors.rb
Overview
TODO:
make this work with new plugin system (i.e. no loading of all plugins)
CLI commands for working with ETL connectors
Instance Method Summary collapse
-
#list ⇒ Object
Display all available connectors that chronicle-etl has access to.
- #show(phase, identifier) ⇒ Object
Methods inherited from SubcommandBase
banner, help, subcommand_prefix
Instance Method Details
#list ⇒ Object
Display all available connectors that chronicle-etl has access to
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/chronicle/etl/cli/connectors.rb', line 15 def list connector_info = Chronicle::ETL::Registry::Connectors.connectors.map do |connector_registration| { identifier: connector_registration.identifier, phase: connector_registration.phase, description: connector_registration.descriptive_phrase, source: connector_registration.source, core: connector_registration.built_in? ? '✓' : '', class: connector_registration.klass_name } end connector_info = connector_info.sort_by do |a| [a[:core].to_s, a[:provider], a[:phase], a[:identifier]] end headers = connector_info.first.keys.map do |key| key.to_s.upcase.bold end table = TTY::Table.new(headers, connector_info.map(&:values)) puts table.render(indent: 0, padding: [0, 2]) end |
#show(phase, identifier) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/chronicle/etl/cli/connectors.rb', line 40 def show(phase, identifier) unless %w[extractor transformer loader].include?(phase) cli_fail(message: 'Phase argument must be one of: [extractor, transformer, loader]') end begin connector = Chronicle::ETL::Registry::Connectors.find_by_phase_and_identifier(phase.to_sym, identifier) rescue Chronicle::ETL::ConnectorNotAvailableError, Chronicle::ETL::PluginError => e cli_fail(message: "Could not find #{phase} #{identifier}", exception: e) end puts connector.klass.to_s.bold puts " #{connector.descriptive_phrase}" puts puts 'Settings:' headers = %w[name default required].map { |h| h.to_s.upcase.bold } settings = connector.klass.settings.map do |name, setting| [ name, setting.default, setting.required ? 'yes' : 'no' ] end table = TTY::Table.new(headers, settings) puts table.render(indent: 0, padding: [0, 2]) end |