Class: Jasmine::AssetExpander

Inherits:
Object
  • Object
show all
Defined in:
lib/jasmine/asset_expander.rb

Instance Method Summary collapse

Constructor Details

#initialize(bundled_asset_factory, asset_path_for) ⇒ AssetExpander

Returns a new instance of AssetExpander.



3
4
5
6
# File 'lib/jasmine/asset_expander.rb', line 3

def initialize(bundled_asset_factory, asset_path_for)
  @bundled_asset_factory = bundled_asset_factory
  @asset_path_for = asset_path_for
end

Instance Method Details

#expand(src_dir, src_path) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/jasmine/asset_expander.rb', line 8

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

  bundled_asset.to_a.map do |asset|
    "/#{@asset_path_for.call(asset).gsub(/^\//, '')}?body=true"
  end.flatten
end