Class: Rubuild::Build::Simple::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/rubuild/build/simple/context.rb

Instance Method Summary collapse

Constructor Details

#initializeContext

Initialize self.



16
17
18
19
20
21
# File 'lib/rubuild/build/simple/context.rb', line 16

def initialize
  self.rubuild_build_simple_context__loaded = Hash.new
  self.rubuild_build_simple_context__runable = Array.new
  self.rubuild_build_simple_context__debug_level = 0
  self.rubuild_build_simple_context__debug_file = nil
end

Instance Method Details

#debug(level) ⇒ Object

Rubuild::Build::Context#run



81
82
83
84
85
86
# File 'lib/rubuild/build/simple/context.rb', line 81

def debug(level)
  if (self.rubuild_build_simple_context__debug_file &&
      level < self.rubuild_build_simple_context__debug_level)
    yield self.rubuild_build_simple_context__debug_file
  end
end

#dep_loaded(dep) ⇒ Object

Mark that a Rubuild::Dep object has been loaded into self. Used internally.

dep

Rubuild::Dep object loaded into self for future execution.

return

Return value is:

true

when this is the first time the dependency is being loaded into self,

false

otherwise.



30
31
32
33
34
35
36
# File 'lib/rubuild/build/simple/context.rb', line 30

def dep_loaded(dep)
  rval = ! self.rubuild_build_simple_context__loaded.has_key?(dep)
  if rval
    self.rubuild_build_simple_context__loaded[dep] = true
  end
  rval
end

#dep_runable(dep) ⇒ Object

Mark that a Rubuild::Dep object is now runable within the self Rubuild::Build::Context. This indicates that all of the dependency’s parents have been satisfied. Used internally.

dep

Rubuild::Dep that has become runable in self.



43
44
45
46
47
48
49
# File 'lib/rubuild/build/simple/context.rb', line 43

def dep_runable(dep)
  if ! self.rubuild_build_simple_context__loaded.has_key?(dep)
    raise Build::Context::Error::Runable.new(self, dep)
  end
  self.rubuild_build_simple_context__loaded.delete(dep)
  self.rubuild_build_simple_context__runable << dep
end

#runObject

Execute the dependencies loaded into this build context, in dependency order.



72
73
74
75
76
77
78
79
# File 'lib/rubuild/build/simple/context.rb', line 72

def run
  while self.rubuild_build_simple_context__runable.size > 0
    self.step
  end
  if self.rubuild_build_simple_context__loaded.keys.size > 0
    raise self.run_error
  end
end

#run_errorObject

Create an exception to capture the event that not all loaded dependencies were built. Used internally.

return

Rubuild::Build::Context::Error::Run exception.



55
56
57
# File 'lib/rubuild/build/simple/context.rb', line 55

def run_error
  Build::Context::Error::Run.new(self)
end

#selfObject

Rubuild::Build::Context Hash of dependencies that are loadable in this build context.



8
# File 'lib/rubuild/build/simple/context.rb', line 8

Safer::IVar.instance_variable(self, :loaded)

#stepObject

Execute a single dependency object. Not a supported interface in all derived classes.



61
62
63
64
65
66
67
68
# File 'lib/rubuild/build/simple/context.rb', line 61

def step
  if self.rubuild_build_simple_context__runable.size > 0
    dep = self.rubuild_build_simple_context__runable.shift
    if ! dep.built
      dep.runctx_build(self)
    end
  end
end