Class: Rubuild::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/rubuild/env.rb,
lib/rubuild/env/location.rb,
lib/rubuild/env/provider.rb,
lib/rubuild/env/requirer.rb

Overview

Rubuild::Env Environment of Rubuild source modules.

Defined Under Namespace

Classes: Error, Location, Provider, Requirer

Instance Method Summary collapse

Constructor Details

#initialize(build_factory) ⇒ Env

Create a Rubuild::Env object.

build_factory

Rubuild::Build::Factory derived object, which will integrate the dependency objects in this Rubuild::Env.



78
79
80
81
# File 'lib/rubuild/env.rb', line 78

def initialize(build_factory)
  self.rubuild_env__build_factory = build_factory
  self.rubuild_env__providing = Hash.new
end

Instance Method Details

#_provide_require(dep, providing, requiring) ⇒ Object



109
110
111
# File 'lib/rubuild/env.rb', line 109

def _provide_require(dep, providing, requiring)
  requiring.set_data(providing.data)
end

#has_provider?(key) ⇒ Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/rubuild/env.rb', line 91

def has_provider?(key)
  self.rubuild_env__providing.has_key?(key)
end

#provide(key, providing) ⇒ Object

Rubuild::Env#initialize



83
84
85
86
87
88
89
90
# File 'lib/rubuild/env.rb', line 83

def provide(key, providing)
  if self.rubuild_env__providing.has_key?(key)
    raise(
      Error::Key::Full.new(
        self, key, self.rubuild_env__providing[key], providing))
  end
  self.rubuild_env__providing[key] = providing
end

#require(key, requiring) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/rubuild/env.rb', line 94

def require(key, requiring)
  providing = self.rubuild_env__providing[key]
  if not providing
    raise(Error::Key::Empty.new(self, key, requiring))
  end
  reqdep = self.rubuild_env__build_factory.create_dep(
    self.method(:_provide_require),
    "Rubuild::Env::require(#{key.dump}," +
    "#{providing.found_dep.name.dump}, " +
    "#{requiring.found_dep.name.dump}",
    providing, requiring)
  reqdep.add_parent(providing.found_dep)
  requiring.found_dep.add_parent(reqdep)
end

#selfObject

Rubuild::Env Rubuild::Build::Factory object for this Rubuild::Env.



70
# File 'lib/rubuild/env.rb', line 70

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