-
Notifications
You must be signed in to change notification settings - Fork 645
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix assets lookup for precompiled assets
- use asset_manifest if available - gems missing from dev dependencies - remove static preset asset path in unit test that breaks tests for anyone without ENV variable set
- Loading branch information
1 parent
2742687
commit a1a8897
Showing
4 changed files
with
46 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class WickedPdf | ||
module WickedPdfHelper | ||
module Assets | ||
AssetWrapper = Struct.new(:asset, :filename) do | ||
def source | ||
asset.respond_to?(:source) ? source.source : asset | ||
end | ||
|
||
def to_s | ||
asset.to_s | ||
end | ||
|
||
def content_type | ||
asset.respond_to?(:content_type) ? source.content_type : get_mime_type | ||
end | ||
|
||
def extension | ||
filename.to_s[/^.*\/?.*?\.(\w+)(\?.*)?/, 1] | ||
end | ||
|
||
private | ||
|
||
def get_mime_type | ||
mime = Mime::Type.lookup_by_extension(extension) | ||
|
||
raise 'Mime not Found' unless mime | ||
|
||
mime | ||
rescue StandardError | ||
`file --b --mime-type '#{filename}'`.strip | ||
end | ||
end | ||
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