Sha256: d8983f0089a67adfde3b62b791387a01a8e7afe490d9080cc81ee4a278c493e5

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

module Jasmine
  class AssetExpander
    def initialize(bundled_asset_factory, asset_path_for)
      @bundled_asset_factory = bundled_asset_factory
      @asset_path_for = asset_path_for
    end

    def expand(src_dir, src_path)
      pathname = src_path.gsub(/^\/?assets\//, '').gsub(/\.js$/, '')
      bundled_asset = @bundled_asset_factory.call(pathname, 'js')
      return nil unless bundled_asset

      base_asset = "#{bundled_asset.pathname.to_s.gsub(/#{src_dir}/, '')}?body=true"
      bundled_asset.to_a.inject([base_asset]) do |assets, asset|
        assets << "/#{@asset_path_for.call(asset).gsub(/^\//, '')}?body=true"
      end.flatten
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
jasmine-multi_json-1.3.1.1 lib/jasmine/asset_expander.rb
jasmine-1.3.1 lib/jasmine/asset_expander.rb