module Roda::RodaPlugins::Assets::InstanceMethods
def assets_paths(type)
Return an array of paths for the given asset type and optionally
def assets_paths(type) o = self.class.assets_opts if type.is_a?(Array) ltype, *dirs = type else ltype = type end stype = ltype.to_s url_prefix = request.script_name if self.class.opts[:add_script_name] relative_paths = o[:relative_paths] paths = if o[:compiled] relative_paths = false if o[:compiled_asset_host] if ukey = _compiled_assets_hash(type, true) ["#{o[:compiled_asset_host]}#{url_prefix}/#{o[:"compiled_#{stype}_prefix"]}.#{ukey}.#{stype}"] else [] end else asset_dir = o[ltype] if dirs && !dirs.empty? dirs.each{|f| asset_dir = asset_dir[f]} prefix = "#{dirs.join('/')}/" if o[:group_subdirs] end Array(asset_dir).map do |f| if ts = o[:timestamp_paths] mtime = asset_last_modified(File.join(o[:"#{stype}_path"], *[prefix, f].compact)) mtime = "#{sprintf("%i%06i", mtime.to_i, mtime.usec)}#{ts}" end "#{url_prefix}/#{o[:"#{stype}_prefix"]}#{mtime}#{prefix}#{f}#{o[:"#{stype}_suffix"]}" end end if relative_paths paths.map! do |path| "#{relative_prefix}#{path}" end end paths end