Sha256: a5f1ed674787e553872e9d7f8c961fb46d7707223a1d9794274d307965207b72

Contents?: true

Size: 886 Bytes

Versions: 1

Compression:

Stored size: 886 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_from_path(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

1 entries across 1 versions & 1 rubygems

Version Path
pakyow-core-0.8rc1 pakyow-core/lib/core/loader.rb