pathname2 1.6.3-x86-mswin32-60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES ADDED
@@ -0,0 +1,120 @@
1
+ == 1.6.3 - 2-Oct-2009
2
+ * Updated Windows platform handling code to include mingw and cygwin.
3
+ * Added the :gem rake task.
4
+ * Minor gemspec updates.
5
+ * Some minor test suite updates.
6
+
7
+ == 1.6.2 - 4-Aug-2009
8
+ * Now compatible with Ruby 1.9.x.
9
+ * License changed to Artistic 2.0.
10
+ * Added the Pathname.pwd method as a synonym for Pathname.new(Dir.pwd).
11
+ * Modified Pathname#dirname so that you can specify a level that indicates
12
+ how many levels up you want to retrieve. For example, if your path was
13
+ '/usr/local/bin', then path.dirname(2) would return '/usr'.
14
+ * Now compatible with Ruby 1.9.x.
15
+ * Bumped required version of the facade library to 1.0.4.
16
+
17
+ == 1.6.1 - 8-Nov-2008
18
+ * Added the Pathname#[] method, which accepts an index, an index plus a
19
+ length, or a range, and returns appropriate the path element(s).
20
+ * Refactoring the platform checking in the test suite to use rbconfig instead
21
+ of RUBY_PLATFORM.
22
+ * More inline documentation examples.
23
+
24
+ == 1.6.0 - 13-July-2008
25
+ * The facade for ftools (and ftools itself) has been removed. The ftools
26
+ library is deprecated in favor of FileUtils.
27
+ * PathnameError is now Pathname::Error.
28
+ * Bug fix for Pathname#relative_path_from for MS Windows. Thanks go to an
29
+ anonymous user for the spot.
30
+ * Fixed a bug where frozen strings would raise an error on MS Windows.
31
+ * The code is now -w clean.
32
+ * Removed the C version as part of the release because it was just too
33
+ difficult to maintain both versions. The C code remains in CVS, however.
34
+ * Changed platform checking to use rbconfig instead of RUBY_PLATFORM to avoid
35
+ potential issues with other Ruby implementation.
36
+
37
+ == 1.5.2 - 9-Mar-2007
38
+ * Bug fix for the Pathname#realpath method where it was not handling recursive
39
+ symlinks. The C version was also fixed, but it only affected platforms that
40
+ don't have the realpath() function.
41
+ * Added a test for recursive symlinks (for Solaris, anyway).
42
+ * Updated the docs for Pathname#realpath.
43
+ * Minor speed enhancements for the C version and the elimination of one
44
+ (potential) segfault.
45
+ * Added a 'Future Plans' section to the README.
46
+ * Added a Rakefile. You can now build, clean, and test and install (both the
47
+ pure Ruby and C versions).
48
+
49
+ == 1.5.1 - 28-Aug-2006
50
+ * Added the Kernel#pn method as a shortcut for Pathname.new.
51
+ * The Pathname#readlink now properly handles symbolic links. The 'fix'
52
+ from 1.4.4 did not work.
53
+ * The C extension uses your system's realpath() function for the
54
+ Pathname#readlink method if it has one.
55
+ * Added the '/' alias for '+'. So, p1 / p2 is the same as p1 + p2.
56
+ * The windows-pr package is now required on MS Windows.
57
+
58
+ == 1.5.0 - 17-Apr-2006
59
+ * Better subclass handling, in that some methods that previously returned
60
+ hardcoded Pathname.new now return self.class.new.
61
+ * File URL's are now handled on Unix as well (using the 'uri' package).
62
+ * Some comment changes/clarifications.
63
+ * Added the PathnameError class to the pure Ruby version.
64
+
65
+ == 1.4.4 - 23-Mar-2006
66
+ * If the path is a symbolic link the Pathname#realpath method
67
+ now returns the absolute path of that link, i.e. the result
68
+ of File.readlink (as a Pathname object).
69
+
70
+ == 1.4.3 - 3-Mar-2006
71
+ * Added the Pathname#realpath method.
72
+
73
+ == 1.4.2 - 22-Feb-2006
74
+ * Fixed the Pathname#relative_path_from method for Windows. This really only
75
+ affected edge cases that you probably never saw anyway.
76
+ * Added corresponding tests for Windows.
77
+
78
+ == 1.4.1 - 18-Feb-2006
79
+ * Added the Pathname#parent method.
80
+ * Added the Pathname#relative_path_from method.
81
+ * Bug fix for Pathname#pstrip on *nix.
82
+ * Corresponding test suite additions.
83
+
84
+ == 1.4.0 - 19-Dec-2005
85
+ * Added destructive and non-destructive methods for some methods - pstrip,
86
+ pstrip!, undecorate, undecorate!, clean and clean!.
87
+ * Added a C extension version of this package. You can use the C version
88
+ instead of the pure Ruby version instead. See the README for more details.
89
+ * Fixed bug in the root method where the result wasn't guaranteed to be a
90
+ Pathname class.
91
+ * Fixed bugs in Windows version where the receiver was inadvertantly modified
92
+ in some cases, and added tests to check for this in the future.
93
+ * Modified the Dir.glob facade so that it (temporarily) changes to the path
94
+ directory, globs on that path, then returns to the original directory.
95
+ * Added the bench_pathname.rb script to let you benchmark all Pathname
96
+ methods.
97
+
98
+ == 1.3.1 - 21-Nov-2005
99
+ * Added the Pathname#children method.
100
+ * Added tests for the Pathname#children method.
101
+
102
+ == 1.3.0 - 28-Oct-2005
103
+ * Added the short_path and long_path methods for MS Windows.
104
+ * Optimization for the '+' method on Unix.
105
+ * Added some examples under the 'examples' directory.
106
+ * More tests added and some minor changes to the test suite in general.
107
+
108
+ == 1.2.1 - 1-Sep-2005
109
+ * Bug fix for the ascend and descend methods wrt Windows and UNC paths.
110
+ * More tests added for ascend and descend methods.
111
+
112
+ == 1.2.0 - 29-Aug-2005
113
+ * Added the 'ascend' and 'descend' methods.
114
+ * Added corresponding test suite additions.
115
+
116
+ == 1.1.0 - 13-Jul-2005
117
+ * Added the 'find' facade.
118
+
119
+ == 1.0.0 - 11-Jun-2005
120
+ * Initial release
data/MANIFEST ADDED
@@ -0,0 +1,11 @@
1
+ * CHANGES
2
+ * MANIFEST
3
+ * Rakefile
4
+ * README
5
+ * pathname2.gempsec
6
+ * benchmarks/bench_all.rb
7
+ * benchmarks/bench_plus.rb
8
+ * examples/example_pathname.rb
9
+ * lib/pathname2.rb
10
+ * test/test_pathname.rb
11
+ * test/test_pathname_windows.rb
data/README ADDED
@@ -0,0 +1,109 @@
1
+ == Description
2
+ A drop-in replacement for the current Pathname class.
3
+
4
+ == Prerequisites
5
+ * Ruby 1.8.0 or later
6
+ * facade 1.0.0 or later (available on the RAA and as a gem)
7
+ * windows-pr 0.5.1 or later (available on the RAA and as a gem)
8
+
9
+ The windows-pr library is only required on MS Windows.
10
+
11
+ == Installation, pure Ruby
12
+ === Manual Installation
13
+ rake test (optional)
14
+ rake install
15
+
16
+ === Gem Installation
17
+ rake test (optional)
18
+ gem install pathname2-<version>.gem
19
+
20
+ == Installation, C extension
21
+ rake test_c (optional)
22
+ rake install_c
23
+
24
+ == Synopsis
25
+ require "pathname2"
26
+
27
+ # Unix
28
+ path1 = "/foo/bar/baz"
29
+ path2 = "../zap"
30
+
31
+ path1 + path2 # "/foo/bar/zap"
32
+ path1 / path2 # "/foo/bar/zap" (same as +)
33
+ path1.exists? # Does this path exist?
34
+ path1.dirname # "/foo/bar"
35
+ path1.to_a # ['foo','bar','baz']
36
+
37
+ # Windows
38
+ path1 = "C:/foo/bar/baz"
39
+ path2 = "../zap"
40
+
41
+ path1 + path2 # "C:\\foo\\bar\\zap"
42
+ path1.root # "C:\\"
43
+ path1.to_a # ['C:','foo','bar','baz']
44
+
45
+ == Windows Notes
46
+ All forward slashes are converted to backslashes for Pathname objects.
47
+
48
+ == Differences between Unix and Windows
49
+ If your pathname consists solely of ".", or "..", the return
50
+ value for Pathname#clean will be different. On Win32, "\\" is returned,
51
+ while on Unix "." is returned. I consider this an extreme edge case and
52
+ will not worry myself with it.
53
+
54
+ == Differences between Pathname in the standard library and this version
55
+ * It is a subclass of String (and thus, mixes in Enumerable).
56
+ * It has sensical to_a and root instance methods.
57
+ * It works on Windows and Unix. The current implementation does not work
58
+ with Windows path names very well, and not at all when it comes to UNC
59
+ paths.
60
+ * The Pathname#cleanpath method works differently - it always returns
61
+ a canonical pathname. In addition, there is no special consideration
62
+ for symlinks (yet), though I'm not sure it warrants it.
63
+ * The Pathname#+ method auto cleans.
64
+ * It uses a facade for all File and Dir methods, as well as most FileUtils
65
+ methods.
66
+ * Pathname#clean works slightly differently. In the stdlib version,
67
+ Pathname#clean("../a") returns "../a". In this version, it returns "a".
68
+ This affects other methods, such as Pathname#relative_path_from.
69
+ * Accepts file urls and converts them to paths automatically, e.g.
70
+ file:///foo%20bar/baz becomes '/foo/bar/baz'.
71
+ * Adds a Kernel level +pn+ method as a shortcut.
72
+ * Allows you to add paths together with the '/' operator.
73
+
74
+ == Method Priority
75
+ Because there is some overlap in method names between File, Dir, and
76
+ FileUtils, the priority is as follows:
77
+
78
+ * File
79
+ * Dir
80
+ * FileUtils
81
+
82
+ In other words, whichever of these defines a given method first is the
83
+ method that is used by the pathname2 library.
84
+
85
+ == Known Issues
86
+ In Ruby 1.8.3 and 1.8.4 you will see a failure in the test suite regarding
87
+ 'fu_world_writable?' from FileUtils. You can ignore this. That method is
88
+ supposed to be private. See ruby-core:7383.
89
+
90
+ Any other issues should be reported on the project page at
91
+ http://www.rubyforge.org/projects/shards
92
+
93
+ == Future Plans
94
+ Suggestions welcome.
95
+
96
+ == License
97
+ Artistic 2.0
98
+
99
+ == Copyright
100
+ (C) 2003-2009 Daniel J. Berger
101
+ All rights reserved.
102
+
103
+ == Warranty
104
+ This library is provided "as is" and without any express or
105
+ implied warranties, including, without limitation, the implied
106
+ warranties of merchantability and fitness for a particular purpose.
107
+
108
+ == Author
109
+ Daniel J. Berger
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ require 'rake'
2
+ require 'rake/clean'
3
+ require 'rake/testtask'
4
+
5
+ desc 'Install pathname2 library (non-gem)'
6
+ task :install do
7
+ cp 'lib/pathname2.rb', Config::CONFIG['sitelibdir']
8
+ end
9
+
10
+ desc 'Build the pathname2 gem'
11
+ task :gem do
12
+ spec = eval(IO.read('pathname2.gemspec'))
13
+ Gem::Builder.new(spec).build
14
+ end
15
+
16
+ desc "Install the pathname2 libarary as a gem"
17
+ task :install_gem => [:gem] do
18
+ file = Dir["*.gem"].first
19
+ sh "gem install #{file}"
20
+ end
21
+
22
+ desc 'Run the test suite for the pure Ruby version'
23
+ Rake::TestTask.new('test') do |t|
24
+ t.warning = true
25
+ t.verbose = true
26
+
27
+ if Config::CONFIG['host_os'] =~ /mswin|win32|dos|cygwin|mingw/i
28
+ t.test_files = FileList['test/test_pathname_windows.rb']
29
+ else
30
+ t.test_files = FileList['test/test_pathname.rb']
31
+ end
32
+ end
33
+
34
+ desc 'Run the Pathname benchmark suite'
35
+ task :benchmark do
36
+ sh 'ruby -Ilib benchmarks/bench_pathname.rb'
37
+ end
38
+
39
+ desc 'Run the benchmark suite for Pathname#+ vs File.join'
40
+ task :benchmark_plus do
41
+ sh 'ruby -Ilib benchmarks/bench_plus.rb'
@@ -0,0 +1,127 @@
1
+ #####################################################################
2
+ # bench_pathname.rb
3
+ #
4
+ # Benchmark suite for all methods of the Pathname class, excluding
5
+ # the facade methods.
6
+ #
7
+ # Use the Rake tasks to run this benchmark:
8
+ #
9
+ # => rake benchmark to run the pure Ruby benchmark.
10
+ #####################################################################
11
+ require 'benchmark'
12
+ require 'pathname2'
13
+ require 'rbconfig'
14
+
15
+ if Config::CONFIG['host_os'].match("mswin")
16
+ path1 = Pathname.new("C:\\Program Files\\Windows NT")
17
+ path2 = Pathname.new("Accessories")
18
+ path3 = Pathname.new("C:\\Program Files\\..\\.\\Windows NT")
19
+ else
20
+ path1 = Pathname.new("/usr/local")
21
+ path2 = Pathname.new("bin")
22
+ path3 = Pathname.new("/usr/../local/./bin")
23
+ path4 = Pathname.new("/dev/stdin")
24
+ end
25
+
26
+ MAX = 10000
27
+
28
+ Benchmark.bm(25) do |bench|
29
+ bench.report("Pathname.new(path)"){
30
+ MAX.times{ Pathname.new("/usr/local/bin") }
31
+ }
32
+
33
+ bench.report("Pathname#+(Pathname)"){
34
+ MAX.times{ path1 + path2 }
35
+ }
36
+
37
+ bench.report("Pathname#+(String)"){
38
+ MAX.times{ path1 + path2 }
39
+ }
40
+
41
+ bench.report("Pathname#children"){
42
+ MAX.times{ path1.children }
43
+ }
44
+
45
+ bench.report("Pathname#pstrip"){
46
+ MAX.times{ path1.pstrip }
47
+ }
48
+
49
+ bench.report("Pathname#pstrip!"){
50
+ MAX.times{ path1.pstrip! }
51
+ }
52
+
53
+ bench.report("Pathname#to_a"){
54
+ MAX.times{ path1.to_a }
55
+ }
56
+
57
+ bench.report("Pathname#descend"){
58
+ MAX.times{ path1.descend{} }
59
+ }
60
+
61
+ bench.report("Pathname#ascend"){
62
+ MAX.times{ path1.ascend{} }
63
+ }
64
+
65
+ bench.report("Pathname#root"){
66
+ MAX.times{ path1.root }
67
+ }
68
+
69
+ bench.report("Pathname#root?"){
70
+ MAX.times{ path1.root? }
71
+ }
72
+
73
+ bench.report("Pathname#<=>"){
74
+ MAX.times{ path1 <=> path2 }
75
+ }
76
+
77
+ bench.report("Pathname#absolute?"){
78
+ MAX.times{ path1.absolute? }
79
+ }
80
+
81
+ bench.report("Pathname#relative?"){
82
+ MAX.times{ path1.relative? }
83
+ }
84
+
85
+ bench.report("Pathname#clean"){
86
+ MAX.times{ path3.clean }
87
+ }
88
+
89
+ bench.report("Pathname#clean!"){
90
+ MAX.times{ path3.clean! }
91
+ }
92
+
93
+ # Platform specific tests
94
+ if Config::CONFIG['host_os'].match("mswin")
95
+ bench.report("Pathname.new(file_url)"){
96
+ MAX.times{ Pathname.new("file:///C:/usr/local/bin") }
97
+ }
98
+
99
+ bench.report("Pathname#drive_number"){
100
+ MAX.times{ path1.drive_number }
101
+ }
102
+
103
+ bench.report("Pathname#unc?"){
104
+ MAX.times{ path1.unc? }
105
+ }
106
+
107
+ bench.report("Pathname#undecorate"){
108
+ MAX.times{ path1.undecorate }
109
+ }
110
+
111
+ bench.report("Pathname#undecorate!"){
112
+ MAX.times{ path1.undecorate! }
113
+ }
114
+
115
+ bench.report("Pathname#short_path"){
116
+ MAX.times{ path1.short_path }
117
+ }
118
+
119
+ bench.report("Pathname#long_path"){
120
+ MAX.times{ path1.long_path }
121
+ }
122
+ else
123
+ bench.report("Pathname#realpath"){
124
+ MAX.times{ path4.realpath }
125
+ }
126
+ end
127
+ end
@@ -0,0 +1,34 @@
1
+ ##############################################################################
2
+ # Compare File.join vs. Pathname#+
3
+ #
4
+ # This benchmark was inspired by a post by Thomas Sawyer. Note that
5
+ # Pathname#+ will never be as fast as File.join, but this provides a
6
+ # good base for further optimizations.
7
+ #
8
+ # Also keep in mind that File.join does no path normalization whatsoever,
9
+ # e.g. File.join("foo", "/bar") behaves differently than Pathname.new("foo")
10
+ # + Pathname.new("/bar"). This is true of both the pathname and pathname2
11
+ # packages.
12
+ #
13
+ # You can run this via the 'rake benchmark_plus' task.
14
+ ##############################################################################
15
+ require 'benchmark'
16
+ require 'pathname2'
17
+
18
+ MAX = 10000
19
+
20
+ s1 = "a/b/c"
21
+ s2 = "d/e/f"
22
+
23
+ path1 = Pathname.new(s1)
24
+ path2 = Pathname.new(s2)
25
+
26
+ Benchmark.bm(10) do |bench|
27
+ bench.report("File.join"){
28
+ MAX.times{ File.join(s1, s2) }
29
+ }
30
+
31
+ bench.report("Pathname#+"){
32
+ MAX.times{ path1 + path2 }
33
+ }
34
+ end
@@ -0,0 +1,25 @@
1
+ ########################################################################
2
+ # example_pathname.rb
3
+ #
4
+ # Some examples to demonstrate the behavior of the pathname2 library.
5
+ ########################################################################
6
+ require 'pathname2'
7
+
8
+ puts "VERSION: " + Pathname::VERSION
9
+
10
+ path1 = Pathname.new("foo/bar")
11
+ path2 = Pathname.new("baz/blah")
12
+
13
+ path3 = Pathname.new("foo/../bar")
14
+ path4 = Pathname.new("../baz")
15
+
16
+ p path1 + path2 # foo/bar/baz/blah
17
+ p path3 + path4 # baz
18
+
19
+ # Shortcut syntax
20
+ path = pn{ "C:\\Documents and Settings\\snoopy\\My Documents" }
21
+
22
+ p path[0] # C:
23
+ p path[1] # Documents and Settings
24
+ p path[0,2] # C:\\Documents and Settings
25
+ p path[0..2] # C:\\Documents and Settings\\snoopy