Class: Piano::ControllerLoader
- Inherits:
-
Object
- Object
- Piano::ControllerLoader
- Defined in:
- lib/piano/controllerloader.rb
Overview
Handler of .controller files loading
Class Method Summary collapse
- .folder(path) ⇒ Object
-
.recursive(path, &block) ⇒ Object
Iterates recursively over the path and calls the block with each newfound file.
Class Method Details
.folder(path) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/piano/controllerloader.rb', line 4 def self.folder path $LOAD_PATH << Dir.pwd recursive path do |item| load item end end |
.recursive(path, &block) ⇒ Object
Iterates recursively over the path and calls the block with each newfound file
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/piano/controllerloader.rb', line 13 def self.recursive path, &block files = [] Dir.new(File.(path)).each do |file| if File.directory? "#{path}/#{file}" recursive "#{path}/#{file}" do |item| files << "#{item}" end unless file == ".." or file == "." elsif file.end_with? ".controller" files << "#{path}/#{file}" end end files.each { |item| block.call(item) } end |