Module: Sprockets::Dependencies

### Home Classes Methods

### In Files

- lib/sprockets/dependencies.rb

### Methods

- #add_dependency
- #depend_on
- #dependencies
- #dependency_resolvers
- #register_dependency_resolver
- #resolve_dependency

### Included Modules

- Sprockets::DigestUtils
- Sprockets::PathDigestUtils
- Sprockets::URIUtils

### Class/Module Index

Quicksearch

- Sprockets
- Sprockets::ArgumentError
- Sprockets::Asset
- Sprockets::Autoload
- Sprockets::Base
- Sprockets::Bower
- Sprockets::Bundle
- Sprockets::Cache
- Sprockets::Cache::FileStore
- Sprockets::Cache::GetWrapper
- Sprockets::Cache::HashWrapper
- Sprockets::Cache::MemoryStore
- Sprockets::Cache::NullStore
- Sprockets::Cache::ReadWriteWrapper
- Sprockets::Cache::Wrapper
- Sprockets::CachedEnvironment
- Sprockets::ClosureCompressor
- Sprockets::CoffeeScriptProcessor
- Sprockets::CoffeeScriptTemplate
- Sprockets::Compressing
- Sprockets::Configuration
- Sprockets::ContentTypeMismatch
- Sprockets::Context
- Sprockets::ConversionError
- Sprockets::Dependencies
- Sprockets::DigestUtils
- Sprockets::DirectiveProcessor
- Sprockets::ERBProcessor
- Sprockets::ERBTemplate
- Sprockets::EcoProcessor
- Sprockets::EcoTemplate
- Sprockets::EjsProcessor
- Sprockets::EjsTemplate
- Sprockets::EncodingUtils
- Sprockets::Engines
- Sprockets::Environment
- Sprockets::Error
- Sprockets::FileNotFound
- Sprockets::FileOutsidePaths
- Sprockets::FileReader
- Sprockets::HTTPUtils
- Sprockets::Index
- Sprockets::JstProcessor
- Sprockets::LegacyProcProcessor
- Sprockets::LegacyTiltProcessor
- Sprockets::Loader
- Sprockets::Manifest
- Sprockets::ManifestUtils
- Sprockets::Mime
- Sprockets::NotFound
- Sprockets::NotImplementedError
- Sprockets::PathDependencyUtils
- Sprockets::PathDigestUtils
- Sprockets::PathUtils
- Sprockets::Paths
- Sprockets::Processing
- Sprockets::ProcessorUtils
- Sprockets::Resolve
- Sprockets::SassCompressor
- Sprockets::SassProcessor
- Sprockets::SassProcessor::CacheStore
- Sprockets::SassProcessor::Functions
- Sprockets::SassTemplate
- Sprockets::ScssProcessor
- Sprockets::ScssTemplate
- Sprockets::Server
- Sprockets::Transformers
- Sprockets::URITar
- Sprockets::URIUtils
- Sprockets::UglifierCompressor
- Sprockets::UnloadedAsset
- Sprockets::Utils
- Sprockets::YUICompressor
- Rake
- Rake::SprocketsTask

No matching classes.

# Sprockets::Dependencies

`Dependencies` is an internal mixin whose public methods are exposed on the `Environment` and `CachedEnvironment` classes.

### Public Instance Methods

add_dependency(uri) click to toggle source

Public: Add environmental dependency inheirted by all assets.

uri - String dependency URI

Returns nothing.

    # File lib/sprockets/dependencies.rb, line 47
    def add_dependency(uri)
      self.config = hash_reassoc(config, :dependencies) do |set|
        set + Set.new([uri])
      end
    end

Also aliased as: depend_on
depend_on(uri) click to toggle source
Alias for: add_dependency
dependencies() click to toggle source

Public: Default set of dependency URIs for assets.

Returns Set of String URIs.

    # File lib/sprockets/dependencies.rb, line 24
    def dependencies
      config[:dependencies]
    end

dependency_resolvers() click to toggle source

Public: Mapping dependency schemes to resolver functions.

key - String scheme value - Proc.call(Environment, String)

Returns Hash.

    # File lib/sprockets/dependencies.rb, line 17
    def dependency_resolvers
      config[:dependency_resolvers]
    end

register_dependency_resolver(scheme, &block) click to toggle source

Public: Register new dependency URI resolver.

scheme - String scheme block -

    environment - Environment
    uri - String dependency URI

Returns nothing.

    # File lib/sprockets/dependencies.rb, line 36
    def register_dependency_resolver(scheme, &block)
      self.config = hash_reassoc(config, :dependency_resolvers) do |hash|
        hash.merge(scheme => block)
      end
    end

resolve_dependency(str) click to toggle source

Internal: Resolve dependency URIs.

Returns resolved Object.

    # File lib/sprockets/dependencies.rb, line 57
    def resolve_dependency(str)
      # Optimize for the most common scheme to
      # save 22k allocations on an average Spree app.
      scheme = if str.start_with?('file-digest:'.freeze)
        'file-digest'.freeze
      else
        str[/([^:]+)/, 1]
      end

      if resolver = config[:dependency_resolvers][scheme]
        resolver.call(self, str)
      else
        nil
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.