Sha256: 8ce780ba5af56257da8fcaca616fc56522b750bf961b8a95b0601315233eac10

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

require "rev_manifest/version"
require "rev_manifest/actionview/base"

module RevManifest
  DEFAULT_ASSET_PUBLIC_DIRECTORIES = {
    audio:      "/assets/audios",
    font:       "/assets/fonts",
    image:      "/assets/images",
    javascript: "/assets/javascripts",
    stylesheet: "/assets/stylesheets",
    video:      "/assets/videos"
  }

  DEFAULT_ASSET_PREFIXES = {
    audio:      "assets/audios/",
    font:       "assets/fonts/",
    image:      "assets/images/",
    javascript: "assets/javascripts/",
    stylesheet: "assets/stylesheets/",
    video:      "assets/videos/"
  }

  DEFAULT_MANIFEST_PATH = "public/assets/rev-manifest.json"

  class << self
    attr_writer :enabled, :asset_prefixes, :asset_public_directories, :manifest_path

    #  @return [true, false]
    def enabled?
      !!@enabled
    end

    # @return [Hash]
    def asset_prefixes
      @asset_prefixes || DEFAULT_ASSET_PREFIXES
    end

    # @return [Hash]
    def asset_public_directories
      @asset_public_directories || DEFAULT_ASSET_PUBLIC_DIRECTORIES
    end

    # @return [String]
    def manifest_path
      @manifest_path || Rails.root.join(DEFAULT_MANIFEST_PATH)
    end

    def manifest
      @manifest ||= JSON.load(File.read(manifest_path))
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
actionview-rev_manifest-0.0.1 lib/actionview-rev_manifest.rb