Object
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 25 25: def asset_name 26: raise NotImplementedError 27: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 37 37: def asset_tag(source, options) 38: raise NotImplementedError 39: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 33 33: def custom_dir 34: raise NotImplementedError 35: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 29 29: def extension 30: raise NotImplementedError 31: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 41 41: def include_tag(*sources) 42: options = sources.extract_options!.stringify_keys 43: concat = options.delete("concat") 44: cache = concat || options.delete("cache") 45: recursive = options.delete("recursive") 46: 47: if concat || (config.perform_caching && cache) 48: joined_name = (cache == true ? "all" : cache) + ".#{extension}" 49: joined_path = File.join((joined_name[/^#{File::SEPARATOR}/] ? config.assets_dir : custom_dir), joined_name) 50: unless config.perform_caching && File.exists?(joined_path) 51: write_asset_file_contents(joined_path, compute_paths(sources, recursive)) 52: end 53: asset_tag(joined_name, options) 54: else 55: sources = expand_sources(sources, recursive) 56: ensure_sources!(sources) if cache 57: sources.collect { |source| asset_tag(source, options) }.join("\n").html_safe 58: end 59: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 134 134: def asset_file_path!(absolute_path, error_if_file_is_uri = false) 135: if asset_paths.is_uri?(absolute_path) 136: raise(Errno::ENOENT, "Asset file #{path} is uri and cannot be merged into single file") if error_if_file_is_uri 137: else 138: raise(Errno::ENOENT, "Asset file not found at '#{absolute_path}'" ) unless File.exist?(absolute_path) 139: return absolute_path 140: end 141: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 103 103: def collect_asset_files(*path) 104: dir = path.first 105: 106: Dir[File.join(*path.compact)].collect do |file| 107: file[-(file.size - dir.size - 1)..1].sub(/\.\w+$/, '') 108: end.sort 109: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 71 71: def compute_paths(*args) 72: expand_sources(*args).collect { |source| path_to_asset_source(source) } 73: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 111 111: def determine_source(source, collection) 112: case source 113: when Symbol 114: collection[source] || raise(ArgumentError, "No expansion found for #{source.inspect}") 115: else 116: source 117: end 118: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 97 97: def ensure_sources!(sources) 98: sources.each do |source| 99: asset_file_path!(path_to_asset_source(source)) 100: end 101: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 75 75: def expand_sources(sources, recursive) 76: if sources.first == :all 77: collect_asset_files(custom_dir, ('**' if recursive), "*.#{extension}") 78: else 79: sources.inject([]) do |list, source| 80: determined_source = determine_source(source, expansions) 81: update_source_list(list, determined_source) 82: end 83: end 84: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 120 120: def join_asset_file_contents(paths) 121: paths.collect { |path| File.read(asset_file_path!(path, true)) }.join("\n\n") 122: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 63 63: def path_to_asset(source, options = {}) 64: asset_paths.compute_public_path(source, asset_name.to_s.pluralize, options.merge(:ext => extension)) 65: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 67 67: def path_to_asset_source(source) 68: asset_paths.compute_source_path(source, asset_name.to_s.pluralize, extension) 69: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 86 86: def update_source_list(list, source) 87: case source 88: when String 89: list.delete(source) 90: list << source 91: when Array 92: updated_sources = source - list 93: list.concat(updated_sources) 94: end 95: end
# File lib/action_view/helpers/asset_tag_helpers/asset_include_tag.rb, line 124 124: def write_asset_file_contents(joined_asset_path, asset_paths) 125: FileUtils.mkdir_p(File.dirname(joined_asset_path)) 126: File.atomic_write(joined_asset_path) { |cache| cache.write(join_asset_file_contents(asset_paths)) } 127: 128: # Set mtime to the latest of the combined files to allow for 129: # consistent ETag without a shared filesystem. 130: mt = asset_paths.map { |p| File.mtime(asset_file_path!(p)) }.max 131: File.utime(mt, mt, joined_asset_path) 132: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.