Sha256: 9c33a45759521369bf5667ef70763589beaa7fb2f892e94df8d5f389cd617a63
Contents?: true
Size: 1.42 KB
Versions: 1
Compression:
Stored size: 1.42 KB
Contents
module Jpmobile class Resolver < ActionView::FileSystemResolver EXTENSIONS = [:locale, :formats, :handlers, :mobile] DEFAULT_PATTERN = ":prefix/:action{_:mobile,}{.:locale,}{.:formats,}{.:handlers,}" def initialize(path, pattern=nil) raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver) super(path, pattern || DEFAULT_PATTERN) @path = File.expand_path(path) end private def query(path, details, formats) query = build_query(path, details) # deals with case-insensitive file systems. sanitizer = Hash.new { |h,dir| h[dir] = Dir["#{dir}/*"] } template_paths = Dir[query].reject { |filename| File.directory?(filename) || !sanitizer[File.dirname(filename)].include?(filename) } template_paths.map { |template| handler, format = extract_handler_and_format(template, formats) contents = File.binread template if format jpmobile_variant = template.match(/.+#{path}(.+)\.#{format.to_sym.to_s}.*$/) ? $1 : '' virtual_path = jpmobile_variant.blank? ? path.virtual : path.to_str + jpmobile_variant else virtual_path = path.virtual end ActionView::Template.new(contents, File.expand_path(template), handler, :virtual_path => virtual_path, :format => format, :updated_at => mtime(template)) } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jpmobile-4.1.0.rc1 | lib/jpmobile/resolver.rb |