class CoinSync::RunCommandTask

Public Class Methods

new(config) click to toggle source
# File lib/coinsync/run_command_task.rb, line 5
def initialize(config)
  @config = config
end

Public Instance Methods

run(source_name, command, args = []) click to toggle source
# File lib/coinsync/run_command_task.rb, line 9
def run(source_name, command, args = [])
  source = @config.sources[source_name] or raise "Source not found in the config file: '#{source_name}'"
  importer = source.importer

  if importer.class.registered_commands.include?(command.to_sym)
    importer.send(command.to_sym, *args)
  else
    raise "#{source_name}: no such command: #{command}"
  end
end