Sha256: 2c8db180c6b72284f9128e203d9c88bb3722bf2e6b1a538da431493ea00a27a2

Contents?: true

Size: 938 Bytes

Versions: 3

Compression:

Stored size: 938 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)
            
          split = path.split('/')
          next if split[split.length-1].start_with?('.')
          
          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

3 entries across 3 versions & 1 rubygems

Version Path
pakyow-core-0.7.0 pakyow-core/lib/core/loader.rb
pakyow-core-0.6.3.1 pakyow-core/lib/core/loader.rb
pakyow-core-0.6.1 pakyow-core/lib/core/loader.rb