Class: Bozo::BozoConfiguration

Inherits:
Object
  • Object
show all
Includes:
ClassNameHelpers
Defined in:
lib/bozo/bozo_configuration.rb

Overview

Class used for defining the configuration of a build.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassNameHelpers

#to_class_name

Constructor Details

#initializeBozoConfiguration

Creates a new instance



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bozo/bozo_configuration.rb', line 9

def initialize
  @build_tools_location = nil
  @tools = []
  @compilers = []
  @dependency_resolvers = []
  @hooks = []
  @packagers = []
  @preparers = []
  @publishers = []
  @test_runners = []
  @version = nil
end

Instance Attribute Details

#compilersObject (readonly)

Returns the configured compilers.



110
111
112
# File 'lib/bozo/bozo_configuration.rb', line 110

def compilers
  @compilers
end

#dependency_resolversObject (readonly)

Returns the configured dependency resolvers.



65
66
67
# File 'lib/bozo/bozo_configuration.rb', line 65

def dependency_resolvers
  @dependency_resolvers
end

#hooksObject (readonly)

Returns the configured hooks.



166
167
168
# File 'lib/bozo/bozo_configuration.rb', line 166

def hooks
  @hooks
end

#packagersObject (readonly)

Returns the configured packagers.



138
139
140
# File 'lib/bozo/bozo_configuration.rb', line 138

def packagers
  @packagers
end

#preparersObject (readonly)

Returns the configured preparers.



79
80
81
# File 'lib/bozo/bozo_configuration.rb', line 79

def preparers
  @preparers
end

#publishersObject (readonly)

Returns the configured publishers.



152
153
154
# File 'lib/bozo/bozo_configuration.rb', line 152

def publishers
  @publishers
end

#test_runnersObject (readonly)

Returns the configured test runners.



124
125
126
# File 'lib/bozo/bozo_configuration.rb', line 124

def test_runners
  @test_runners
end

#toolsObject (readonly)

Returns the required tools



95
96
97
# File 'lib/bozo/bozo_configuration.rb', line 95

def tools
  @tools
end

Instance Method Details

#build_toolsObject

Returns the all the build tools required by the specified compilers, dependency resolvers, hooks, packagers, publishers and test runners.



54
55
56
57
58
59
60
61
62
# File 'lib/bozo/bozo_configuration.rb', line 54

def build_tools
  build_tools = get_build_tools @compilers
  build_tools |= get_build_tools @dependency_resolvers
  build_tools |= get_build_tools @hooks
  build_tools |= get_build_tools @packagers
  build_tools |= get_build_tools @preparers
  build_tools |= get_build_tools @publishers
  build_tools | (get_build_tools @test_runners)
end

#build_tools_location(location = nil) ⇒ Object

The location of the base build tools.

Sets and returns the location if a value is provided, otherwise returns the current value.

It is expected the build tools will be in sub-directory of this location according to the name of the tool and that the runner will be able to copy the contents of the sub-directory to a local directory via the ‘FileUtils.cp_r` method.



47
48
49
50
# File 'lib/bozo/bozo_configuration.rb', line 47

def build_tools_location(location = nil)
  @build_tools_location = location if location
  @build_tools_location
end

#compile_with(type, &block) ⇒ Object

Adds an instance of the named compiler to the compiler collection and yields it to the configuration block when one is specified.



119
120
121
# File 'lib/bozo/bozo_configuration.rb', line 119

def compile_with(type, &block) # :yields: compiler

  add_instance @compilers, Bozo::Compilers, type, block
end

#load(path) ⇒ Object

Loads the configuration from the specified file.



26
27
28
# File 'lib/bozo/bozo_configuration.rb', line 26

def load(path)
  instance_eval IO.read(path), path
end

#package_with(type, &block) ⇒ Object

Adds an instance of the named packager to the packager collection and yields it to the configuration block when one is specified.



147
148
149
# File 'lib/bozo/bozo_configuration.rb', line 147

def package_with(type, &block) # :yields: packager

  add_instance @packagers, Bozo::Packagers, type, block
end

#prepare(type, &block) ⇒ Object

Adds an instance of the named preparer to the preparer collection and yields it to the configuration block when one is specified.



74
75
76
# File 'lib/bozo/bozo_configuration.rb', line 74

def prepare(type, &block) # :yields: preparer

  add_instance @preparers, Bozo::Preparers, type, block
end

#publish_with(type, &block) ⇒ Object

Adds an instance of the named publisher to the publisher collection and yields it to the configuration block when one is specified.



161
162
163
# File 'lib/bozo/bozo_configuration.rb', line 161

def publish_with(type, &block) # :yields: publisher

  add_instance @publishers, Bozo::Publishers, type, block
end

#required_tool(type, &block) ⇒ Object

Adds an instance of the named tool to the tools collection and yields it to the configuration block when one is specified.



104
105
106
107
# File 'lib/bozo/bozo_configuration.rb', line 104

def required_tool(type, &block)
  @tools ||= []
  add_instance @tools, Bozo::Tools, type, block
end

#resolve_dependencies_with(type, &block) ⇒ Object

Adds an instance of the named dependency resolver to the dependency resolver collection and yields it to the configuration block when one is specified.



90
91
92
# File 'lib/bozo/bozo_configuration.rb', line 90

def resolve_dependencies_with(type, &block) # :yields: dependency_resolver

  add_instance @dependency_resolvers, Bozo::DependencyResolvers, type, block
end

#test_with(type, &block) ⇒ Object

Adds an instance of the named test runner to the test runner collection and yields it to the configuration block when one is specified.



133
134
135
# File 'lib/bozo/bozo_configuration.rb', line 133

def test_with(type, &block) # :yields: test_runner

  add_instance @test_runners, Bozo::TestRunners, type, block
end

#versionObject

The version of the project to build.



31
32
33
# File 'lib/bozo/bozo_configuration.rb', line 31

def version
  @version ||= Versioning::Version.load_from_file
end

#with_hook(type, &block) ⇒ Object Also known as: pre_build, pre_clean, post_clean, pre_uninstall, post_uninstall, pre_dependencies, post_dependencies, pre_prepare, post_prepare, pre_compile, post_compile, pre_test, post_test, pre_package, post_package, pre_publish, post_publish, post_build

Adds an instance of the named hook to the hook collection and yields it to the configuration block when one is specified.



175
176
177
# File 'lib/bozo/bozo_configuration.rb', line 175

def with_hook(type, &block) # :yields: hook

  add_instance @hooks, Bozo::Hooks, type, block
end