Sha256: 66f0ab64f939739c98c1c7474ac3d03c370943b7ad6f912c9cac1065aa22fa74

Contents?: true

Size: 1.16 KB

Versions: 7

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true
require 'sprockets/base'
require 'sprockets/cache/memory_store'
require 'sprockets/cached_environment'

module Sprockets
  class Environment < Base
    # `Environment` should be initialized with your application's root
    # directory. This should be the same as your Rails or Rack root.
    #
    #     env = Environment.new(Rails.root)
    #
    def initialize(root = ".")
      initialize_configuration(Sprockets)
      self.root = root
      self.cache = Cache::MemoryStore.new
      yield self if block_given?
    end

    # Returns a cached version of the environment.
    #
    # All of its file system calls are cached which makes `cached` much
    # faster. This behavior is ideal in production since the file
    # system only changes between deploys.
    def cached
      CachedEnvironment.new(self)
    end
    alias_method :index, :cached

    def find_asset(*args)
      cached.find_asset(*args)
    end

    def find_asset!(*args)
      cached.find_asset!(*args)
    end

    def find_all_linked_assets(*args, &block)
      cached.find_all_linked_assets(*args, &block)
    end

    def load(*args)
      cached.load(*args)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sprockets-4.0.0.beta10 lib/sprockets/environment.rb
sprockets-4.0.0.beta9 lib/sprockets/environment.rb
sprockets-4.0.0.beta8 lib/sprockets/environment.rb
sprockets-4.0.0.beta7 lib/sprockets/environment.rb
sprockets-4.0.0.beta6 lib/sprockets/environment.rb
sprockets-4.0.0.beta5 lib/sprockets/environment.rb
sprockets-4.0.0.beta4 lib/sprockets/environment.rb