Class: Bozo::Executor

Inherits:
Object
  • Object
show all
Includes:
Runner
Defined in:
lib/bozo/executor.rb

Overview

Class defining the structure of the build and responsible for executing tasks and their dependencies.

Instance Attribute Summary

Attributes included from Runner

#build_configuration, #env, #global_params, #params

Instance Method Summary collapse

Methods included from Runner

#build_server?, #environment, #execute_command, #pre_release?, #version

Methods included from Logging

#log_debug, #log_fatal, #log_info, #log_warn

Constructor Details

#initialize(build_configuration, global_params) ⇒ Executor

Create a new instance.

Parameters:

  • build_configuration (Configuration)

    The build configuration.

  • global_params (Hash)

    The global parameters



14
15
16
17
# File 'lib/bozo/executor.rb', line 14

def initialize(build_configuration, global_params)
  @build_configuration = build_configuration
  @global_params = cli_keys_to_ruby global_params
end

Instance Method Details

#clean(params, env) ⇒ Object

Runs the clean task.

Parameters:

  • params (Hash)

    The parameters for the command.

  • env (Hash)

    The environment that the command is run within.



39
40
41
42
43
44
45
# File 'lib/bozo/executor.rb', line 39

def clean(params, env)
  with_hooks :clean, params, env do
    log_info 'Cleaning project'
    clear_directory 'temp'
    clear_directory 'dist'
  end
end

#compile(params, env) ⇒ Object

Runs the compile task.

Parameters:

  • params (Hash)

    The parameters for the command.

  • env (Hash)

    The environment that the command is run within.



91
92
93
94
# File 'lib/bozo/executor.rb', line 91

def compile(params, env)
  prepare params, env
  execute_with_hooks :compile, params, env
end

#dependencies(params, env) ⇒ Object

Runs the dependency retrieval task.

Parameters:

  • params (Hash)

    The parameters for the command.

  • env (Hash)

    The environment that the command is run within.



68
69
70
71
72
# File 'lib/bozo/executor.rb', line 68

def dependencies(params, env)
  clean params, env
  retrieve_build_dependencies
  execute_with_hooks :dependencies, params, env
end

#execute(command, params, env) ⇒ Object

Executes the command using the given parameters and environment.

Parameters:

  • command (Symbol)

    The name of the command to execute.

  • params (Hash)

    The parameters for the command.

  • env (Hash)

    The environment that the command is run within.



27
28
29
30
31
# File 'lib/bozo/executor.rb', line 27

def execute(command, params, env)
  with_hooks :build, params, env do
    send command, params, env
  end
end

#package(params, env) ⇒ Object

Runs the package task.

Parameters:

  • params (Hash)

    The parameters for the command.

  • env (Hash)

    The environment that the command is run within.



113
114
115
116
# File 'lib/bozo/executor.rb', line 113

def package(params, env)
  test params, env
  execute_with_hooks :package, params, env
end

#prepare(params, env) ⇒ Object

Runs the prepare task.

Parameters:

  • params (Hash)

    The parameters for the command.

  • env (Hash)

    The environment that the command is run within.



80
81
82
83
# File 'lib/bozo/executor.rb', line 80

def prepare(params, env)
  dependencies params, env
  execute_with_hooks :prepare, params, env
end

#publish(params, env) ⇒ Object

Runs the publish task.

Parameters:

  • params (Hash)

    The parameters for the command.

  • env (Hash)

    The environment that the command is run within.



124
125
126
127
128
129
130
131
132
133
# File 'lib/bozo/executor.rb', line 124

def publish(params, env)
  if build_server?
    package params, env
    execute_with_hooks :publish, params, env
  else
    log_warn 'You can only publish a package from build server.'
    log_warn ''
    log_warn 'If you really need to publish the package then provide the --build-server switch but you should only be doing that as a last resort.'
  end
end

#test(params, env) ⇒ Object

Runs the test task.

Parameters:

  • params (Hash)

    The parameters for the command.

  • env (Hash)

    The environment that the command is run within.



102
103
104
105
# File 'lib/bozo/executor.rb', line 102

def test(params, env)
  compile params, env
  execute_with_hooks :test, params, env
end

#uninstall(params, env) ⇒ Object

Runs the uninstall task.

Parameters:

  • params (Hash)

    The parameters for the command.

  • env (Hash)

    The environment that the command is run within.



53
54
55
56
57
58
59
60
# File 'lib/bozo/executor.rb', line 53

def uninstall(params, env)
  clean params, env
  with_hooks :uninstall, params, env do
    log_info 'Uninstalling project'
    clear_directory 'packages'
    clear_directory 'build'
  end
end