Module: Discharger::SetupRunner

Defined in:
lib/discharger/setup_runner.rb,
lib/discharger/setup_runner/runner.rb,
lib/discharger/setup_runner/version.rb,
lib/discharger/setup_runner/configuration.rb,
lib/discharger/setup_runner/command_factory.rb,
lib/discharger/setup_runner/command_registry.rb,
lib/discharger/setup_runner/condition_evaluator.rb,
lib/discharger/setup_runner/commands/env_command.rb,
lib/discharger/setup_runner/commands/git_command.rb,
lib/discharger/setup_runner/prerequisites_loader.rb,
lib/discharger/setup_runner/commands/asdf_command.rb,
lib/discharger/setup_runner/commands/base_command.rb,
lib/discharger/setup_runner/commands/brew_command.rb,
lib/discharger/setup_runner/commands/yarn_command.rb,
lib/discharger/setup_runner/commands/config_command.rb,
lib/discharger/setup_runner/commands/custom_command.rb,
lib/discharger/setup_runner/commands/docker_command.rb,
lib/discharger/setup_runner/commands/bundler_command.rb,
lib/discharger/setup_runner/commands/database_command.rb,
lib/discharger/setup_runner/commands/pg_tools_command.rb,
lib/discharger/setup_runner/pre_commands/base_pre_command.rb,
lib/discharger/setup_runner/pre_commands/homebrew_pre_command.rb,
lib/discharger/setup_runner/pre_commands/pre_command_registry.rb,
lib/discharger/setup_runner/pre_commands/postgresql_tools_pre_command.rb

Defined Under Namespace

Modules: Commands, PreCommands Classes: CommandFactory, CommandRegistry, ConditionEvaluator, Configuration, DatabaseConfig, Error, PrerequisitesLoader, RedisConfig, Runner

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.configurationObject



17
18
19
# File 'lib/discharger/setup_runner.rb', line 17

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



13
14
15
# File 'lib/discharger/setup_runner.rb', line 13

def configure
  yield configuration if block_given?
end

.get_command(name) ⇒ Object



51
52
53
# File 'lib/discharger/setup_runner.rb', line 51

def get_command(name)
  CommandRegistry.get(name)
end

.list_commandsObject



47
48
49
# File 'lib/discharger/setup_runner.rb', line 47

def list_commands
  CommandRegistry.names
end

.register_command(name, command_class) ⇒ Object

Extension points for adding custom commands



29
30
31
# File 'lib/discharger/setup_runner.rb', line 29

def register_command(name, command_class)
  CommandRegistry.register(name, command_class)
end

.run(config_path = nil, logger = nil) {|runner| ... } ⇒ Object

Yields:

  • (runner)


21
22
23
24
25
26
# File 'lib/discharger/setup_runner.rb', line 21

def run(config_path = nil, logger = nil)
  config = config_path ? Configuration.from_file(config_path) : configuration
  runner = Runner.new(config, Dir.pwd, logger)
  yield runner if block_given?
  runner.run
end

.unregister_command(name) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/discharger/setup_runner.rb', line 33

def unregister_command(name)
  # Re-register all commands except the one to remove
  all_commands = {}
  CommandRegistry.names.each do |cmd_name|
    unless cmd_name == name.to_s
      all_commands[cmd_name] = CommandRegistry.get(cmd_name)
    end
  end
  CommandRegistry.clear
  all_commands.each do |cmd_name, cmd_class|
    CommandRegistry.register(cmd_name, cmd_class)
  end
end