Class: GemLoader::Scope
- Inherits:
-
Object
- Object
- GemLoader::Scope
- Defined in:
- lib/gem_loader/scope.rb,
lib/gem_loader/scope/dsl.rb
Defined Under Namespace
Classes: Dsl
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#depend_scopes ⇒ Object
Returns the value of attribute depend_scopes.
-
#gems ⇒ Object
Returns the value of attribute gems.
-
#libs ⇒ Object
Returns the value of attribute libs.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #add_depend_scope(scope) ⇒ Object
- #all_gems ⇒ Object
- #dsl(&block) ⇒ Object
- #gem(name) ⇒ Object
-
#initialize(context, name) ⇒ Scope
constructor
A new instance of Scope.
- #load ⇒ Object
- #require ⇒ Object
Constructor Details
#initialize(context, name) ⇒ Scope
Returns a new instance of Scope.
7 8 9 10 11 |
# File 'lib/gem_loader/scope.rb', line 7 def initialize(context, name) self.context = context self.name = name self.depend_scopes, self.gems, self.libs = [], [], [] end |
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
5 6 7 |
# File 'lib/gem_loader/scope.rb', line 5 def context @context end |
#depend_scopes ⇒ Object
Returns the value of attribute depend_scopes.
5 6 7 |
# File 'lib/gem_loader/scope.rb', line 5 def depend_scopes @depend_scopes end |
#gems ⇒ Object
Returns the value of attribute gems.
5 6 7 |
# File 'lib/gem_loader/scope.rb', line 5 def gems @gems end |
#libs ⇒ Object
Returns the value of attribute libs.
5 6 7 |
# File 'lib/gem_loader/scope.rb', line 5 def libs @libs end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/gem_loader/scope.rb', line 5 def name @name end |
Instance Method Details
#add_depend_scope(scope) ⇒ Object
13 14 15 |
# File 'lib/gem_loader/scope.rb', line 13 def add_depend_scope(scope) self.depend_scopes << scope end |
#all_gems ⇒ Object
17 18 19 |
# File 'lib/gem_loader/scope.rb', line 17 def all_gems [ self.depend_scopes.map(&:all_gems) + self.gems ].flatten end |
#dsl(&block) ⇒ Object
4 5 6 |
# File 'lib/gem_loader/scope/dsl.rb', line 4 def dsl(&block) Dsl.new(self, &block) end |
#gem(name) ⇒ Object
37 38 39 40 41 |
# File 'lib/gem_loader/scope.rb', line 37 def gem(name) gem_requirement = self.context.gem_requirement(name) gem = Gem.new(name, gem_requirement) (self.gems << gem).last end |
#load ⇒ Object
21 22 23 24 25 |
# File 'lib/gem_loader/scope.rb', line 21 def load self.all_gems.each do |gem| gem.load end end |
#require ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/gem_loader/scope.rb', line 27 def require self.all_gems.each do |gem| gem.require end self.libs.flatten.each do |lib| Kernel.send :require, lib.to_s end end |