From 90196398a14896e6a279cbbaa6651861360abc0f Mon Sep 17 00:00:00 2001 From: Cliff Pruitt Date: Mon, 1 Apr 2019 19:29:03 -0400 Subject: Rename File to RawFile --- actionview/lib/action_view/file_template.rb | 2 +- .../lib/action_view/renderer/template_renderer.rb | 2 +- actionview/lib/action_view/template.rb | 2 +- actionview/lib/action_view/template/error.rb | 2 +- actionview/lib/action_view/template/file.rb | 28 ---------------------- actionview/lib/action_view/template/raw_file.rb | 28 ++++++++++++++++++++++ 6 files changed, 32 insertions(+), 32 deletions(-) delete mode 100644 actionview/lib/action_view/template/file.rb create mode 100644 actionview/lib/action_view/template/raw_file.rb (limited to 'actionview') diff --git a/actionview/lib/action_view/file_template.rb b/actionview/lib/action_view/file_template.rb index e0dc7da3b6..dea02176eb 100644 --- a/actionview/lib/action_view/file_template.rb +++ b/actionview/lib/action_view/file_template.rb @@ -11,7 +11,7 @@ module ActionView end def source - ::File.binread @filename + File.binread @filename end def refresh(_) diff --git a/actionview/lib/action_view/renderer/template_renderer.rb b/actionview/lib/action_view/renderer/template_renderer.rb index 698f535b49..1faef9ca81 100644 --- a/actionview/lib/action_view/renderer/template_renderer.rb +++ b/actionview/lib/action_view/renderer/template_renderer.rb @@ -27,7 +27,7 @@ module ActionView Template::HTML.new(options[:html], formats.first) elsif options.key?(:file) if File.exist?(options[:file]) - Template::File.new(options[:file]) + Template::RawFile.new(options[:file]) else ActiveSupport::Deprecation.warn "render file: should be given the absolute path to a file" @lookup_context.with_fallbacks.find_file(options[:file], nil, false, keys, @details) diff --git a/actionview/lib/action_view/template.rb b/actionview/lib/action_view/template.rb index ebe52532d6..94f8a194a0 100644 --- a/actionview/lib/action_view/template.rb +++ b/actionview/lib/action_view/template.rb @@ -113,7 +113,7 @@ module ActionView eager_autoload do autoload :Error - autoload :File + autoload :RawFile autoload :Handlers autoload :HTML autoload :Inline diff --git a/actionview/lib/action_view/template/error.rb b/actionview/lib/action_view/template/error.rb index aace0be04d..d0ea03e228 100644 --- a/actionview/lib/action_view/template/error.rb +++ b/actionview/lib/action_view/template/error.rb @@ -104,7 +104,7 @@ module ActionView def line_number @line_number ||= if file_name - regexp = /#{Regexp.escape ::File.basename(file_name)}:(\d+)/ + regexp = /#{Regexp.escape File.basename(file_name)}:(\d+)/ $1 if message =~ regexp || backtrace.find { |line| line =~ regexp } end end diff --git a/actionview/lib/action_view/template/file.rb b/actionview/lib/action_view/template/file.rb deleted file mode 100644 index 487e5735cf..0000000000 --- a/actionview/lib/action_view/template/file.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -module ActionView #:nodoc: - # = Action View File Template - class Template #:nodoc: - class File #:nodoc: - attr_accessor :type, :format - - def initialize(filename) - @filename = filename.to_s - extname = ::File.extname(filename).delete(".") - @type = Template::Types[extname] || Template::Types[:text] - @format = @type.symbol - end - - def identifier - @filename - end - - def render(*args) - ::File.read(@filename) - end - - def formats; Array(format); end - deprecate :formats - end - end -end diff --git a/actionview/lib/action_view/template/raw_file.rb b/actionview/lib/action_view/template/raw_file.rb new file mode 100644 index 0000000000..61818ba52f --- /dev/null +++ b/actionview/lib/action_view/template/raw_file.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module ActionView #:nodoc: + # = Action View File Template + class Template #:nodoc: + class RawFile #:nodoc: + attr_accessor :type, :format + + def initialize(filename) + @filename = filename.to_s + extname = ::File.extname(filename).delete(".") + @type = Template::Types[extname] || Template::Types[:text] + @format = @type.symbol + end + + def identifier + @filename + end + + def render(*args) + ::File.read(@filename) + end + + def formats; Array(format); end + deprecate :formats + end + end +end -- cgit v1.2.3