class Sprockets::AssetAttributes

These methods should be considered internalish.
some helper accessors.
‘AssetAttributes` is a wrapper similar to `Pathname` that provides

def content_type

Returns the content type for the pathname. Falls back to `application/octet-stream`.
def content_type
  @content_type ||= begin
    if format_extension.nil?
      engine_content_type || 'application/octet-stream'
    else
      @environment.mime_types(format_extension) ||
        engine_content_type ||
        'application/octet-stream'
    end
  end
end

def engine_content_type

content type.
`.coffee` files carry an implicit `application/javascript`

Returns implicit engine content type.
def engine_content_type
  engines.reverse.each do |engine|
    if engine.respond_to?(:default_mime_type) && engine.default_mime_type
      return engine.default_mime_type
    end
  end
  nil
end

def engine_extensions


# => [".coffee", ".erb"]
"foo.js.coffee.erb"

Returns an `Array` of engine extensions.
def engine_extensions
  exts = extensions
  if offset = extensions.index(format_extension)
    exts = extensions[offset+1..-1]
  end
  exts.select { |ext| @environment.engines(ext) }
end

def engine_format_extension

def engine_format_extension
  if content_type = engine_content_type
    environment.extension_for_mime_type(content_type)
  end
end

def engines

Returns engine classes.
def engines
  engine_extensions.map { |ext| @environment.engines(ext) }
end

def extensions


# => [".js", ".coffee"]
"foo.js.coffee"

Returns `Array` of extension `String`s.
def extensions
  @extensions ||= @pathname.basename.to_s.scan(/\.[^.]+/)
end

def format_extension


# => ".js"
"foo.js.coffee"

Returns the format extension.
def format_extension
  extensions.reverse.detect { |ext|
    @environment.mime_types(ext) && !@environment.engines(ext)
  }
end

def initialize(environment, path)

def initialize(environment, path)
  @environment = environment
  @pathname = path.is_a?(Pathname) ? path : Pathname.new(path.to_s)
end

def logical_path

path will be incorrect.
shaddowed in the path, but is required relatively, its logical
This has some known issues. For an example if a file is

Reverse guess logical path for fully expanded path.
def logical_path
  if root_path = environment.paths.detect { |path| pathname.to_s[path] }
    path = pathname.to_s.sub("#{root_path}/", '')
    path = pathname.relative_path_from(Pathname.new(root_path)).to_s
    path = engine_extensions.inject(path) { |p, ext| p.sub(ext, '') }
    path = "#{path}#{engine_format_extension}" unless format_extension
    path
  else
    raise FileOutsidePaths, "#{pathname} isn't in paths: #{environment.paths.join(', ')}"
  end
end

def processors

Returns all processors to run on the path.
def processors
  environment.preprocessors(content_type) +
    engines.reverse +
    environment.postprocessors(content_type)
end

def search_paths

Returns paths search the load path for.
def search_paths
  paths = [pathname.to_s]
  path_without_extensions = extensions.inject(pathname) { |p, ext| p.sub(ext, '') }
  # optimization: bower.json can only be nested one level deep
  if !path_without_extensions.to_s.index('/')
    paths << path_without_extensions.join("bower.json").to_s
    # DEPRECATED bower configuration file
    paths << path_without_extensions.join("component.json").to_s
  end
  if pathname.basename(extensions.join).to_s != 'index'
    paths << path_without_extensions.join("index#{extensions.join}").to_s
  end
  paths
end