Sha256: 98dfddcea7deb2cc52b26f0716d5beeef8cb9a9ae68871863b7be1d5765b4fdd

Contents?: true

Size: 833 Bytes

Versions: 4

Compression:

Stored size: 833 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)
        Dir.walk(dir) do |path|
          next if FileTest.directory?(path)
          next if path.split('.')[-1] != 'rb'

          if Config.reloader.enabled
            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

4 entries across 4 versions & 1 rubygems

Version Path
pakyow-core-0.11.3 pakyow-core/lib/pakyow/core/loader.rb
pakyow-core-0.11.2 pakyow-core/lib/pakyow/core/loader.rb
pakyow-core-0.11.1 pakyow-core/lib/pakyow/core/loader.rb
pakyow-core-0.11.0 pakyow-core/lib/pakyow/core/loader.rb