Sha256: c506e860dcb174e77f74cc3f069f92cec709723c5d6294f85113955132097d8a

Contents?: true

Size: 1.18 KB

Versions: 22

Compression:

Stored size: 1.18 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, **options)
      cached.find_asset(*args, **options)
    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

22 entries across 21 versions & 10 rubygems

Version Path
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.1.0/gems/sprockets-4.2.1/lib/sprockets/environment.rb
trusty-cms-7.0.9.1 vendor/bundle/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/environment.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/sprockets-4.2.1/lib/sprockets/environment.rb
tinymce-rails-7.1.2 vendor/bundle/ruby/3.3.0/gems/sprockets-4.2.1/lib/sprockets/environment.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/sprockets-4.1.1/lib/sprockets/environment.rb
sprockets-4.2.1 lib/sprockets/environment.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/sprockets-4.1.1/lib/sprockets/environment.rb
sprockets-4.2.0 lib/sprockets/environment.rb
sprockets-4.1.1 lib/sprockets/environment.rb
sprockets-4.1.0 lib/sprockets/environment.rb
sprockets-4.0.3 lib/sprockets/environment.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/environment.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/sprockets-4.0.2/lib/sprockets/environment.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/sprockets-4.0.2/lib/sprockets/environment.rb
sprockets-4.0.2 lib/sprockets/environment.rb
sprockets-4.0.1 lib/sprockets/environment.rb
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/sprockets-4.0.0/lib/sprockets/environment.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/sprockets-4.0.0/lib/sprockets/environment.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/sprockets-4.0.0/lib/sprockets/environment.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/sprockets-4.0.0/lib/sprockets/environment.rb