[前][次][番号順一覧][スレッド一覧]

ruby-changes:31307

From: eregon <ko1@a...>
Date: Tue, 22 Oct 2013 16:59:28 +0900 (JST)
Subject: [ruby-changes:31307] eregon:r43386 (trunk): * file.c (File#expand_path): [DOC] improve documentation of File#expand_path.

eregon	2013-10-22 16:59:23 +0900 (Tue, 22 Oct 2013)

  New Revision: 43386

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43386

  Log:
    * file.c (File#expand_path): [DOC] improve documentation of File#expand_path.
      Based on patch by Prathamesh Sonpatki. [ruby-core:57734] [Bug #9002]

  Modified files:
    trunk/ChangeLog
    trunk/file.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 43385)
+++ ChangeLog	(revision 43386)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct 22 16:57:48 2013  Benoit Daloze  <eregontp@g...>
+
+	* file.c (File#expand_path): [DOC] improve documentation of File#expand_path.
+	  Based on patch by Prathamesh Sonpatki. [ruby-core:57734] [Bug #9002]
+
 Tue Oct 22 15:59:51 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH
Index: file.c
===================================================================
--- file.c	(revision 43385)
+++ file.c	(revision 43386)
@@ -3432,7 +3432,18 @@ rb_file_expand_path_fast(VALUE fname, VA https://github.com/ruby/ruby/blob/trunk/file.c#L3432
  *  user's home directory.
  *
  *     File.expand_path("~oracle/bin")           #=> "/home/oracle/bin"
- *     File.expand_path("../../bin", "/tmp/x")   #=> "/bin"
+ *
+ *  A simple example of using <i>dir_string</i> is as follows.
+ *     File.expand_path("ruby", "/usr/bin")      #=> "/usr/bin/ruby"
+ *
+ *  A more complex example which also resolves parent directory is as follows.
+ *  Suppose we are in bin/mygem and want the absolute path of lib/mygem.rb.
+ *
+ *     File.expand_path("../../lib/mygem.rb", __FILE__)
+ *     #=> ".../path/to/project/lib/mygem.rb"
+ *
+ *  So first it resolves the parent of __FILE__, that is bin/, then go to the
+ *  parent, the root of the project and appends +lib/mygem.rb+.
  */
 
 VALUE

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]