Class: Teapot::Target

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

Instance Attribute Summary collapse

Attributes inherited from Definition

#context, #description, #name, #package

Instance Method Summary collapse

Methods included from Dependency

chain, #dependencies, #depends, #depends?, #priority, #priority=, #provides, #provides?, #provisions

Methods inherited from Definition

#path, #pretty_print, #to_s

Constructor Details

#initialize(context, package, name) ⇒ Target

Returns a new instance of Target.



35
36
37
38
39
40
41
# File 'lib/teapot/target.rb', line 35

def initialize(context, package, name)
	super context, package, name
	
	@build = nil
	
	@rulebook = Build::Rulebook.new
end

Instance Attribute Details

#rulebookObject (readonly)

Returns the value of attribute rulebook.



43
44
45
# File 'lib/teapot/target.rb', line 43

def rulebook
  @rulebook
end

Instance Method Details

#build(&block) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/teapot/target.rb', line 85

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

#environment(configuration) ⇒ Object Also known as: environment_for_configuration

Given a specific configuration, generate the build environment based on this target and it’s provision chain.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/teapot/target.rb', line 61

def environment(configuration)
	chain = provision_chain(configuration)
	
	environments = []
	
	# Calculate the dependency chain's ordered environments:
	environments += chain.provisions.collect do |provision|
		Build::Environment.new(&provision.value)
	end
	
	# Per-configuration package package environment:
	environments << @package.options[:environment]
	
	# Merge all the environments together:
	environment = Build::Environment.combine(*environments)
	
	environment.merge do
		default platforms_path configuration.platforms_path
	end
end

#freezeObject



45
46
47
48
49
50
# File 'lib/teapot/target.rb', line 45

def freeze
	@build.freeze
	@rulebook.freeze
	
	super
end

#provision_chain(configuration) ⇒ Object

Given a configuration, compute the dependency chain for this target.



53
54
55
56
57
58
# File 'lib/teapot/target.rb', line 53

def provision_chain(configuration)
	# Reduce the number of keystrokes for good health:
	context = configuration.context
	
	chain = Dependency::chain(context.selection, self.dependencies, context.targets.values)
end