Class: Rubuild::Load::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/rubuild/load/info.rb

Overview

Rubuild::Load::Info

Instance Method Summary collapse

Constructor Details

#initialize(env, path, name) ⇒ Info

Returns a new instance of Info.



12
13
14
15
16
17
18
19
# File 'lib/rubuild/load/info.rb', line 12

def initialize(env, path, name)
  self.rubuild_load_info__env = env
  self.rubuild_load_info__path = path
  self.rubuild_load_info__location = Rubuild::Env::Location.new(name, env.build_factory)
  self.rubuild_load_info__commit_dep = self.rubuild_load_info__env.build_factory.create_dep(
    self.method(:_commit), "#{self.class.to_s}\#commit(#{name})")
  self.rubuild_load_info__location.found_dep.add_parent(self.rubuild_load_info__commit_dep)
end

Instance Method Details

#_commit(dep) ⇒ Object

Rubuild::Load::Info#initialize



21
22
23
# File 'lib/rubuild/load/info.rb', line 21

def _commit(dep)
  self.rubuild_load_info__location.set_data(nil)
end

#_require_satisfied(dep, required, block) ⇒ Object

Rubuild::Load::Info#require!



43
44
45
# File 'lib/rubuild/load/info.rb', line 43

def _require_satisfied(dep, required, block)
  block.call(required.data)
end

#provide(nm) ⇒ Object

Rubuild::Load::Info#_commit



25
26
27
# File 'lib/rubuild/load/info.rb', line 25

def provide(nm)
  Rubuild::Env::Provider.new(self.rubuild_load_info__env, self.location.name + nm)
end

#require(req_desc) ⇒ Object

Rubuild::Load::Info#provide



29
30
31
# File 'lib/rubuild/load/info.rb', line 29

def require(req_desc)
  Rubuild::Env::Requirer.new(self.rubuild_load_info__env, req_desc)
end

#require!(req_desc, &block) ⇒ Object

Rubuild::Load::Info#require



33
34
35
36
37
38
39
40
41
# File 'lib/rubuild/load/info.rb', line 33

def require!(req_desc, &block)
  required = Rubuild::Env::Requirer.new(self.rubuild_load_info__env, req_desc)
  satisfied_dep = self.rubuild_load_info__env.build_factory.create_dep(
    self.method(:_require_satisfied),
    "#{self.class.to_s}(#{self.location.name}).require!(#{required.location.name})",
    required.location, block)
  satisfied_dep.add_parent(required.location.found_dep)
  self.rubuild_load_info__commit_dep.add_parent(satisfied_dep)
end

#with(&block) ⇒ Object

Rubuild::Load::Info#require_satisfied



47
48
49
# File 'lib/rubuild/load/info.rb', line 47

def with(&block)
  self.instance_eval(&block)
end