Module: Sprockets::Configuration

Includes:
Compressing, Engines, Mime, Paths, Processing, Transformers, Utils
Included in:
Sprockets, Base
Defined in:
lib/sprockets/configuration.rb

Constant Summary

Constants included from PathUtils

PathUtils::SEPARATOR_PATTERN

Constants included from Utils

Utils::UNBOUND_METHODS_BIND_TO_ANY_OBJECT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Paths

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

Methods included from PathUtils

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

Methods included from Utils

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

Methods included from Mime

#encodings, #mime_exts, #mime_type_charset_detecter, #mime_types, #read_file, #register_encoding, #register_mime_type

Methods included from HTTPUtils

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

Methods included from Engines

#engine_mime_types, #engines, #register_engine, #unwrap_engines

Methods included from Transformers

#expand_transform_accepts, #inverted_transformers, #register_transformer, #resolve_transform_type, #transformers, #unwrap_transformer

Methods included from Processing

#bundle_processors, #bundle_reducers, #postprocessors, #preprocessors, #process_bundle_reducers, #register_bundle_metadata_reducer, #register_bundle_processor, #register_postprocessor, #register_preprocessor, #unregister_bundle_processor, #unregister_postprocessor, #unregister_preprocessor, #unwrap_bundle_processors, #unwrap_bundle_reducers, #unwrap_postprocessors, #unwrap_preprocessors

Methods included from Compressing

#compressors, #css_compressor, #css_compressor=, #js_compressor, #js_compressor=, #register_compressor

Instance Attribute Details

#configObject

Returns the value of attribute config



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

def config
  @config
end

#context_classObject (readonly)

Deprecated: Get `Context` class.

This class maybe mutated and mixed in with custom helpers.

environment.context_class.instance_eval do
  include MyHelpers
  def asset_url; end
end


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

def context_class
  @context_class
end

#loggerObject

Get and set `Logger` instance.



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

def logger
  @logger
end

Instance Method Details

#digest_classObject

Public: Returns a `Digest` implementation class.

Defaults to `Digest::SHA256`.



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

def digest_class
  config[:digest_class]
end

#digest_class=(klass) ⇒ Object

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

environment.digest_class = Digest::MD5


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

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

#initialize_configuration(parent) ⇒ Object



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

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

#versionObject

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.



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

def version
  config[:version]
end

#version=(version) ⇒ Object

Assign an environment version.

environment.version = '2.0'


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

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