Class: Mammoth::Commands::BootstrapCommand

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

Overview

Initializes the configured operational-state backend.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, state_adapter: nil, output: $stdout) ⇒ BootstrapCommand

Returns a new instance of BootstrapCommand.

Parameters:



12
13
14
15
16
# File 'lib/mammoth/commands/bootstrap_command.rb', line 12

def initialize(config, state_adapter: nil, output: $stdout)
  @config = config
  @state_adapter = state_adapter || OperationalState::Registry.build_configured(config)
  @output = output
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



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

def config
  @config
end

#outputObject (readonly)

Returns the value of attribute output.



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

def output
  @output
end

#state_adapterObject (readonly)

Returns the value of attribute state_adapter.



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

def state_adapter
  @state_adapter
end

Instance Method Details

#callInteger

Returns process-style status code.

Returns:

  • (Integer)

    process-style status code



19
20
21
22
23
24
25
26
27
# File 'lib/mammoth/commands/bootstrap_command.rb', line 19

def call
  state_adapter.bootstrap!
  summary = state_adapter.summary
  output.puts "Operational state initialized"
  output.puts "Adapter: #{summary.fetch(:adapter)}"
  output.puts "Path: #{summary.fetch(:path)}" if summary.key?(:path)
  output.puts "Tables: #{Array(summary.fetch(:tables)).join(", ")}" if summary.key?(:tables)
  0
end