class Sprockets::Manifest

def initialize(*args)


Manifest.new(environment, "./public/assets/manifest.json")

directory.
filename will default a random "manifest-123.json" file in that
compiled assets to. Otherwise, if the path is a directory, the
already exist. The dirname of the `path` will be used to write
a full path to the manifest json file. The file may or may not
Create new Manifest associated with an `environment`. `path` is
def initialize(*args)
  if args.first.is_a?(Base) || args.first.nil?
    @environment = args.shift
  end
  @dir, @path = args[0], args[1]
  # Expand paths
  @dir  = File.expand_path(@dir) if @dir
  @path = File.expand_path(@path) if @path
  # If path is given as the second arg
  if @dir && File.extname(@dir) != ""
    @dir, @path = nil, @dir
  end
  # Default dir to the directory of the path
  @dir ||= File.dirname(@path) if @path
  # If directory is given w/o path, pick a random manifest.json location
  if @dir && @path.nil?
    # Find the first manifest.json in the directory
    paths = Dir[File.join(@dir, "manifest*.json")]
    if paths.any?
      @path = paths.first
    else
      @path = File.join(@dir, "manifest-#{SecureRandom.hex(16)}.json")
    end
  end
  unless @dir && @path
    raise ArgumentError, "manifest requires output path"
  end
  data = nil
  begin
    if File.exist?(@path)
      data = json_decode(File.read(@path))
    end
  rescue MultiJson::DecodeError => e
    logger.error "#{@path} is invalid: #{e.class} #{e.message}"
  end
  @data = data.is_a?(Hash) ? data : {}
end