Class: Mammoth::Commands::BootstrapCommand

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

Overview

Initializes the configured operational SQLite database.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of BootstrapCommand.

Parameters:

  • config (Mammoth::Configuration)

    loaded configuration

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

    output stream



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

def initialize(config, output: $stdout)
  @config = 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

Instance Method Details

#callInteger

Returns process-style status code.

Returns:

  • (Integer)

    process-style status code



17
18
19
20
21
22
23
# File 'lib/mammoth/commands/bootstrap_command.rb', line 17

def call
  store = SQLiteStore.connect(config.dig("sqlite", "path")).bootstrap!
  output.puts "SQLite database initialized"
  output.puts "Path: #{store.path}"
  output.puts "Tables: #{store.tables.join(", ")}"
  0
end