Class: Rake::Pipeline::DSL::ProjectDSL

Inherits:
Object
  • Object
show all
Defined in:
lib/rake-pipeline/dsl/project_dsl.rb

Overview

This class exists purely to provide a convenient DSL for configuring a project.

All instance methods of ProjectDSL are available in the context the block passed to Rake::Pipeline::Project.Project.build.

When configuring a project, you must provide an output root and a series of files using at least one #input block.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ void

Create a new Rake::Pipeline::DSL::ProjectDSL to configure a project.

Parameters:

  • project (Project)

    the project that the ProjectDSL should configure.


33
34
35
36
37
38
39
# File 'lib/rake-pipeline/dsl/project_dsl.rb', line 33

def initialize(project)
  @project = project
  @before_filters = []
  @after_filters = []
  @project.before_filters = @before_filters
  @project.after_filters = @after_filters
end

Instance Attribute Details

#projectProject (readonly)

Returns the project the DSL should configure

Returns:

  • (Project)

    the project the DSL should configure


14
15
16
# File 'lib/rake-pipeline/dsl/project_dsl.rb', line 14

def project
  @project
end

Class Method Details

.evaluate(project, &block) ⇒ void

This method returns an undefined value.

Configure a project with a passed in block.

Parameters:

  • project (Project)

    the project that the ProjectDSL should configure.

  • block (Proc)

    the block describing the configuration. This block will be evaluated in the context of a new instance of Rake::Pipeline::DSL::ProjectDSL


24
25
26
# File 'lib/rake-pipeline/dsl/project_dsl.rb', line 24

def self.evaluate(project, &block)
  new(project).instance_eval(&block)
end

Instance Method Details

#after_filter(klass, *args, &block) ⇒ Object

Add a filter to every input block. The parameters to after_filter are the same as the parameters to Rake::Pipeline::DSL::PipelineDSL#filter.

Filters will be executed after the specified filters in insertion order.

See Also:

  • Rake::Pipeline::DSL::ProjectDSL.{PipelineDSL{PipelineDSL#filter}

61
62
63
# File 'lib/rake-pipeline/dsl/project_dsl.rb', line 61

def after_filter(klass, *args, &block)
  @after_filters.push [klass, args, block]
end

#before_filter(klass, *args, &block) ⇒ Object

Add a filter to every input block. The parameters to before_filter are the same as the parameters to Rake::Pipeline::DSL::PipelineDSL#filter.

Filters will be executed before the specified filters in reverse of insertion order.

See Also:

  • Rake::Pipeline::DSL::ProjectDSL.{PipelineDSL{PipelineDSL#filter}

49
50
51
# File 'lib/rake-pipeline/dsl/project_dsl.rb', line 49

def before_filter(klass, *args, &block)
  @before_filters.unshift [klass, args, block]
end

#input(*inputs, &block) ⇒ Object Also known as: inputs

Add a new pipeline with the given inputs to the project.


93
94
95
96
97
98
99
# File 'lib/rake-pipeline/dsl/project_dsl.rb', line 93

def input(*inputs, &block)
  # Allow pipelines without a specified block. This is possible
  # if before and after filters are all that are needed for a
  # given input.
  block = proc {} unless block_given?
  project.build_pipeline(*inputs, &block)
end

#map(path, &block) ⇒ Object


102
103
104
# File 'lib/rake-pipeline/dsl/project_dsl.rb', line 102

def map(path, &block)
  project.maps[path] = block
end

#output(root) ⇒ void

This method returns an undefined value.

Specify the default output directory for the project.

Pipelines created in this project will place their outputs here unless the value is overriden in their #input block.

Parameters:

  • root (String)

    the output directory.


73
74
75
# File 'lib/rake-pipeline/dsl/project_dsl.rb', line 73

def output(root)
  project.default_output_root = root
end

#tmpdir(root) ⇒ void

This method returns an undefined value.

Specify the location of the root temporary directory.

Pipelines will store intermediate build artifacts in a subdirectory of this directory.

This defaults to “tmp” in the current working directory.

Parameters:

  • root (String)

    the temporary directory


86
87
88
# File 'lib/rake-pipeline/dsl/project_dsl.rb', line 86

def tmpdir(root)
  project.tmpdir = root
end