class Bake::Loader
Represents a directory which contains bakefiles.
Attributes
root[R]
The root path for this loader.
Public Class Methods
new(root, name: nil)
click to toggle source
Initialize the loader with the specified root path. @parameter root [String] A file-system path.
# File lib/bake/loader.rb, line 30 def initialize(root, name: nil) @root = root @name = name end
Public Instance Methods
each() { |sub(/\.rb$/, '').split(SEPARATOR)| ... }
click to toggle source
Enumerate all bakefiles within the loaders root directory. @yields {|path| …}
@parameter path [String] The Ruby source file path.
# File lib/bake/loader.rb, line 45 def each return to_enum unless block_given? Dir.glob("**/*.rb", base: @root) do |file_path| yield file_path.sub(/\.rb$/, '').split(File::SEPARATOR) end end
scope_for(path)
click to toggle source
Load the {Scope} for the specified relative path within this loader, if it exists. @parameter path [Array(String)] A relative path.
# File lib/bake/loader.rb, line 55 def scope_for(path) *directory, file = *path file_path = File.join(@root, directory, "#{file}.rb") if File.exist?(file_path) return Scope.load(file_path, path) end end
to_s()
click to toggle source
# File lib/bake/loader.rb, line 35 def to_s "#{self.class} #{@name || @root}" end