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

ruby-changes:33745

From: akr <ko1@a...>
Date: Mon, 5 May 2014 21:49:37 +0900 (JST)
Subject: [ruby-changes:33745] akr:r45826 (trunk): * ext/pathname/lib/pathname.rb (Pathname#/): Aliased to Pathname#+.

akr	2014-05-05 21:49:27 +0900 (Mon, 05 May 2014)

  New Revision: 45826

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

  Log:
    * ext/pathname/lib/pathname.rb (Pathname#/): Aliased to Pathname#+.
      Suggested by Alexey Muranov.  [ruby-core:61432] [Feature #9625]

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/ext/pathname/lib/pathname.rb
    trunk/test/pathname/test_pathname.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45825)
+++ ChangeLog	(revision 45826)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Mon May  5 21:48:04 2014  Tanaka Akira  <akr@f...>
+
+	* ext/pathname/lib/pathname.rb (Pathname#/): Aliased to Pathname#+.
+	  Suggested by Alexey Muranov.  [ruby-core:61432] [Feature #9625]
+
 Mon May  5 17:26:09 2014  Tadayoshi Funaba  <tadf@d...>
 
 	* math.c (rb_math_sqrt): omitted exporting an unused function,
Index: ext/pathname/lib/pathname.rb
===================================================================
--- ext/pathname/lib/pathname.rb	(revision 45825)
+++ ext/pathname/lib/pathname.rb	(revision 45826)
@@ -324,12 +324,17 @@ class Pathname https://github.com/ruby/ruby/blob/trunk/ext/pathname/lib/pathname.rb#L324
   #   p2 = p1 + "bin/ruby"           # Pathname:/usr/bin/ruby
   #   p3 = p1 + "/etc/passwd"        # Pathname:/etc/passwd
   #
+  #   # / is aliased to +.
+  #   p4 = p1 / "bin/ruby"           # Pathname:/usr/bin/ruby
+  #   p5 = p1 / "/etc/passwd"        # Pathname:/etc/passwd
+  #
   # This method doesn't access the file system; it is pure string manipulation.
   #
   def +(other)
     other = Pathname.new(other) unless Pathname === other
     Pathname.new(plus(@path, other.to_s))
   end
+  alias / +
 
   def plus(path1, path2) # -> path # :nodoc:
     prefix2 = path2
Index: NEWS
===================================================================
--- NEWS	(revision 45825)
+++ NEWS	(revision 45826)
@@ -70,6 +70,9 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L70
   * Extended methods:
     * find method accepts "ignore_error" keyword argument.
 
+* Pathname
+  * Pathname#/ is aliased to Pathname#+.
+
 === Stdlib compatibility issues (excluding feature bug fixes)
 
 * time.rb
Index: test/pathname/test_pathname.rb
===================================================================
--- test/pathname/test_pathname.rb	(revision 45825)
+++ test/pathname/test_pathname.rb	(revision 45826)
@@ -213,6 +213,10 @@ class TestPathname < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/pathname/test_pathname.rb#L213
 
   defassert(:plus, 'a//b/d//e', 'a//b/c', '../d//e')
 
+  def test_slash
+    assert_kind_of(Pathname, Pathname("a") / Pathname("b"))
+  end
+
   def test_parent
     assert_equal(Pathname("."), Pathname("a").parent)
   end

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

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