Sha256: c905c361416c0c76fa2d40c50ca441b1feda11daf20162e2d4c30fd671832f6f

Contents?: true

Size: 880 Bytes

Versions: 2

Compression:

Stored size: 880 Bytes

Contents

module Pakyow
  
  # Handles the loading and reloading of a Pakyow application. If in development
  # mode, files are automatically reloaded if modified.
  class Loader

    # Loads files in the provided path, decending into child directories.
    def load!(path)
      require_recursively(path)
    end
    
    protected
    
    def require_recursively(dir)
      @times ||= {}
      if File.exists?(dir)
        DirUtils.walk_dir(dir) do |path|
          next if FileTest.directory?(path)
          next if path.split('.')[-1] != 'rb'
          
          if Configuration::Base.app.auto_reload
            if !@times[path] || (@times[path] && File.mtime(path) - @times[path] > 0)
              load(path)
              @times[path] = File.mtime(path)
            end              
          else
            require path
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pakyow-core-0.7.2 pakyow-core/lib/core/loader.rb
pakyow-core-0.7.1 pakyow-core/lib/core/loader.rb