pathname2 1.8.3 → 1.8.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d5ceebdb160d9cff955f151ea0dfc7d4bcdb9712aaa704a8da7c9313049cea9b
4
- data.tar.gz: 9395e28af5ba15511e1438e3aa03de96a1cf60aa85c0444b5d602fd6f73546b8
3
+ metadata.gz: fddfb413b9216b72763294f0f0a96c4152136d1f260950689dedd19487d54c51
4
+ data.tar.gz: 624d9bd2f4a9d268e07576437cc8c759e324b4408fb4b845fc2c6a2cf251e4ec
5
5
  SHA512:
6
- metadata.gz: 3d6f7a5782967efe3352ed26af74e48b73a321bc13cd01855d413577e9f97d1146e54a2c4562e6928c3dd6f4d6a066118e7f12af1a82f97e15f3cddd9048f5ff
7
- data.tar.gz: 137597451e32bb50a4d13ed9a8e3d5e1fe497968e2bf1c917aa0ba20145c560a211ed64f1b230ea2a552ee79688d86431a02cdcbf933aeb9c051813b6d7b9527
6
+ metadata.gz: 68336850d8d55086487fd8a0677ec6193d390f32be805acb9c3b3630242d09662969bf1aae86b568e6d03d4c67a8da8e5d0f2418b465ceaa7b2d7abc31a089d9
7
+ data.tar.gz: 18997962fbefd926afbd7f57f10fc61bab6dcfc8857fd72cba6f1479ae9b2c91cb910eb40bd49f7b9d8e413905abd750b6199d250ae7ff31edd2fbfda4a1725e
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,51 +1,56 @@
1
- == 1.8.3 - 30-Aug-2020
1
+ ## 1.8.4 - 19-Jan-2021
2
+ * Cleaned up the Rubocop warnings.
3
+ * Added a Gemfile.
4
+ * Some minor updates to the gemspec and Rakefile.
5
+
6
+ ## 1.8.3 - 30-Aug-2020
2
7
  * Updated the tests to match the version. Thanks go to Cédric Boutillier for the spot.
3
8
  * Fixed a redefinition warning for the :children method.
4
9
  * Fixed a Fixnum deprecation warning.
5
10
 
6
- == 1.8.2 - 21-Jul-2020
11
+ ## 1.8.2 - 21-Jul-2020
7
12
  * Added a LICENSE file as required by the Apache-2.0 license.
8
13
 
9
- == 1.8.1 - 31-Jan-2019
14
+ ## 1.8.1 - 31-Jan-2019
10
15
  * The VERSION constant is now frozen.
11
16
  * Added metadata to the gemspec.
12
17
  * Fixed missing hyphen in license name.
13
18
  * Updated cert, should be good for about 10 years.
14
19
 
15
- == 1.8.0 - 19-Jun-2016
20
+ ## 1.8.0 - 19-Jun-2016
16
21
  * Changed license to Apache-2.0.
17
22
  * Some cleanup and updates to the Rakefile and benchmarks.
18
23
  * Refactored some realpath tests so they're not touching system files like
19
24
  /dev/stdin any more. Thanks go to Michael R. Crusoe for pointing out the
20
25
  potential pitfalls of doing that.
21
26
 
22
- == 1.7.4 - 7-Sep-2015
27
+ ## 1.7.4 - 7-Sep-2015
23
28
  * This gem is now signed.
24
29
  * Rakefile now assumes Rubygems 2.x for some tasks.
25
30
 
26
- == 1.7.3 - 24-Apr-2014
31
+ ## 1.7.3 - 24-Apr-2014
27
32
  * The basename and dirname methods now return Pathname objects.
28
33
 
29
- == 1.7.2 - 23-Apr-2014
34
+ ## 1.7.2 - 23-Apr-2014
30
35
  * The join and expand_path methods now return Pathname objects.
31
36
 
32
- == 1.7.1 - 28-Mar-2014
37
+ ## 1.7.1 - 28-Mar-2014
33
38
  * Updated gemspec for Windows vs Unix.
34
39
  * Updated README and MANIFEST.
35
40
 
36
- == 1.7.0 - 28-Mar-2014
41
+ ## 1.7.0 - 28-Mar-2014
37
42
  * Windows now uses FFI internally instead of win32-api.
38
43
  * Added a custom pretty_print method for the pp library.
39
44
  * Reorganized the test suite for Windows, and added many
40
45
  more test tasks to the Rakefile.
41
46
 
42
- == 1.6.5 - 19-Sep-2011
47
+ ## 1.6.5 - 19-Sep-2011
43
48
  * Added the String#to_path instance method. This returns a Pathname
44
49
  object.
45
50
  * The architecture for the Windows gem is now "universal", and some
46
51
  gemspec dependencies were simplified.
47
52
 
48
- == 1.6.4 - 20-Jan-2011
53
+ ## 1.6.4 - 20-Jan-2011
49
54
  * Explicitly remove the Pathname const if it is already defined in order
50
55
  to avoid a superclass mismatch error. This library assumes that if you
51
56
  require pathname2, you want my version of the Pathname class.
@@ -54,13 +59,13 @@
54
59
  * Some Rakefile and gemspec tweaks.
55
60
  * Some updates to the test suite, including some specifically for Windows 7.
56
61
 
57
- == 1.6.3 - 2-Oct-2009
62
+ ## 1.6.3 - 2-Oct-2009
58
63
  * Updated Windows platform handling code to include mingw and cygwin.
59
64
  * Added the :gem rake task.
60
65
  * Minor gemspec updates.
61
66
  * Some minor test suite updates.
62
67
 
63
- == 1.6.2 - 4-Aug-2009
68
+ ## 1.6.2 - 4-Aug-2009
64
69
  * Now compatible with Ruby 1.9.x.
65
70
  * License changed to Artistic 2.0.
66
71
  * Added the Pathname.pwd method as a synonym for Pathname.new(Dir.pwd).
@@ -70,14 +75,14 @@
70
75
  * Now compatible with Ruby 1.9.x.
71
76
  * Bumped required version of the facade library to 1.0.4.
72
77
 
73
- == 1.6.1 - 8-Nov-2008
78
+ ## 1.6.1 - 8-Nov-2008
74
79
  * Added the Pathname#[] method, which accepts an index, an index plus a
75
80
  length, or a range, and returns appropriate the path element(s).
76
81
  * Refactoring the platform checking in the test suite to use rbconfig instead
77
82
  of RUBY_PLATFORM.
78
83
  * More inline documentation examples.
79
84
 
80
- == 1.6.0 - 13-July-2008
85
+ ## 1.6.0 - 13-July-2008
81
86
  * The facade for ftools (and ftools itself) has been removed. The ftools
82
87
  library is deprecated in favor of FileUtils.
83
88
  * PathnameError is now Pathname::Error.
@@ -90,7 +95,7 @@
90
95
  * Changed platform checking to use rbconfig instead of RUBY_PLATFORM to avoid
91
96
  potential issues with other Ruby implementation.
92
97
 
93
- == 1.5.2 - 9-Mar-2007
98
+ ## 1.5.2 - 9-Mar-2007
94
99
  * Bug fix for the Pathname#realpath method where it was not handling recursive
95
100
  symlinks. The C version was also fixed, but it only affected platforms that
96
101
  don't have the realpath() function.
@@ -102,7 +107,7 @@
102
107
  * Added a Rakefile. You can now build, clean, and test and install (both the
103
108
  pure Ruby and C versions).
104
109
 
105
- == 1.5.1 - 28-Aug-2006
110
+ ## 1.5.1 - 28-Aug-2006
106
111
  * Added the Kernel#pn method as a shortcut for Pathname.new.
107
112
  * The Pathname#readlink now properly handles symbolic links. The 'fix'
108
113
  from 1.4.4 did not work.
@@ -111,33 +116,33 @@
111
116
  * Added the '/' alias for '+'. So, p1 / p2 is the same as p1 + p2.
112
117
  * The windows-pr package is now required on MS Windows.
113
118
 
114
- == 1.5.0 - 17-Apr-2006
119
+ ## 1.5.0 - 17-Apr-2006
115
120
  * Better subclass handling, in that some methods that previously returned
116
121
  hardcoded Pathname.new now return self.class.new.
117
122
  * File URL's are now handled on Unix as well (using the 'uri' package).
118
123
  * Some comment changes/clarifications.
119
124
  * Added the PathnameError class to the pure Ruby version.
120
125
 
121
- == 1.4.4 - 23-Mar-2006
126
+ ## 1.4.4 - 23-Mar-2006
122
127
  * If the path is a symbolic link the Pathname#realpath method
123
128
  now returns the absolute path of that link, i.e. the result
124
129
  of File.readlink (as a Pathname object).
125
130
 
126
- == 1.4.3 - 3-Mar-2006
131
+ ## 1.4.3 - 3-Mar-2006
127
132
  * Added the Pathname#realpath method.
128
133
 
129
- == 1.4.2 - 22-Feb-2006
134
+ ## 1.4.2 - 22-Feb-2006
130
135
  * Fixed the Pathname#relative_path_from method for Windows. This really only
131
136
  affected edge cases that you probably never saw anyway.
132
137
  * Added corresponding tests for Windows.
133
138
 
134
- == 1.4.1 - 18-Feb-2006
139
+ ## 1.4.1 - 18-Feb-2006
135
140
  * Added the Pathname#parent method.
136
141
  * Added the Pathname#relative_path_from method.
137
142
  * Bug fix for Pathname#pstrip on *nix.
138
143
  * Corresponding test suite additions.
139
144
 
140
- == 1.4.0 - 19-Dec-2005
145
+ ## 1.4.0 - 19-Dec-2005
141
146
  * Added destructive and non-destructive methods for some methods - pstrip,
142
147
  pstrip!, undecorate, undecorate!, clean and clean!.
143
148
  * Added a C extension version of this package. You can use the C version
@@ -151,26 +156,26 @@
151
156
  * Added the bench_pathname.rb script to let you benchmark all Pathname
152
157
  methods.
153
158
 
154
- == 1.3.1 - 21-Nov-2005
159
+ ## 1.3.1 - 21-Nov-2005
155
160
  * Added the Pathname#children method.
156
161
  * Added tests for the Pathname#children method.
157
162
 
158
- == 1.3.0 - 28-Oct-2005
163
+ ## 1.3.0 - 28-Oct-2005
159
164
  * Added the short_path and long_path methods for MS Windows.
160
165
  * Optimization for the '+' method on Unix.
161
166
  * Added some examples under the 'examples' directory.
162
167
  * More tests added and some minor changes to the test suite in general.
163
168
 
164
- == 1.2.1 - 1-Sep-2005
169
+ ## 1.2.1 - 1-Sep-2005
165
170
  * Bug fix for the ascend and descend methods wrt Windows and UNC paths.
166
171
  * More tests added for ascend and descend methods.
167
172
 
168
- == 1.2.0 - 29-Aug-2005
173
+ ## 1.2.0 - 29-Aug-2005
169
174
  * Added the 'ascend' and 'descend' methods.
170
175
  * Added corresponding test suite additions.
171
176
 
172
- == 1.1.0 - 13-Jul-2005
177
+ ## 1.1.0 - 13-Jul-2005
173
178
  * Added the 'find' facade.
174
179
 
175
- == 1.0.0 - 11-Jun-2005
180
+ ## 1.0.0 - 11-Jun-2005
176
181
  * Initial release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org' do
2
+ gemspec
3
+ end
@@ -1,8 +1,9 @@
1
- * CHANGES
1
+ * CHANGES.md
2
+ * Gemfile
2
3
  * LICENSE
3
- * MANIFEST
4
+ * MANIFEST.md
4
5
  * Rakefile
5
- * README
6
+ * README.md
6
7
  * pathname2.gempsec
7
8
  * benchmarks/bench_all.rb
8
9
  * benchmarks/bench_plus.rb
@@ -0,0 +1,98 @@
1
+ ## Description
2
+ A drop-in replacement for the current Pathname class.
3
+
4
+ ## Prerequisites
5
+ * facade
6
+ * ffi (Windows only)
7
+ * test-unit (testing only)
8
+
9
+ ## Installation
10
+ `gem install pathname2`
11
+
12
+ ## Synopsis
13
+ ```ruby
14
+ require 'pathname2'
15
+
16
+ # Unix
17
+ path1 = Pathname.new("/foo/bar/baz")
18
+ path2 = Pathname.new("../zap")
19
+
20
+ path1 + path2 # "/foo/bar/zap"
21
+ path1 / path2 # "/foo/bar/zap" (same as +)
22
+ path1.exists? # Does this path exist?
23
+ path1.dirname # "/foo/bar"
24
+ path1.to_a # ['foo','bar','baz']
25
+
26
+ # Windows
27
+ path1 = Pathname.new("C:/foo/bar/baz")
28
+ path2 = Pathname.new("../zap")
29
+
30
+ path1 + path2 # "C:\\foo\\bar\\zap"
31
+ path1.root # "C:\\"
32
+ path1.to_a # ['C:','foo','bar','baz']
33
+ ```
34
+
35
+ ## Windows Notes
36
+ All forward slashes are converted to backslashes for Pathname objects.
37
+
38
+ ## Differences between Unix and Windows
39
+ If your pathname consists solely of ".", or "..", the return
40
+ value for Pathname#clean will be different. On Win32, "\\" is returned,
41
+ while on Unix "." is returned. I consider this an extreme edge case and
42
+ will not worry myself with it.
43
+
44
+ ## Differences between Pathname in the standard library and this version
45
+ * It is a subclass of String (and thus, mixes in Enumerable).
46
+ * It has sensical `to_a` and `root` instance methods.
47
+ * It works on Windows and Unix. The current implementation does not work
48
+ with Windows path names very well, and not at all when it comes to UNC
49
+ paths.
50
+ * The `Pathname#cleanpath` method works differently - it always returns
51
+ a canonical pathname. In addition, there is no special consideration
52
+ for symlinks (yet), though I'm not sure it warrants it.
53
+ * The `Pathname#+` method auto cleans.
54
+ * It uses a facade for all File and Dir methods, as well as most FileUtils
55
+ methods.
56
+ * `Pathname#clean` works slightly differently. In the stdlib version,
57
+ `Pathname#clean("../a")` returns "../a". In this version, it returns "a".
58
+ This affects other methods, such as `Pathname#relative_path_from`.
59
+ * Accepts file urls and converts them to paths automatically, e.g.
60
+ file:///foo%20bar/baz becomes '/foo/bar/baz'.
61
+ * Adds a Kernel level `pn` method as a shortcut.
62
+ * Allows you to add paths together with the '/' operator.
63
+
64
+ ## Method Priority
65
+ Because there is some overlap in method names between File, Dir, and
66
+ FileUtils, the priority is as follows:
67
+
68
+ * File
69
+ * Dir
70
+ * FileUtils
71
+
72
+ In other words, whichever of these defines a given method first is the
73
+ method that is used by the pathname2 library.
74
+
75
+ ## Known Issues
76
+ On MS Windows, some methods may not work on pathnames greater than 260
77
+ characters because of internal function limitations.
78
+
79
+ Any issues you find should be reported on the project page at
80
+ https://github.com/djberg96/pathname2
81
+
82
+ ## Future Plans
83
+ None at this time. Suggestions welcome.
84
+
85
+ ## License
86
+ Apache-2.0
87
+
88
+ ## Copyright
89
+ (C) 2003-2021 Daniel J. Berger
90
+ All rights reserved.
91
+
92
+ ## Warranty
93
+ This library is provided "as is" and without any express or
94
+ implied warranties, including, without limitation, the implied
95
+ warranties of merchantability and fitness for a particular purpose.
96
+
97
+ ## Author
98
+ Daniel J. Berger
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rake/testtask'
4
4
 
5
- CLEAN.include("**/*.gem", "**/*.rbc")
5
+ CLEAN.include("**/*.gem", "**/*.rbc", "**/*.lock")
6
6
 
7
7
  namespace :gem do
8
8
  desc "Build the pathname2 gem"
@@ -64,10 +64,10 @@ class Pathname < String
64
64
  :chdir, :entries, :glob, :foreach, :mkdir, :open, :children
65
65
  ]
66
66
 
67
- private
68
-
69
67
  alias :_plus_ :+ # Used to prevent infinite loops in some cases
70
68
 
69
+ protected :_plus_
70
+
71
71
  if File::ALT_SEPARATOR
72
72
  extend FFI::Library
73
73
  ffi_lib :shlwapi
@@ -88,12 +88,17 @@ class Pathname < String
88
88
 
89
89
  attach_function :GetLongPathNameW, [:buffer_in, :buffer_out, :ulong], :ulong
90
90
  attach_function :GetShortPathNameW, [:buffer_in, :pointer, :ulong], :ulong
91
+
92
+ private_class_method :PathAppendW, :PathCanonicalizeW, :PathCreateFromUrlW
93
+ private_class_method :PathGetDriveNumberW, :PathIsRelativeW, :PathIsRelativeW
94
+ private_class_method :PathIsRootW, :PathIsUNCW, :PathIsURLW, :PathRemoveBackslashW
95
+ private_class_method :PathStripToRootW, :PathUndecorateW, :GetLongPathNameW, :GetShortPathNameW
91
96
  end
92
97
 
93
98
  public
94
99
 
95
100
  # The version of the pathname2 library
96
- VERSION = '1.8.3'.freeze
101
+ VERSION = '1.8.4'.freeze
97
102
 
98
103
  # The maximum length of a path
99
104
  MAXPATH = 1024 unless defined? MAXPATH # Yes, I willfully violate POSIX
@@ -809,7 +814,7 @@ class Pathname < String
809
814
  raise ArgumentError if level < 0
810
815
  local_path = self.dup
811
816
 
812
- level.times{ |n| local_path = File.dirname(local_path) }
817
+ level.times{ local_path = File.dirname(local_path) }
813
818
  self.class.new(local_path)
814
819
  end
815
820
 
@@ -854,8 +859,8 @@ class Pathname < String
854
859
  # If +self+ is ".", yielded pathnames begin with a filename in the current
855
860
  # current directory, not ".".
856
861
  #
857
- def find(&block)
858
- require "find"
862
+ def find
863
+ require 'find'
859
864
  if self == "."
860
865
  Find.find(self){ |f| yield self.class.new(f.sub(%r{\A\./}, '')) }
861
866
  else
@@ -1119,11 +1124,13 @@ module Kernel
1119
1124
  instance_eval{ Pathname.new(yield) }
1120
1125
  end
1121
1126
 
1127
+ # rubocop:disable Lint/ShadowedException
1122
1128
  begin
1123
1129
  remove_method(:Pathname)
1124
1130
  rescue NoMethodError, NameError
1125
1131
  # Do nothing, not defined.
1126
1132
  end
1133
+ # rubocop:enable Lint/ShadowedException
1127
1134
 
1128
1135
  # Synonym for Pathname.new
1129
1136
  #
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'pathname2'
5
- spec.version = '1.8.3'
5
+ spec.version = '1.8.4'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -11,8 +11,6 @@ Gem::Specification.new do |spec|
11
11
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
12
12
  spec.cert_chain = ['certs/djberg96_pub.pem']
13
13
 
14
- spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
15
-
16
14
  spec.add_dependency('facade')
17
15
  spec.add_development_dependency('test-unit')
18
16
  spec.add_development_dependency('rake')
@@ -20,7 +18,7 @@ Gem::Specification.new do |spec|
20
18
  spec.metadata = {
21
19
  'homepage_uri' => 'https://github.com/djberg96/pathname2',
22
20
  'bug_tracker_uri' => 'https://github.com/djberg96/pathname2/issues',
23
- 'changelog_uri' => 'https://github.com/djberg96/pathname2/blob/ffi/CHANGES',
21
+ 'changelog_uri' => 'https://github.com/djberg96/pathname2/blob/ffi/CHANGES.md',
24
22
  'documentation_uri' => 'https://github.com/djberg96/pathname2/wiki',
25
23
  'source_code_uri' => 'https://github.com/djberg96/pathname2',
26
24
  'wiki_uri' => 'https://github.com/djberg96/pathname2/wiki'
@@ -28,10 +26,10 @@ Gem::Specification.new do |spec|
28
26
 
29
27
  if File::ALT_SEPARATOR
30
28
  spec.add_dependency('ffi')
31
- spec.test_files = FileList['test/windows/*.rb', 'test/test_version.rb']
29
+ spec.test_files = Dir['test/windows/*.rb', 'test/test_version.rb']
32
30
  spec.platform = Gem::Platform.new(['universal', 'mingw32'])
33
31
  else
34
- spec.test_files = FileList['test/test_pathname.rb', 'test/test_version.rb']
32
+ spec.test_files = Dir['test/test_pathname.rb', 'test/test_version.rb']
35
33
  end
36
34
 
37
35
  spec.description = <<-EOF
@@ -8,7 +8,7 @@ require 'test-unit'
8
8
 
9
9
  class TC_Pathname_Version < Test::Unit::TestCase
10
10
  test "version is set to expected value" do
11
- assert_equal('1.8.3', Pathname::VERSION)
11
+ assert_equal('1.8.4', Pathname::VERSION)
12
12
  end
13
13
 
14
14
  test "version is frozen" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pathname2
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.3
4
+ version: 1.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
@@ -90,10 +90,7 @@ description: |2
90
90
  email: djberg96@gmail.com
91
91
  executables: []
92
92
  extensions: []
93
- extra_rdoc_files:
94
- - README
95
- - CHANGES
96
- - MANIFEST
93
+ extra_rdoc_files: []
97
94
  files:
98
95
  - LICENSE
99
96
  - test
@@ -129,10 +126,9 @@ files:
129
126
  - test/windows/test_to_a.rb
130
127
  - test/test_version.rb
131
128
  - pathname2.gemspec
132
- - CHANGES
133
- - MANIFEST
134
- - README
129
+ - README.md
135
130
  - Rakefile
131
+ - MANIFEST.md
136
132
  - certs
137
133
  - certs/djberg96_pub.pem
138
134
  - examples
@@ -142,13 +138,15 @@ files:
142
138
  - benchmarks/bench_plus.rb
143
139
  - lib
144
140
  - lib/pathname2.rb
141
+ - Gemfile
142
+ - CHANGES.md
145
143
  homepage: https://github.com/djberg96/pathname2
146
144
  licenses:
147
145
  - Apache-2.0
148
146
  metadata:
149
147
  homepage_uri: https://github.com/djberg96/pathname2
150
148
  bug_tracker_uri: https://github.com/djberg96/pathname2/issues
151
- changelog_uri: https://github.com/djberg96/pathname2/blob/ffi/CHANGES
149
+ changelog_uri: https://github.com/djberg96/pathname2/blob/ffi/CHANGES.md
152
150
  documentation_uri: https://github.com/djberg96/pathname2/wiki
153
151
  source_code_uri: https://github.com/djberg96/pathname2
154
152
  wiki_uri: https://github.com/djberg96/pathname2/wiki
@@ -167,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
165
  - !ruby/object:Gem::Version
168
166
  version: '0'
169
167
  requirements: []
170
- rubygems_version: 3.1.4
168
+ rubygems_version: 3.0.3
171
169
  signing_key:
172
170
  specification_version: 4
173
171
  summary: An alternate implementation of the Pathname class
metadata.gz.sig CHANGED
Binary file
data/README DELETED
@@ -1,97 +0,0 @@
1
- == Description
2
- A drop-in replacement for the current Pathname class.
3
-
4
- == Prerequisites
5
- * facade
6
- * ffi (Windows only)
7
- * test-unit (testing only)
8
-
9
- == Installation
10
-
11
- gem install pathname2
12
-
13
- == Synopsis
14
- require 'pathname2'
15
-
16
- # Unix
17
- path1 = Pathname.new("/foo/bar/baz")
18
- path2 = Pathname.new("../zap")
19
-
20
- path1 + path2 # "/foo/bar/zap"
21
- path1 / path2 # "/foo/bar/zap" (same as +)
22
- path1.exists? # Does this path exist?
23
- path1.dirname # "/foo/bar"
24
- path1.to_a # ['foo','bar','baz']
25
-
26
- # Windows
27
- path1 = Pathname.new("C:/foo/bar/baz")
28
- path2 = Pathname.new("../zap")
29
-
30
- path1 + path2 # "C:\\foo\\bar\\zap"
31
- path1.root # "C:\\"
32
- path1.to_a # ['C:','foo','bar','baz']
33
-
34
- == Windows Notes
35
- All forward slashes are converted to backslashes for Pathname objects.
36
-
37
- == Differences between Unix and Windows
38
- If your pathname consists solely of ".", or "..", the return
39
- value for Pathname#clean will be different. On Win32, "\\" is returned,
40
- while on Unix "." is returned. I consider this an extreme edge case and
41
- will not worry myself with it.
42
-
43
- == Differences between Pathname in the standard library and this version
44
- * It is a subclass of String (and thus, mixes in Enumerable).
45
- * It has sensical to_a and root instance methods.
46
- * It works on Windows and Unix. The current implementation does not work
47
- with Windows path names very well, and not at all when it comes to UNC
48
- paths.
49
- * The Pathname#cleanpath method works differently - it always returns
50
- a canonical pathname. In addition, there is no special consideration
51
- for symlinks (yet), though I'm not sure it warrants it.
52
- * The Pathname#+ method auto cleans.
53
- * It uses a facade for all File and Dir methods, as well as most FileUtils
54
- methods.
55
- * Pathname#clean works slightly differently. In the stdlib version,
56
- Pathname#clean("../a") returns "../a". In this version, it returns "a".
57
- This affects other methods, such as Pathname#relative_path_from.
58
- * Accepts file urls and converts them to paths automatically, e.g.
59
- file:///foo%20bar/baz becomes '/foo/bar/baz'.
60
- * Adds a Kernel level +pn+ method as a shortcut.
61
- * Allows you to add paths together with the '/' operator.
62
-
63
- == Method Priority
64
- Because there is some overlap in method names between File, Dir, and
65
- FileUtils, the priority is as follows:
66
-
67
- * File
68
- * Dir
69
- * FileUtils
70
-
71
- In other words, whichever of these defines a given method first is the
72
- method that is used by the pathname2 library.
73
-
74
- == Known Issues
75
- On MS Windows, some methods may not work on pathnames greater than 260
76
- characters because of internal function limitations.
77
-
78
- Any issues you find should be reported on the project page at
79
- https://github.com/djberg96/pathname2
80
-
81
- == Future Plans
82
- Suggestions welcome.
83
-
84
- == License
85
- Apache-2.0
86
-
87
- == Copyright
88
- (C) 2003-2020 Daniel J. Berger
89
- All rights reserved.
90
-
91
- == Warranty
92
- This library is provided "as is" and without any express or
93
- implied warranties, including, without limitation, the implied
94
- warranties of merchantability and fitness for a particular purpose.
95
-
96
- == Author
97
- Daniel J. Berger