1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/pathname/pathname.c (path_s_getwd): Pathname.getwd and

Pathname.pwd translated from pathname.rb.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29248 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-09-14 11:18:37 +00:00
parent 6d9b5fdffc
commit bf77099923
4 changed files with 23 additions and 3 deletions

View file

@ -1,3 +1,8 @@
Tue Sep 14 20:17:48 2010 Tanaka Akira <akr@fsij.org>
* 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@fsij.org>
* ext/pathname/pathname.c (path_s_glob): Pathname.glob translated

View file

@ -485,9 +485,6 @@ end
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.

View file

@ -846,6 +846,17 @@ path_s_glob(int argc, VALUE *argv, VALUE klass)
}
}
/*
* 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
*
@ -1100,4 +1111,6 @@ Init_pathname()
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);
}

View file

@ -1164,6 +1164,11 @@ class TestPathname < Test::Unit::TestCase
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") {}