Module: Sprockets::Configuration
- Includes:
- Compressing, Dependencies, Engines, Mime, Paths, Processing, Transformers, Utils
- Defined in:
- lib/sprockets/configuration.rb
Constant Summary
Constants included from PathUtils
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 collapse
-
#computed_config ⇒ Object
Returns the value of attribute computed_config.
-
#config ⇒ Object
Returns the value of attribute config.
-
#context_class ⇒ Object
readonly
Deprecated: Get ‘Context` class.
-
#logger ⇒ Object
Get and set ‘Logger` instance.
Instance Method Summary collapse
-
#digest_class ⇒ Object
Public: Returns a ‘Digest` implementation class.
-
#digest_class=(klass) ⇒ Object
Deprecated: Assign a ‘Digest` implementation class.
- #initialize_configuration(parent) ⇒ Object
-
#version ⇒ Object
The ‘Environment#version` is a custom value used for manually expiring all asset caches.
-
#version=(version) ⇒ Object
Assign an environment version.
Methods included from Paths
#append_path, #clear_paths, #each_file, #paths, #prepend_path, #root
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 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 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 Engines
#engine_mime_types, #engines, #register_engine
Methods included from Transformers
#compose_transformers, #expand_transform_accepts, #register_transformer, #resolve_transform_type, #transformers
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 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 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 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 DigestUtils
#detect_digest_class, #digest, #hexdigest_integrity_uri, #integrity_uri, #pack_base64digest, #pack_hexdigest, #pack_urlsafe_base64digest, #unpack_hexdigest
Methods included from PathDigestUtils
#file_digest, #files_digest, #stat_digest
Instance Attribute Details
#computed_config ⇒ Object
Returns the value of attribute computed_config.
23 24 25 |
# File 'lib/sprockets/configuration.rb', line 23 def computed_config @computed_config end |
#config ⇒ Object
Returns the value of attribute config.
21 22 23 |
# File 'lib/sprockets/configuration.rb', line 21 def config @config end |
#context_class ⇒ Object (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
81 82 83 |
# File 'lib/sprockets/configuration.rb', line 81 def context_class @context_class end |
#logger ⇒ Object
Get and set ‘Logger` instance.
31 32 33 |
# File 'lib/sprockets/configuration.rb', line 31 def logger @logger end |
Instance Method Details
#digest_class ⇒ Object
Public: Returns a ‘Digest` implementation class.
Defaults to ‘Digest::SHA256`.
58 59 60 |
# File 'lib/sprockets/configuration.rb', line 58 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
68 69 70 |
# File 'lib/sprockets/configuration.rb', line 68 def digest_class=(klass) self.config = config.merge(digest_class: klass).freeze end |
#initialize_configuration(parent) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/sprockets/configuration.rb', line 14 def initialize_configuration(parent) @config = parent.config @computed_config = parent.computed_config @logger = parent.logger @context_class = Class.new(parent.context_class) end |
#version ⇒ Object
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.
43 44 45 |
# File 'lib/sprockets/configuration.rb', line 43 def version config[:version] end |
#version=(version) ⇒ Object
Assign an environment version.
environment.version = '2.0'
51 52 53 |
# File 'lib/sprockets/configuration.rb', line 51 def version=(version) self.config = hash_reassoc(config, :version) { version.dup } end |