Class: Teapot::Build::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/teapot/build/target.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent) ⇒ Target

Returns a new instance of Target.



35
36
37
38
# File 'lib/teapot/build/target.rb', line 35

def initialize(parent)
  @parent = parent
  @configure = nil
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



40
41
42
# File 'lib/teapot/build/target.rb', line 40

def parent
  @parent
end

Class Method Details

.target(*args, &block) ⇒ Object



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

def self.target(*args, &block)
  instance = self.new(*args)

  if block_given?
    instance.instance_eval(&block)
  end

  return instance
end

Instance Method Details

#configure(&block) ⇒ Object



46
47
48
# File 'lib/teapot/build/target.rb', line 46

def configure(&block)
  @configure = Proc.new &block
end

#execute(command, environment, *arguments) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/teapot/build/target.rb', line 60

def execute(command, environment, *arguments)
  if @configure
    environment = environment.merge &@configure
  end

  # Flatten the environment to a hash:
  flat_environment = environment.flatten

  puts "Performing #{self.class}/#{command} for #{root}...".color(:cyan)

  # Show the environment to the user:
  Environment::System::dump(flat_environment)

  self.send(command, flat_environment, *arguments)
end

#rootObject



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

def root
  @parent.root
end