123456789_123456789_123456789_123456789_123456789_

Module: Sprockets::Configuration

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Included In:
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Defined in: lib/sprockets/configuration.rb

Constant Summary

Utils - Included

MODULE_INCLUDE_MUTEX, WHITESPACE_ORDINALS

PathUtils - Included

SEPARATOR_PATTERN

DigestUtils - Included

ADD_VALUE_TO_DIGEST, DIGEST_SIZES, HASH_ALGORITHMS

ProcessorUtils - Included

VALID_METADATA_COMPOUND_TYPES, VALID_METADATA_COMPOUND_TYPES_HASH, VALID_METADATA_TYPES, VALID_METADATA_VALUE_TYPES, VALID_METADATA_VALUE_TYPES_HASH

Instance Attribute Summary

Paths - Included

#root

Returns Environment root.

#root=

Internal: Change Environment root.

Exporting - Included

#export_concurrent

Public: Checks if concurrent exporting is allowed.

#export_concurrent=

Public: Enable or disable the concurrently exporting files.

Compressing - Included

#css_compressor

Return CSS compressor or nil if none is set.

#css_compressor=

Assign a compressor to run on text/css assets.

#gzip=

Public: Enable or disable the creation of Gzip files.

#gzip?

Public: Checks if Gzip is enabled.

#js_compressor

Return JS compressor or nil if none is set.

#js_compressor=

Assign a compressor to run on application/javascript assets.

#skip_gzip?

Public: Checks if Gzip is disabled.

Instance Method Summary

Paths - Included

#append_path

Append a path to the paths list.

#clear_paths

Clear all paths and start fresh.

#each_file

Public: Iterate over every file under all load paths.

#paths

Returns an Array of path Strings.

#prepend_path

Prepend a path to the paths list.

Mime - Included

#mime_exts

Internal: Mapping of MIME extension Strings to MIME type Strings.

#mime_type_charset_detecter

Internal: Get detecter function for MIME type.

#mime_types

Public: Mapping of MIME type Strings to properties Hash.

#read_file

Public: Read file on disk with MIME type specific encoding.

#register_mime_type

Public: Register a new mime type.

Transformers - Included

#compose_transformers

Internal: Compose multiple transformer steps into a single processor function.

#expand_transform_accepts

Internal: Expand accept type list to include possible transformed types.

#register_transformer

Public: Register a transformer from and to a mime type.

#register_transformer_suffix

Internal: Register transformer for existing type adding a suffix.

#resolve_transform_type

Internal: Resolve target mime type that the source type should be transformed to.

#transformers

Public: Two level mapping of a source mime type to a target mime type.

#compose_transformer_list, #compute_transformers!

HTTPUtils - Included

#find_best_mime_type_match

Internal: Find the best qvalue match from an Array of available mime type options.

#find_best_q_match

Internal: Find the best qvalue match from an Array of available options.

#find_mime_type_matches

Internal: Find the all qvalue match from an Array of available mime type options.

#find_q_matches

Internal: Find all qvalue matches from an Array of available options.

#match_mime_type?

Public: Test mime type against mime range.

#match_mime_type_keys

Public: Return values from Hash where the key matches the mime type.

#parse_q_values

Internal: Parse Accept header quality values.

Processing - Included

#bundle_processors

Bundle Processors are ran on concatenated assets rather than individual files.

#pipelines,
#postprocessors

Postprocessors are ran after Preprocessors and Engine processors.

#preprocessors

Preprocessors are ran before Postprocessors and Engine processors.

#processors
#register_bundle_metadata_reducer

Public: Register bundle metadata reducer function.

#register_bundle_processor

Registers a new Bundle Processor klass for mime_type.

#register_pipeline

Registers a pipeline that will be called by call_processor method.

#register_postprocessor

Registers a new Postprocessor klass for mime_type.

#register_preprocessor

Registers a new Preprocessor klass for mime_type.

#register_processor
#unregister_bundle_processor

Remove Bundle Processor klass for mime_type.

#unregister_postprocessor

Remove Postprocessor klass for mime_type.

#unregister_preprocessor

Remove Preprocessor klass for mime_type.

#unregister_processor
#register_config_processor, #unregister_config_processor

ProcessorUtils - Included

#call_processor

Public: Invoke processor.

#call_processors

Public: Invoke list of processors in right to left order.

#compose_processors

Public: Compose processors in right to left order.

#processor_cache_key

Internal: Get processor defined cached key.

#processors_cache_keys

Internal: Get combined cache keys for set of processors.

#validate_processor_result!

Internal: Validate returned result of calling a processor pipeline and raise a friendly user error message.

Exporting - Included

#exporters

Exporters are ran on the assets:precompile task.

#register_exporter

Public: Registers a new Exporter klass for mime_type.

#unregister_exporter

Public: Remove Exporting processor klass for mime_type.

Compressing - Included

#compressors,
#register_compressor

Public: Register a new compressor klass at sym for mime_type.

Dependencies - Included

#add_dependency

Public: Add environmental dependency inherited by all assets.

#depend_on
#dependencies

Public: Default set of dependency URIs for assets.

#dependency_resolvers

Public: Mapping dependency schemes to resolver functions.

#register_dependency_resolver

Public: Register new dependency URI resolver.

#resolve_dependency

Internal: Resolve dependency URIs.

PathDigestUtils - Included

#file_digest

Internal: Compute digest for path.

#files_digest

Internal: Compute digest for a set of paths.

#stat_digest

Internal: Compute digest for file stat.

DigestUtils - Included

#already_digested?

Internal: Checks an asset name for a valid digest.

#detect_digest_class

Internal: Detect digest class hash algorithm for digest bytes.

#digest

Internal: Generate a hexdigest for a nested JSON serializable object.

#digest_class

Internal: Default digest class.

#hexdigest

Internal: Generate a hexdigest for a nested JSON serializable object.

#hexdigest_integrity_uri

Public: Generate hash for use in the integrity attribute of an asset tag as per the subresource integrity specification.

#integrity_uri

Public: Generate hash for use in the integrity attribute of an asset tag as per the subresource integrity specification.

#pack_base64digest

Internal: Pack a binary digest to a base64 encoded string.

#pack_hexdigest

Internal: Pack a binary digest to a hex encoded string.

#pack_urlsafe_base64digest

Internal: Pack a binary digest to a urlsafe base64 encoded string.

#unpack_hexdigest

Internal: Unpack a hex encoded digest string into binary bytes.

#build_digest

PathUtils - Included

#absolute_path?

On Windows, ALT_SEPARATOR is \ Delegate to Pathname since the logic gets complex.

#atomic_write

Public: Write to a file atomically.

#directory?

Public: Like File.directory?.

#entries

Public: A version of Dir.entries that filters out . files and ~ swap files.

#file?

Public: Like File.file?.

#find_matching_path_for_extensions

Internal: Match paths in a directory against available extensions.

#find_upwards

Internal: Find target basename checking upwards from path.

#join

Public: Joins path to base path.

#match_path_extname

Internal: Match path extnames against available extensions.

#path_extnames

Internal: Get path’s extensions.

#path_parents

Internal: Returns all parents for path.

#paths_split

Internal: Detect root path and base for file in a set of paths.

#relative_path?

Public: Check if path is explicitly relative.

#relative_path_from

Public: Get relative path from start to dest.

#set_pipeline

Public: Sets pipeline for path.

#split_subpath

Internal: Get relative path for root path and subpath.

#stat

Public: Like File.stat.

#stat_directory

Public: Stat all the files under a directory.

#stat_sorted_tree

Public: Recursive stat all the files under a directory in alphabetical order.

#stat_tree

Public: Recursive stat all the files under a directory.

URIUtils - Included

#build_asset_uri

Internal: Build Asset URI.

#build_file_digest_uri

Internal: Build file-digest dependency URI.

#encode_uri_query_params

Internal: Serialize hash of params into query string.

#join_file_uri

Internal: Join file: URI component parts into String.

#join_uri

Internal: Join URI component parts into String.

#parse_asset_uri

Internal: Parse Asset URI.

#parse_file_digest_uri

Internal: Parse file-digest dependency URI.

#parse_uri_query_params

Internal: Parse query string into hash of params.

#split_file_uri

Internal: Parse file: URI into component parts.

#split_uri

Internal: Parse URI into component parts.

#valid_asset_uri?

Internal: Check if String is a valid Asset URI.

Utils - Included

#concat_javascript_sources

Internal: Accumulate asset source to buffer and append a trailing semicolon if necessary.

#dfs

Internal: Post-order Depth-First search algorithm.

#dfs_paths

Internal: Post-order Depth-First search algorithm that gathers all paths along the way.

#duplicable?

Internal: Check if object can safely be .dup’d.

#hash_reassoc

Internal: Duplicate and store key/value on new frozen hash.

#hash_reassoc1

Internal: Duplicate and store key/value on new frozen hash.

#module_include

Internal: Inject into target module for the duration of the block.

#string_end_with_semicolon?

Internal: Check if string has a trailing semicolon.

Instance Attribute Details

#config (rw)

[ GitHub ]

  
# File 'lib/sprockets/configuration.rb', line 21

attr_reader :config

#config=(config) (rw)

Raises:

  • (TypeError)
[ GitHub ]

  
# File 'lib/sprockets/configuration.rb', line 23

def config=(config)
  raise TypeError, "can't assign mutable config" unless config.frozen?
  @config = config
end

#context_class (readonly)

This class maybe mutated and mixed in with custom helpers.

environment.context_class.instance_eval do
  include MyHelpers
  def asset_url; end
end
[ GitHub ]

  
# File 'lib/sprockets/configuration.rb', line 77

attr_reader :context_class

#digest_class (rw)

Public: Returns a Digest implementation class.

Defaults to Digest::SHA256.

[ GitHub ]

  
# File 'lib/sprockets/configuration.rb', line 56

def digest_class
  config[:digest_class]
end

#digest_class=(klass) (rw)

Deprecated: Assign a Digest implementation class. This maybe any Ruby Digest:: implementation such as Digest::SHA256 or Digest::SHA512.

environment.digest_class = Digest::SHA512
[ GitHub ]

  
# File 'lib/sprockets/configuration.rb', line 66

def digest_class=(klass)
  self.config = config.merge(digest_class: klass).freeze
end

#logger (rw)

Get and set Logger instance.

[ GitHub ]

  
# File 'lib/sprockets/configuration.rb', line 29

attr_accessor :logger

#version (rw)

The Environment#version is a custom value used for manually expiring all asset caches.

::Sprockets is able to track most file and directory changes and will take care of expiring the cache for you. However, its impossible to know when any custom helpers change that you mix into the Context.

It would be wise to increment this value anytime you make a configuration change to the Environment object.

[ GitHub ]

  
# File 'lib/sprockets/configuration.rb', line 41

def version
  config[:version]
end

#version=(version) (rw)

Assign an environment version.

environment.version = '2.0'
[ GitHub ]

  
# File 'lib/sprockets/configuration.rb', line 49

def version=(version)
  self.config = hash_reassoc(config, :version) { version.dup }
end

Instance Method Details

#initialize_configuration(parent)

[ GitHub ]

  
# File 'lib/sprockets/configuration.rb', line 15

def initialize_configuration(parent)
  @config = parent.config
  @logger = parent.logger
  @context_class = Class.new(parent.context_class)
end