Class: Mosaico::MceSkin
- Inherits:
-
Object
- Object
- Mosaico::MceSkin
- Defined in:
- lib/mosaico/mce_skin.rb
Constant Summary collapse
- CSS_FILES =
{ content: 'content.min.css', inline_content: 'content.inline.min.css', skin: 'skin.min.css' }.freeze
Instance Attribute Summary collapse
-
#inline ⇒ Object
(also: #inline?)
readonly
Returns the value of attribute inline.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #absolute_path ⇒ Object
- #asset_paths ⇒ Object
- #css_asset_paths ⇒ Object
- #font_asset_paths ⇒ Object
- #image_asset_paths ⇒ Object
-
#initialize(name, path) ⇒ MceSkin
constructor
A new instance of MceSkin.
- #list_precompile_assets ⇒ Object
- #resolve_asset(path) ⇒ Object
Constructor Details
#initialize(name, path) ⇒ MceSkin
Returns a new instance of MceSkin.
14 15 16 17 |
# File 'lib/mosaico/mce_skin.rb', line 14 def initialize(name, path) @name = name @path = path end |
Instance Attribute Details
#inline ⇒ Object (readonly) Also known as: inline?
Returns the value of attribute inline.
11 12 13 |
# File 'lib/mosaico/mce_skin.rb', line 11 def inline @inline end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/mosaico/mce_skin.rb', line 11 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/mosaico/mce_skin.rb', line 11 def path @path end |
Instance Method Details
#absolute_path ⇒ Object
19 20 21 |
# File 'lib/mosaico/mce_skin.rb', line 19 def absolute_path @absolute_path ||= Mosaico.vendor_asset_root.join(path) end |
#asset_paths ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/mosaico/mce_skin.rb', line 27 def asset_paths @asset_paths ||= { css: css_asset_paths, images: image_asset_paths, fonts: font_asset_paths } end |
#css_asset_paths ⇒ Object
35 36 37 38 39 |
# File 'lib/mosaico/mce_skin.rb', line 35 def css_asset_paths @css_asset_paths ||= list_css_assets.each_with_object({}) do |(prop, asset_path), ret| ret[prop] = Mosaico.resolve_asset(asset_path) end end |
#font_asset_paths ⇒ Object
47 48 49 50 51 |
# File 'lib/mosaico/mce_skin.rb', line 47 def font_asset_paths @font_asset_paths ||= list_font_assets.each_with_object({}) do |asset_path, ret| ret[asset_path] = Mosaico.resolve_asset(asset_path) end end |
#image_asset_paths ⇒ Object
41 42 43 44 45 |
# File 'lib/mosaico/mce_skin.rb', line 41 def image_asset_paths @image_asset_paths ||= list_image_assets.each_with_object({}) do |asset_path, ret| ret[asset_path] = Mosaico.resolve_asset(asset_path) end end |
#list_precompile_assets ⇒ Object
23 24 25 |
# File 'lib/mosaico/mce_skin.rb', line 23 def list_precompile_assets @precompile_assets ||= list_css_assets.values + list_image_assets + list_font_assets end |
#resolve_asset(path) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mosaico/mce_skin.rb', line 53 def resolve_asset(path) uri = URI.parse(path) [image_asset_paths, font_asset_paths].each do |paths| paths.each do |logical_path, digest_path| if logical_path.end_with?(uri.path) uri.path = digest_path return uri.to_s end end end nil end |