Class: Sprockets::Environment

Inherits:
Base
  • Object
show all
Defined in:
lib/sprockets/environment.rb

Constant Summary

Constants included from Bower

Bower::POSSIBLE_BOWER_JSONS

Constants included from PathUtils

PathUtils::SEPARATOR_PATTERN

Constants included from Utils

Utils::UNBOUND_METHODS_BIND_TO_ANY_OBJECT

Constants included from ProcessorUtils

ProcessorUtils::VALID_METADATA_COMPOUND_TYPES, ProcessorUtils::VALID_METADATA_TYPES, ProcessorUtils::VALID_METADATA_VALUE_TYPES

Constants included from DigestUtils

DigestUtils::DIGEST_SIZES, DigestUtils::HASH_ALGORITHMS

Instance Attribute Summary

Attributes inherited from Base

#cache

Attributes included from Configuration

#computed_config, #config, #context_class, #logger

Instance Method Summary collapse

Methods inherited from Base

#[], #cache_get, #cache_set, #compress_from_root, #each_logical_path, #expand_from_root, #file_digest, #inspect, #logical_paths, #normalize_logical_path, #resolve_with_compat

Methods included from Bower

#read_bower_main, #resolve_alternates

Methods included from Resolve

#resolve, #resolve!

Methods included from HTTPUtils

#find_best_mime_type_match, #find_best_q_match, #find_mime_type_matches, #find_q_matches, #match_mime_type?, #match_mime_type_keys, #parse_q_values

Methods included from PathDependencyUtils

#entries_with_dependencies, #file_digest_dependency_set, #stat_directory_with_dependencies, #stat_sorted_tree_with_dependencies

Methods included from URIUtils

#build_asset_uri, #build_file_digest_uri, #encode_uri_query_params, #join_file_uri, #join_uri, #parse_asset_uri, #parse_file_digest_uri, #parse_uri_query_params, #split_file_uri, #split_uri, #valid_asset_uri?

Methods included from PathUtils

#absolute_path?, #atomic_write, #directory?, #entries, #file?, #find_upwards, #match_path_extname, #path_extnames, #path_parents, #paths_split, #relative_path?, #split_subpath, #stat, #stat_directory, #stat_sorted_tree, #stat_tree

Methods included from Engines

#engine_mime_types, #engines, #register_engine

Methods included from Utils

#concat_javascript_sources, #dfs, #dfs_paths, #duplicable?, #hash_reassoc, #hash_reassoc1, #module_include, #normalize_extension, #string_end_with_semicolon?

Methods included from Mime

#mime_exts, #mime_type_charset_detecter, #mime_types, #read_file, #register_mime_type

Methods included from Processing

#bundle_processors, #pipelines, #postprocessors, #preprocessors, #register_bundle_metadata_reducer, #register_bundle_processor, #register_pipeline, #register_postprocessor, #register_preprocessor, #unregister_bundle_processor, #unregister_postprocessor, #unregister_preprocessor

Methods included from ProcessorUtils

#call_processor, #call_processors, #compose_processors, #processor_cache_key, #processors_cache_keys, #valid_processor_metadata_value?, #validate_processor_result!

Methods included from Transformers

#compose_transformers, #expand_transform_accepts, #register_transformer, #resolve_transform_type, #transformers

Methods included from DigestUtils

#detect_digest_class, #digest, #digest_class, #hexdigest_integrity_uri, #integrity_uri, #pack_base64digest, #pack_hexdigest, #pack_urlsafe_base64digest, #unpack_hexdigest

Methods included from Server

#call

Methods included from Configuration

#digest_class, #digest_class=, #initialize_configuration, #version, #version=

Methods included from Paths

#append_path, #clear_paths, #each_file, #paths, #prepend_path, #root

Methods included from Compressing

#compressors, #css_compressor, #css_compressor=, #gzip=, #gzip?, #js_compressor, #js_compressor=, #register_compressor, #skip_gzip?

Methods included from Dependencies

#add_dependency, #dependencies, #dependency_resolvers, #register_dependency_resolver, #resolve_dependency

Methods included from PathDigestUtils

#file_digest, #files_digest, #stat_digest

Constructor Details

#initialize(root = ".") {|_self| ... } ⇒ Environment

`Environment` should initialized with your application's root directory. This should be the same as your Rails or Rack root.

env = Environment.new(Rails.root)

Yields:

  • (_self)

Yield Parameters:


12
13
14
15
16
17
# File 'lib/sprockets/environment.rb', line 12

def initialize(root = ".")
  initialize_configuration(Sprockets)
  self.root = root
  self.cache = Cache::MemoryStore.new
  yield self if block_given?
end

Instance Method Details

#cachedObject Also known as: index

Returns a cached version of the environment.

All 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.


24
25
26
# File 'lib/sprockets/environment.rb', line 24

def cached
  CachedEnvironment.new(self)
end

#find_all_linked_assets(*args, &block) ⇒ Object


33
34
35
# File 'lib/sprockets/environment.rb', line 33

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

#find_asset(*args) ⇒ Object


29
30
31
# File 'lib/sprockets/environment.rb', line 29

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

#load(*args) ⇒ Object


37
38
39
# File 'lib/sprockets/environment.rb', line 37

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