TeapotSourceTeapotScript

class Script

The DSL exposed to the teapot.rb file.

Definitions

def initialize(context, package, path = TEAPOT_FILE)

Initialize a new script.

Signature

parameter context Context

The project context.

parameter package Package

The package.

parameter path String

The teapot file path.

Implementation

def initialize(context, package, path = TEAPOT_FILE)
	@context = context
	@package = package
	
	@defined = []
	@version = nil
	
	@configurations = Build::Dependency::Set.new
	
	@default_project = nil
	@default_configuration = nil
	
	@mtime = nil
end

def teapot_version(version)

Specify the minimum required teapot gem version for compatibility checks.

Signature

parameter version String

The required version.

Implementation

def teapot_version(version)
	version = version[0..2]
	
	if version >= MINIMUM_LOADER_VERSION && version <= LOADER_VERSION
		@version = version
	else
		raise IncompatibleTeapotError.new(package, version)
	end
end

def define_project(*arguments, **options)

Define a new project.

Signature

parameter arguments Array

The definition arguments.

Implementation

def define_project(*arguments, **options)
	project = Project.new(@context, @package, *arguments, **options)
	
	yield project
	
	@default_project = project
	@defined << project
end

def define_target(*arguments, **options)

Define a new target.

Signature

parameter arguments Array

The definition arguments.

Implementation

def define_target(*arguments, **options)
	target = Target.new(@context, @package, *arguments, **options)
	
	yield target
	
	target.update_environments!
	
	@defined << target
end

def define_configuration(*arguments, **options)

Define a new configuration.

Signature

parameter arguments Array

The definition arguments.

Implementation

def define_configuration(*arguments, **options)
	configuration = Configuration.new(@context, @package, *arguments, **options)
	
	yield configuration
	
	@default_configuration ||= configuration
	@defined << configuration
	@configurations << configuration
end

def host(*arguments, **options, &block)

Checks the host patterns and executes the block if they match.

Implementation

def host(*arguments, **options, &block)
	name = @context.options[:host_platform] || RUBY_PLATFORM
	
	if block_given?
		if arguments.find{|argument| argument === name}
			yield
		end
	else
		name
	end
end