Sha256: 21a81061ffcd9370e3412ad206eecda87a1ad8c3eebd296cee57c4884dad5448

Contents?: true

Size: 752 Bytes

Versions: 6

Compression:

Stored size: 752 Bytes

Contents

module Jekyll
  module AssetsPlugin
    class AssetPath

      attr_writer :anchor, :query


      def initialize asset
        asset.bundle!
        @asset = asset
      end


      def cachebust
        @cachebust ||= @asset.site.assets_config.cachebust
      end


      def path
        :hard == cachebust && @asset.digest_path || @asset.logical_path
      end


      def query
        query = []

        query << "cb=#{@asset.digest}" if :soft == cachebust
        query << @query               if @query

        "?#{query.join '&'}" unless query.empty?
      end


      def anchor
        "##{@anchor}" if @anchor
      end


      def to_s
        "#{@asset.site.assets_config.baseurl}/#{path}#{query}#{anchor}"
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
jekyll-assets-0.7.6 lib/jekyll/assets_plugin/asset_path.rb
jekyll-assets-0.7.5 lib/jekyll/assets_plugin/asset_path.rb
jekyll-assets-0.7.4 lib/jekyll/assets_plugin/asset_path.rb
jekyll-assets-0.7.3 lib/jekyll/assets_plugin/asset_path.rb
jekyll-assets-0.7.2 lib/jekyll/assets_plugin/asset_path.rb
jekyll-assets-0.7.1 lib/jekyll/assets_plugin/asset_path.rb