Sha256: 1c1248ffb83d51ebccffe721c32315d533e41024160d8d719b0cc5e678bb9759
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
module Locomotive module Wagon class ThemeAssetDecorator < SimpleDelegator include ToHashConcern def __attributes__ %i(source folder checksum) end def source Locomotive::Coal::UploadIO.new(filepath, nil, realname) end def priority stylesheet_or_javascript? ? 100 : 0 end def stylesheet_or_javascript? File.extname(realname) =~ /^(\.css|\.js)/ end def checksum Digest::MD5.hexdigest(File.read(filepath)) end def relative_url "#{folder.gsub('\\', '/')}/#{realname}" end def short_relative_url relative_url[/^(javascripts|stylesheets|fonts)\/(.*)$/, 2] end def realname # - memoize it because it will not change even if we change the filepath (or source) # - we keep the first extension and drop the others (.coffee, .scss, ...etc) @realname ||= File.basename(filepath).split('.')[0..1].join('.') end def filepath __getobj__.source end def filepath=(path) __getobj__[:source] = path end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
locomotivecms_wagon-2.0.0.pre.alpha | lib/locomotive/wagon/decorators/theme_asset_decorator.rb |