Sha256: 1b98e31b563bb0919c1f57c6e5b98b65607045908907c08e50ac10a2290084bf

Contents?: true

Size: 870 Bytes

Versions: 2

Compression:

Stored size: 870 Bytes

Contents

module Roadie
  module Rails
    class AssetPipelineProvider
      include Roadie::AssetProvider
      attr_reader :pipeline

      def initialize(pipeline)
        raise ArgumentError, "You need to pass a pipeline to initialize AssetPipelineProvider" unless pipeline
        super()
        @pipeline = pipeline
      end

      def find_stylesheet(name)
        if (asset = @pipeline[normalize_asset_name name])
          Stylesheet.new("#{asset.pathname} (live compiled)", asset.to_s)
        end
      end

      private
      def normalize_asset_name(href)
        remove_asset_prefix href.split('?').first
      end

      def remove_asset_prefix(path)
        path.sub(Regexp.new("^#{Regexp.quote(asset_prefix)}/?"), "")
      end

      def asset_prefix
        ::Rails.application.try(:config).try(:assets).try(:prefix) || "/assets"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roadie-rails-1.0.4 lib/roadie/rails/asset_pipeline_provider.rb
roadie-rails-1.0.3 lib/roadie/rails/asset_pipeline_provider.rb