[ANN] pathname2 1.5.1

D

Daniel Berger

Hi all,

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

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

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

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

What's the difference between your version and the one in the stdlib?
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
* 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=20
Windows path names very well (e.g. Pathname#realpath, Pathname#parent), =
and not=20
at all when it comes to UNC paths.

* The Pathname#cleanpath method works differently - it always returns a=20
canonical pathname. In addition, there is no special consideration for=20
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=20
and most FileUtils methods.

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

* Accepts file urls and converts them to paths automatically, e.g.=20
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=20
installs the pure Ruby version only).

Some benchmarks for your amusement
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D
- 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#<=3D> 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#<=3D> 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=20
prohibited and may be unlawful. If you have received this communication =

in error, please immediately notify the sender by reply e-mail and =
destroy=20
all copies of the communication and any attachments.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

[ANN] rs 0.1.2 0
[ANN] JRuby 1.6.0.RC2 released 0
[ANN] JRuby 1.6.1 released 1
[ANN] Rio 0.3.4 22

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top