Module: Bake::Scope
- Defined in:
- lib/bake/scope.rb
Overview
Used for containing all methods defined in a bakefile.
Class Method Summary collapse
- .inspect ⇒ Object
-
.load(file_path, path = []) ⇒ Object
Load the specified file into a unique scope module, which can then be included into a Base instance.
Instance Method Summary collapse
-
#path ⇒ Object
The path of the file that was used to Scope.load this scope.
-
#recipe_for(name) ⇒ Object
Look up a recipe with a specific name.
-
#recipes ⇒ Enumerable
Recipes defined in this scope.
Class Method Details
.inspect ⇒ Object
39 40 41 |
# File 'lib/bake/scope.rb', line 39 def self.inspect "Bake::Scope<#{self.const_get(:FILE_PATH)}>" end |
.load(file_path, path = []) ⇒ Object
Load the specified file into a unique scope module, which can then be included into a Base instance.
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/bake/scope.rb', line 27 def self.load(file_path, path = []) scope = Module.new scope.extend(self) scope.const_set(:FILE_PATH, file_path) scope.const_set(:PATH, path) scope.module_eval(File.read(file_path), file_path) return scope end |
Instance Method Details
#path ⇒ Object
The path of the file that was used to load this scope.
59 60 61 |
# File 'lib/bake/scope.rb', line 59 def path self.const_get(:PATH) end |
#recipe_for(name) ⇒ Object
Look up a recipe with a specific name.
66 67 68 |
# File 'lib/bake/scope.rb', line 66 def recipe_for(name) Recipe.new(self, name, self.instance_method(name)) end |
#recipes ⇒ Enumerable
Recipes defined in this scope.
48 49 50 51 52 53 54 55 56 |
# File 'lib/bake/scope.rb', line 48 def recipes return to_enum(:recipes) unless block_given? names = self.instance_methods names.each do |name| yield recipe_for(name) end end |