ruby-changes:17247
From: akr <ko1@a...>
Date: Tue, 14 Sep 2010 20:19:15 +0900 (JST)
Subject: [ruby-changes:17247] Ruby:r29248 (trunk): * ext/pathname/pathname.c (path_s_getwd): Pathname.getwd and
akr 2010-09-14 20:18:37 +0900 (Tue, 14 Sep 2010) New Revision: 29248 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29248 Log: * ext/pathname/pathname.c (path_s_getwd): Pathname.getwd and Pathname.pwd translated from pathname.rb. Modified files: trunk/ChangeLog trunk/ext/pathname/lib/pathname.rb trunk/ext/pathname/pathname.c trunk/test/pathname/test_pathname.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 29247) +++ ChangeLog (revision 29248) @@ -1,3 +1,8 @@ +Tue Sep 14 20:17:48 2010 Tanaka Akira <akr@f...> + + * ext/pathname/pathname.c (path_s_getwd): Pathname.getwd and + Pathname.pwd translated from pathname.rb. + Tue Sep 14 05:13:04 2010 Tanaka Akira <akr@f...> * ext/pathname/pathname.c (path_s_glob): Pathname.glob translated Index: ext/pathname/lib/pathname.rb =================================================================== --- ext/pathname/lib/pathname.rb (revision 29247) +++ ext/pathname/lib/pathname.rb (revision 29248) @@ -485,9 +485,6 @@ class Pathname # * Dir * - # See <tt>Dir.getwd</tt>. Returns the current working directory as a Pathname. - def Pathname.getwd() self.new(Dir.getwd) end - class << self; alias pwd getwd end # Return the entries (files and subdirectories) in the directory, each as a # Pathname object. Index: ext/pathname/pathname.c =================================================================== --- ext/pathname/pathname.c (revision 29247) +++ ext/pathname/pathname.c (revision 29248) @@ -847,6 +847,17 @@ } /* + * See <tt>Dir.getwd</tt>. Returns the current working directory as a Pathname. + */ +static VALUE +path_s_getwd(VALUE klass) +{ + VALUE str; + str = rb_funcall(rb_cDir, rb_intern("getwd"), 0); + return rb_class_new_instance(1, &str, klass); +} + +/* * == Pathname * * Pathname represents a pathname which locates a file in a filesystem. @@ -1100,4 +1111,6 @@ rb_define_method(rb_cPathname, "writable_real?", path_writable_real_p, 0); rb_define_method(rb_cPathname, "zero?", path_zero_p, 0); rb_define_singleton_method(rb_cPathname, "glob", path_s_glob, -1); + rb_define_singleton_method(rb_cPathname, "getwd", path_s_getwd, 0); + rb_define_singleton_method(rb_cPathname, "pwd", path_s_getwd, 0); } Index: test/pathname/test_pathname.rb =================================================================== --- test/pathname/test_pathname.rb (revision 29247) +++ test/pathname/test_pathname.rb (revision 29248) @@ -1164,6 +1164,11 @@ assert_kind_of(Pathname, wd) end + def test_s_pwd + wd = Pathname.pwd + assert_kind_of(Pathname, wd) + end + def test_entries with_tmpchdir('rubytest-pathname') {|dir| open("a", "w") {} -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/