From dd958483b39821116192a135c4993521730c6b2a Mon Sep 17 00:00:00 2001 From: Paul McMahon Date: Mon, 21 May 2012 14:32:56 +0900 Subject: [PATCH] Add exists method to Pathname Dir/File/FileTest all have an exists method, so I found it confusing that Pathname did not. --- ext/pathname/pathname.c | 1 + test/pathname/test_pathname.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index 84a2b5d61ba54c..b269c6169ede2c 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -1226,6 +1226,7 @@ Init_pathname() rb_define_method(rb_cPathname, "executable?", path_executable_p, 0); rb_define_method(rb_cPathname, "executable_real?", path_executable_real_p, 0); rb_define_method(rb_cPathname, "exist?", path_exist_p, 0); + rb_define_method(rb_cPathname, "exists?", path_exist_p, 0); rb_define_method(rb_cPathname, "grpowned?", path_grpowned_p, 0); rb_define_method(rb_cPathname, "directory?", path_directory_p, 0); rb_define_method(rb_cPathname, "file?", path_file_p, 0); diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index ccdc5bd8ebe03c..c68c84c1ccec79 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -992,6 +992,7 @@ def test_exist? with_tmpchdir('rubytest-pathname') {|dir| open("f", "w") {|f| f.write "abc" } assert_equal(true, Pathname("f").exist?) + assert_equal(true, Pathname("f").exists?) } end