Class: Teapot::Target

Inherits:
Definition show all
Includes:
Build::Dependency
Defined in:
lib/teapot/target.rb

Overview

A build target.

Instance Attribute Summary

Attributes inherited from Definition

#context, #description, #name, #package

Instance Method Summary collapse

Methods inherited from Definition

#inspect, #path, #to_s

Constructor Details

#initializeTarget

Initialize a new target.



23
24
25
26
27
# File 'lib/teapot/target.rb', line 23

def initialize(*)
	super
	
	@build = nil
end

Instance Method Details

#build(&block) ⇒ Object

Define the build block for this target.



41
42
43
44
45
46
47
# File 'lib/teapot/target.rb', line 41

def build(&block)
	if block_given?
		@build = block
	end
	
	return @build
end

#freezeObject

Make the target immutable after it has been completely defined with dependencies and build rules.



30
31
32
33
34
35
36
# File 'lib/teapot/target.rb', line 30

def freeze
	return self if frozen?
	
	@build.freeze
	
	super
end

#update_environments!Object

Update environments with the build block.



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/teapot/target.rb', line 50

def update_environments!
	return unless @build
	
	self.provisions.each do |key, provision|
		build = @build
		original = provision.value
		
		wrapper = proc do |*arguments|
			self.instance_exec(*arguments, &original) if original
			self.instance_exec(*arguments, &build) if build
		end
		
		provision.value = wrapper
	end
	
	@build = nil
end