-
-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge EmberCLI-generated Manifest with Sprockets'
Closes [#298] Expose Ember's fingerprinted assets to Sprockets. No longer support Sprockets-based helpers for Rails 3.2, given the difference in how the Asset Pipeline works post-4.0. [#298]: #298
- Loading branch information
1 parent
7badc25
commit 316e2ef
Showing
14 changed files
with
393 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
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) | ||
file, = files. | ||
select { |key, _| key =~ regex }. | ||
sort_by { |_, data| data["mtime"] }. | ||
last | ||
|
||
file | ||
end | ||
|
||
def files | ||
manifest.files | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require "sprockets" | ||
|
||
module EmberCli | ||
class Manifest | ||
def initialize(environment, path) | ||
@manifest = ::Sprockets::Manifest.new(environment, path) | ||
end | ||
|
||
def merge_into!(other) | ||
other.assets.merge!(@manifest.assets) | ||
other.files.merge!(@manifest.files) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module EmberCli | ||
class MissingManifest | ||
def merge_into!(*) | ||
end | ||
|
||
def files | ||
{} | ||
end | ||
|
||
def assets | ||
{} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.