mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Merge pull request #2258 from thedarkone/no-file-stat
Use shorter class-level File methods instead of going through File.stat
This commit is contained in:
@@ -161,7 +161,7 @@ module ActionView
|
||||
|
||||
# Returns the file mtime from the filesystem.
|
||||
def mtime(p)
|
||||
File.stat(p).mtime
|
||||
File.mtime(p)
|
||||
end
|
||||
|
||||
# Extract handler and formats from path. If a format cannot be a found neither
|
||||
|
||||
@@ -481,7 +481,7 @@ class AssetTagHelperTest < ActionView::TestCase
|
||||
end
|
||||
|
||||
def test_timebased_asset_id
|
||||
expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s
|
||||
expected_time = File.mtime(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).to_i.to_s
|
||||
assert_equal %(<img alt="Rails" src="/images/rails.png?#{expected_time}" />), image_tag("rails.png")
|
||||
end
|
||||
|
||||
@@ -512,7 +512,7 @@ class AssetTagHelperTest < ActionView::TestCase
|
||||
|
||||
def test_timebased_asset_id_with_relative_url_root
|
||||
@controller.config.relative_url_root = "/collaboration/hieraki"
|
||||
expected_time = File.stat(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).mtime.to_i.to_s
|
||||
expected_time = File.mtime(File.expand_path(File.dirname(__FILE__) + "/../fixtures/public/images/rails.png")).to_i.to_s
|
||||
assert_equal %(<img alt="Rails" src="#{@controller.config.relative_url_root}/images/rails.png?#{expected_time}" />), image_tag("rails.png")
|
||||
end
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ module ActiveSupport
|
||||
end
|
||||
|
||||
def updated_at
|
||||
paths.map { |path| File.stat(path).mtime }.max
|
||||
paths.map { |path| File.mtime(path) }.max
|
||||
end
|
||||
|
||||
def execute_if_updated
|
||||
|
||||
@@ -30,7 +30,7 @@ class CodeStatistics #:nodoc:
|
||||
stats = { "lines" => 0, "codelines" => 0, "classes" => 0, "methods" => 0 }
|
||||
|
||||
Dir.foreach(directory) do |file_name|
|
||||
if File.stat(directory + "/" + file_name).directory? and (/^\./ !~ file_name)
|
||||
if File.directory?(directory + "/" + file_name) and (/^\./ !~ file_name)
|
||||
newstats = calculate_directory_statistics(directory + "/" + file_name, pattern)
|
||||
stats.each { |k, v| stats[k] += newstats[k] }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user