Class: Mammoth::Commands::StartCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/mammoth/commands/start_command.rb

Overview

Starts a Mammoth application and prints the processed work count.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, source: nil, output: $stdout, lifecycle_hooks: LifecycleHooks.new) ⇒ StartCommand

Returns a new instance of StartCommand.

Parameters:

  • config (Mammoth::Configuration)

    loaded configuration

  • source (#each, nil) (defaults to: nil)

    optional injected source

  • output (#puts) (defaults to: $stdout)

    output stream

  • lifecycle_hooks (Mammoth::LifecycleHooks, Hash) (defaults to: LifecycleHooks.new)

    local lifecycle callbacks



13
14
15
16
17
18
# File 'lib/mammoth/commands/start_command.rb', line 13

def initialize(config, source: nil, output: $stdout, lifecycle_hooks: LifecycleHooks.new)
  @config = config
  @source = source
  @output = output
  @lifecycle_hooks = lifecycle_hooks
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



7
8
9
# File 'lib/mammoth/commands/start_command.rb', line 7

def config
  @config
end

#lifecycle_hooksObject (readonly)

Returns the value of attribute lifecycle_hooks.



7
8
9
# File 'lib/mammoth/commands/start_command.rb', line 7

def lifecycle_hooks
  @lifecycle_hooks
end

#outputObject (readonly)

Returns the value of attribute output.



7
8
9
# File 'lib/mammoth/commands/start_command.rb', line 7

def output
  @output
end

#sourceObject (readonly)

Returns the value of attribute source.



7
8
9
# File 'lib/mammoth/commands/start_command.rb', line 7

def source
  @source
end

Instance Method Details

#callInteger

Returns process-style status code.

Returns:

  • (Integer)

    process-style status code



21
22
23
24
25
# File 'lib/mammoth/commands/start_command.rb', line 21

def call
  processed = Application.new(config, source: source, lifecycle_hooks: lifecycle_hooks).start
  output.puts "Processed events: #{processed}"
  0
end