class Wire::WireCommands

WireCLI thor command line class

Attributes

commands[R]

internal array of commands (as objects)

Public Class Methods

new() click to toggle source

initialize wirecommands object

# File lib/wire/cli/cli_commands.rb, line 17
def initialize
  initialize_commands
end

Public Instance Methods

initialize_commands() click to toggle source

pre-build array of available commands see @commands

# File lib/wire/cli/cli_commands.rb, line 23
def initialize_commands
  @commands = {
    :init_command => InitCommand.new,
    :validate_command => ValidateCommand.new,
    :verify_command => VerifyCommand.new,
    :spec_command => SpecCommand.new,
    :up_command => UpCommand.new,
    :down_command => DownCommand.new
  } unless @commands
end
run_down(target_dir) click to toggle source

run the down command on target_dir model

# File lib/wire/cli/cli_commands.rb, line 71
def run_down(target_dir)
  # :reek:DuplicateCode
  if commands[:down_command].run({ :target_dir => target_dir })
    puts 'OK'.color(:green)
  else
    puts 'ERROR, detected errors'.color(:red)
  end
end
run_init(target_dir) click to toggle source

:reek: DuplicateCode run the init command on target_dir model

# File lib/wire/cli/cli_commands.rb, line 36
def run_init(target_dir)
  commands[:init_command].run({ :target_dir => target_dir })
end
run_spec(target_dir, b_run) click to toggle source

run the spec command on target_dir model

# File lib/wire/cli/cli_commands.rb, line 81
def run_spec(target_dir, b_run)
  commands[:spec_command].run({
                                :target_dir => target_dir,
                                :auto_run => b_run
                              })
end
run_up(target_dir) click to toggle source

run the up command on target_dir model

# File lib/wire/cli/cli_commands.rb, line 61
def run_up(target_dir)
  # :reek:DuplicateCode
  if commands[:up_command].run({ :target_dir => target_dir })
    puts 'OK'.color(:green)
  else
    puts 'ERROR, detected errors'.color(:red)
  end
end
run_validate(target_dir) click to toggle source

:reek: DuplicateCode run the validate command on target_dir model

# File lib/wire/cli/cli_commands.rb, line 42
def run_validate(target_dir)
  commands[:validate_command].run({ :target_dir => target_dir })
end
run_verify(target_dir) click to toggle source

run the verify command on target_dir model

# File lib/wire/cli/cli_commands.rb, line 47
def run_verify(target_dir)
  cmd_ver_obj = commands[:verify_command]
  cmd_ver_obj.run({ :target_dir => target_dir })
  if cmd_ver_obj.findings.size == 0
    puts 'OK, system is conforming to model'.color(:green)
  else
    puts 'ERROR, detected inconsistencies/errors.'.color(:red)
    # cmd_ver_obj.findings.each do |val_error|
    #   puts val_error.to_s
    # end
  end
end