[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] pathname2 1.5.1

Berger, Daniel

8/28/2006 9:46:00 PM

Hi all,

I'm happy to announce the release of pathname2 1.5.1.

What is it?
===========
An alternate implementation of the Pathname class.

What's new?
===========
This release adds the Kernel#pn method as a shortcut for Pathname.new, as well
as an '/' alias for the '+' method. It also fixes a bug with Pathname#realpath
and symbolic links.

Where is it?
============
You can find it on the RAA or RubyForge (part of the Shards project). You can
also install it via gems.

What's the difference between your version and the one in the stdlib?
=====================================================================
* It is a subclass of String (and thus, mixes in Enumerable).

* It has sensical to_a and root instance methods.

* It works on Windows and Unix. The current implementation does not work with
Windows path names very well (e.g. Pathname#realpath, Pathname#parent), and not
at all when it comes to UNC paths.

* The Pathname#cleanpath method works differently - it always returns a
canonical pathname. In addition, there is no special consideration for
symlinks (yet, though I'm not sure how important this really is).

* The Pathname#+ method auto cleans.

* It uses a facade for all File and Dir methods, as well as all ftools methods
and most FileUtils methods.

* Pathname#clean works slightly differently. In the stdlib version,
Pathname#clean("../a") returns "../a". In this version, it returns "a". This
affects other methods, such as Pathname#relative_path_from.

* Accepts file urls and converts them to paths automatically, e.g.
file:///foo%20bar/baz becomes '/foo bar/baz'.

* Adds a Kernel level +pn+ method as a shortcut.

* Allows you to add paths together with the '/' operator.

* Provides an implementation in C if you desperately need speed (though the gem
installs the pure Ruby version only).

Some benchmarks for your amusement
==================================
- Pure Ruby
user system total real
Pathname.new(path) 0.640000 0.110000 0.750000 ( 0.779167)
Pathname#+(Pathname) 8.970000 1.370000 10.340000 ( 10.834968)
Pathname#+(String) 9.060000 1.370000 10.430000 ( 15.592133)
Pathname#children 11.520000 2.670000 14.190000 ( 19.733709)
Pathname#pstrip 1.010000 0.160000 1.170000 ( 1.194300)
Pathname#pstrip! 0.250000 0.100000 0.350000 ( 0.340941)
Pathname#to_a 0.590000 0.100000 0.690000 ( 0.697782)
Pathname#descend 8.470000 1.540000 10.010000 ( 11.796088)
Pathname#ascend 11.990000 1.590000 13.580000 ( 15.250620)
Pathname#root 0.910000 0.160000 1.070000 ( 1.126409)
Pathname#root? 1.000000 0.200000 1.200000 ( 1.250843)
Pathname#<=> 0.180000 0.090000 0.270000 ( 0.298482)
Pathname#absolute? 1.070000 0.240000 1.310000 ( 1.359826)
Pathname#relative? 1.020000 0.200000 1.220000 ( 1.271063)
Pathname#clean 5.460000 1.150000 6.610000 ( 6.839555)
Pathname#clean! 13.770000 1.980000 15.750000 ( 16.293503)
Pathname#realpath 11.670000 2.400000 14.070000 ( 14.590873)

- C extension
user system total real
Pathname.new(path) 0.160000 0.050000 0.210000 ( 0.236884)
Pathname#+(Pathname) 2.360000 0.070000 2.430000 ( 2.561718)
Pathname#+(String) 2.340000 0.070000 2.410000 ( 2.508076)
Pathname#children 4.400000 1.240000 5.640000 ( 5.757893)
Pathname#pstrip 0.220000 0.050000 0.270000 ( 0.288802)
Pathname#pstrip! 0.060000 0.050000 0.110000 ( 0.127524)
Pathname#to_a 0.490000 0.050000 0.540000 ( 0.570622)
Pathname#descend 1.850000 0.110000 1.960000 ( 2.050105)
Pathname#ascend 2.270000 0.100000 2.370000 ( 2.436976)
Pathname#root 0.270000 0.050000 0.320000 ( 0.325671)
Pathname#root? 0.260000 0.060000 0.320000 ( 0.342852)
Pathname#<=> 0.090000 0.040000 0.130000 ( 0.158385)
Pathname#absolute? 0.270000 0.060000 0.330000 ( 0.349167)
Pathname#relative? 0.260000 0.050000 0.310000 ( 0.329822)
Pathname#clean 1.350000 0.060000 1.410000 ( 1.456711)
Pathname#clean! 1.070000 0.060000 1.130000 ( 1.192618)
Pathname#realpath 0.290000 0.320000 0.610000 ( 0.629255)

Enjoy!

- Dan


This communication is the property of Qwest and may contain confidential or
privileged information. Unauthorized use of this communication is strictly
prohibited and may be unlawful. If you have received this communication
in error, please immediately notify the sender by reply e-mail and destroy
all copies of the communication and any attachments.