Sha256: 06886d8c5d6526176988b7a9ddd1145f7b78346aa946de32d60867c2c9bd62b0
Contents?: true
Size: 1.33 KB
Versions: 2
Compression:
Stored size: 1.33 KB
Contents
module EmberCli class Assets def initialize(app_name:, ember_app_name:, manifest:) @app_name = app_name @ember_app_name = ember_app_name @manifest = manifest end def javascripts if empty_manifest? fallback_assets else [ latest_matching(%r{#{app_name}/assets/vendor(.*)\.js\z}), latest_matching(%r{#{app_name}/assets/#{ember_app_name}(.*)\.js\z}), ] end end def stylesheets if empty_manifest? fallback_assets else [ latest_matching(%r{#{app_name}/assets/vendor(.*)\.css\z}), latest_matching(%r{#{app_name}/assets/#{ember_app_name}(.*)\.css\z}), ] end end private attr_reader :app_name, :ember_app_name, :manifest def fallback_assets ["#{app_name}/assets/vendor", "#{app_name}/assets/#{ember_app_name}"] end def empty_manifest? files.empty? end def latest_matching(regex) asset, = assets.detect { |(_, digest)| digest == latest_file_for(regex) } asset end def latest_file_for(regex) file, = files. select { |key, _| key =~ regex }. sort_by { |_, data| data["mtime"] }. last file end def assets manifest.assets end def files manifest.files end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ember-cli-rails-0.5.8 | lib/ember_cli/assets.rb |
ember-cli-rails-0.5.7 | lib/ember_cli/assets.rb |