class EmberCli::Assets::AssetMap

Attributes

asset_map[R]
name[R]

Public Class Methods

new(name:, asset_map:) click to toggle source
# File lib/ember_cli/assets/asset_map.rb, line 6
def initialize(name:, asset_map:)
  @name = name
  @asset_map = asset_map
end

Public Instance Methods

javascripts() click to toggle source
# File lib/ember_cli/assets/asset_map.rb, line 11
def javascripts
  assert_asset_map!

  [
    asset_matching(/vendor(.*)\.js\z/),
    asset_matching(/#{name}(.*)\.js\z/),
  ]
end
stylesheets() click to toggle source
# File lib/ember_cli/assets/asset_map.rb, line 20
def stylesheets
  assert_asset_map!

  [
    asset_matching(/vendor(.*)\.css\z/),
    asset_matching(/#{name}(.*)\.css\z/),
  ]
end

Private Instance Methods

assert_asset_map!() click to toggle source
# File lib/ember_cli/assets/asset_map.rb, line 59
      def assert_asset_map!
        if assets.empty?
          raise BuildError.new <<-MSG
            Missing `#{name}/assets/assetMap.json`
          MSG
        end
      end
asset_matching(regex) click to toggle source
# File lib/ember_cli/assets/asset_map.rb, line 33
def asset_matching(regex)
  matching_asset = files.detect { |asset| asset =~ regex }

  if matching_asset.to_s.empty?
    raise_missing_asset(regex)
  end

  prepend + matching_asset
end
assets() click to toggle source
# File lib/ember_cli/assets/asset_map.rb, line 51
def assets
  asset_map["assets"] || {}
end
files() click to toggle source
# File lib/ember_cli/assets/asset_map.rb, line 47
def files
  Array(assets.values)
end
prepend() click to toggle source
# File lib/ember_cli/assets/asset_map.rb, line 43
def prepend
  asset_map["prepend"].to_s
end
raise_missing_asset(regex) click to toggle source
# File lib/ember_cli/assets/asset_map.rb, line 55
def raise_missing_asset(regex)
  raise BuildError.new("Failed to find assets matching `#{regex}`")
end