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
# File 'lib/bozo/bozo_configuration.rb', line 9

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

Instance Attribute Details

#compilersObject (readonly)

Returns the configured compilers.



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

def compilers
  @compilers
end

#dependency_resolversObject (readonly)

Returns the configured dependency resolvers.



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

def dependency_resolvers
  @dependency_resolvers
end

#hooksObject (readonly)

Returns the configured hooks.



150
151
152
# File 'lib/bozo/bozo_configuration.rb', line 150

def hooks
  @hooks
end

#packagersObject (readonly)

Returns the configured packagers.



122
123
124
# File 'lib/bozo/bozo_configuration.rb', line 122

def packagers
  @packagers
end

#preparersObject (readonly)

Returns the configured preparers.



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

def preparers
  @preparers
end

#publishersObject (readonly)

Returns the configured publishers.



136
137
138
# File 'lib/bozo/bozo_configuration.rb', line 136

def publishers
  @publishers
end

#test_runnersObject (readonly)

Returns the configured test runners.



108
109
110
# File 'lib/bozo/bozo_configuration.rb', line 108

def test_runners
  @test_runners
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.



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

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.

Parameters:

  • location (String) (defaults to: nil)

    The path to set as the build tools location.



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

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.

Parameters:

  • type (Symbol)

    The name of the compiler.

  • block (Proc)

    Optional block to refine the configuration of the compiler.



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

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.

Parameters:

  • path (String)

    The path to the configuration file.



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

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.

Parameters:

  • type (Symbol)

    The name of the packager.

  • block (Proc)

    Optional block to refine the configuration of the packager.



131
132
133
# File 'lib/bozo/bozo_configuration.rb', line 131

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.

Parameters:

  • type (Symbol)

    The name of the preparer.

  • block (Proc)

    Optional block to refine the configuration of the preparer.



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

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.

Parameters:

  • type (Symbol)

    The name of the publisher.

  • block (Proc)

    Optional block to refine the configuration of the publisher.



145
146
147
# File 'lib/bozo/bozo_configuration.rb', line 145

def publish_with(type, &block) # :yields: publisher
  add_instance @publishers, Bozo::Publishers, 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.

Parameters:

  • type (Symbol)

    The name of the dependency resolver.

  • block (Proc)

    Optional block to refine the configuration of the dependency resolver.



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

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.

Parameters:

  • type (Symbol)

    The name of the test runner.

  • block (Proc)

    Optional block to refine the configuration of the test runner.



117
118
119
# File 'lib/bozo/bozo_configuration.rb', line 117

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.



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

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.

Parameters:

  • type (Symbol)

    The name of the hook.

  • block (Proc)

    Optional block to refine the configuration of the hook.



159
160
161
# File 'lib/bozo/bozo_configuration.rb', line 159

def with_hook(type, &block) # :yields: hook
  add_instance @hooks, Bozo::Hooks, type, block
end