BakeSourceBakeBase

class Base

The base class for including module Bake::Scope instances which define class Bake::Recipe instances.

Definitions

def self.derive(path = [])

Generate a base class for the specified path.

Signature

parameter path Array(String)

The command path.

Implementation

def self.derive(path = [])
	klass = Class.new(self)
	
	klass.const_set(:PATH, path)
	
	return klass
end

def self.to_s

Format the class as a command.

Signature

returns String

Implementation

def self.to_s
	if path = self.path
		path.join(":")
	else
		super
	end
end

def self.path

The path of this derived base class.

Signature

returns Array(String)

Implementation

def self.path
	self.const_get(:PATH)
rescue
	nil
end

def path

The path for this derived base class.

Signature

returns Array(String)

Implementation

def path
	self.class.path
end

def output?(recipe)

If an instance generates output, it should override this method to return true, otherwise default output handling will be used (essentially the return value of the last recipe).

Signature

returns Boolean

Whether this instance handles its own output.

Implementation

def output?(recipe)
	false
end

def call(*arguments)

Proxy a method call using command line arguments through to the class Bake::Context instance.

Signature

parameter arguments Array(String)

Implementation

def call(*arguments)
	self.context.call(*arguments)
end

def recipes

Recipes defined in this scope.

Signature

yields {|recipe| ...}
parameter recipe Recipe
returns Enumerable

Implementation

def recipes
	return to_enum(:recipes) unless block_given?
	
	names = self.public_methods - Base.public_instance_methods
	
	names.each do |name|
		yield recipe_for(name)
	end
end

def recipe_for(name)

Look up a recipe with a specific name.

Signature

parameter name String

The instance method to look up.

Implementation

def recipe_for(name)
	Recipe.new(self, name)
end