Skip to content

Commit

Permalink
Use shorter class-level File methods instead of going through File.stat.
Browse files Browse the repository at this point in the history
  • Loading branch information
thedarkone committed Jul 25, 2011
1 parent 02691d3 commit 624b118
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/template/resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def build_query(path, details)

# 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
Expand Down
4 changes: 2 additions & 2 deletions actionpack/test/template/asset_tag_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def test_audio_tag
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

Expand Down Expand Up @@ -512,7 +512,7 @@ def test_image_tag_interpreting_email_adding_optional_alt_tag

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

Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/file_update_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def initialize(paths, calculate=false, &block)
end

def updated_at
paths.map { |path| File.stat(path).mtime }.max
paths.map { |path| File.mtime(path) }.max
end

def execute_if_updated
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/code_statistics.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def calculate_directory_statistics(directory, pattern = /.*\.rb$/)
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
Expand Down

0 comments on commit 624b118

Please sign in to comment.