pathname2 1.8.4 → 2.0.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGES.md +7 -0
- data/Gemfile +2 -3
- data/MANIFEST.md +2 -2
- data/README.md +6 -0
- data/Rakefile +227 -222
- data/benchmarks/bench_pathname2.rb +127 -0
- data/examples/{example_pathname.rb → example_pathname2.rb} +7 -7
- data/lib/pathname2.rb +160 -169
- data/pathname2.gemspec +13 -9
- data/test/{test_pathname.rb → test_pathname2.rb} +67 -63
- data/test/test_version.rb +3 -3
- data/test/windows/test_append.rb +7 -7
- data/test/windows/test_aref.rb +3 -3
- data/test/windows/test_ascend.rb +5 -5
- data/test/windows/test_children.rb +7 -7
- data/test/windows/test_clean.rb +17 -17
- data/test/windows/test_clean_bang.rb +17 -17
- data/test/windows/test_constructor.rb +12 -12
- data/test/windows/test_descend.rb +5 -5
- data/test/windows/test_drive_number.rb +13 -13
- data/test/windows/test_each.rb +3 -3
- data/test/windows/test_facade.rb +6 -6
- data/test/windows/test_is_absolute.rb +8 -8
- data/test/windows/test_is_relative.rb +7 -7
- data/test/windows/test_is_root.rb +8 -8
- data/test/windows/test_is_unc.rb +18 -18
- data/test/windows/test_join.rb +8 -8
- data/test/windows/test_long_path.rb +6 -6
- data/test/windows/test_misc.rb +7 -7
- data/test/windows/test_parent.rb +9 -9
- data/test/windows/test_pstrip.rb +9 -9
- data/test/windows/test_pstrip_bang.rb +10 -10
- data/test/windows/test_realpath.rb +5 -5
- data/test/windows/test_relative_path_from.rb +4 -4
- data/test/windows/test_root.rb +14 -14
- data/test/windows/test_short_path.rb +6 -6
- data/test/windows/test_to_a.rb +12 -12
- data/test/windows/test_undecorate.rb +12 -12
- data/test/windows/test_undecorate_bang.rb +13 -13
- data.tar.gz.sig +0 -0
- metadata +61 -54
- metadata.gz.sig +0 -0
- data/benchmarks/bench_pathname.rb +0 -127
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60bcd738b7fad0467fcfb58b1b388ed6ac4887d70658774c1560b39465eaa143
|
|
4
|
+
data.tar.gz: 3c9f9c5e5642e4a0ea514a8f6d416a987b74e7ef69443b502a4b706298fe5420
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4a1ef3a4b5932b7482fecc28809f8281059d5081c93004da2bc93d1f34666bd6db2b8d4a6a7a237ba878c40143622ddb7388b6fb2e915639a5ff697720d408b6
|
|
7
|
+
data.tar.gz: 6c3472bb068e00671398a1f6be05fa528f30c18de5dd770f7b7d72e3352e1c2e57666abef1d347d7d148d3a2b35112b4e19e18be781037c762e57db786a9d228
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGES.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## 2.0.0 - 29-Nov-2025
|
|
2
|
+
* Pathname has been renamed Pathname2, so it's no longer competing for the
|
|
3
|
+
same constant name as the stdlib vedrsion. Recent versions of Ruby simply
|
|
4
|
+
weren't allowing it, and this is probably the better way to go anyway.
|
|
5
|
+
* Added addressable as a dependency since the stdlib uri library is a constant
|
|
6
|
+
source of warnings.
|
|
7
|
+
|
|
1
8
|
## 1.8.4 - 19-Jan-2021
|
|
2
9
|
* Cleaned up the Rubocop warnings.
|
|
3
10
|
* Added a Gemfile.
|
data/Gemfile
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
end
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
gemspec
|
data/MANIFEST.md
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* benchmarks/bench_all.rb
|
|
9
9
|
* benchmarks/bench_plus.rb
|
|
10
10
|
* certs/djberg96_pub.pem
|
|
11
|
-
* examples/
|
|
11
|
+
* examples/example_pathname2.rb
|
|
12
12
|
* lib/pathname2.rb
|
|
13
|
-
* test/
|
|
13
|
+
* test/test_pathname2.rb
|
|
14
14
|
* test/test_version.rb
|
|
15
15
|
* test/windows/test_append.rb
|
|
16
16
|
* test/windows/test_aref.rb
|
data/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[](https://github.com/djberg96/pathname2/actions/workflows/ruby.yml)
|
|
2
|
+
|
|
1
3
|
## Description
|
|
2
4
|
A drop-in replacement for the current Pathname class.
|
|
3
5
|
|
|
@@ -9,6 +11,10 @@ A drop-in replacement for the current Pathname class.
|
|
|
9
11
|
## Installation
|
|
10
12
|
`gem install pathname2`
|
|
11
13
|
|
|
14
|
+
## Adding the Trusted Cert
|
|
15
|
+
|
|
16
|
+
`gem cert --add <(curl -Ls https://raw.githubusercontent.com/djberg96/pathname2/main/certs/djberg96_pub.pem)`
|
|
17
|
+
|
|
12
18
|
## Synopsis
|
|
13
19
|
```ruby
|
|
14
20
|
require 'pathname2'
|
data/Rakefile
CHANGED
|
@@ -1,222 +1,227 @@
|
|
|
1
|
-
require 'rake'
|
|
2
|
-
require 'rake/clean'
|
|
3
|
-
require 'rake/testtask'
|
|
4
|
-
|
|
5
|
-
CLEAN.include("**/*.gem", "**/*.rbc", "**/*.lock")
|
|
6
|
-
|
|
7
|
-
namespace :gem do
|
|
8
|
-
desc "Build the pathname2 gem"
|
|
9
|
-
task :create => [:clean] do
|
|
10
|
-
require 'rubygems/package'
|
|
11
|
-
spec =
|
|
12
|
-
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
|
13
|
-
Gem::Package.build(spec
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
desc "Install the pathname2 gem"
|
|
17
|
-
task :install => [:create] do
|
|
18
|
-
file = Dir["*.gem"].first
|
|
19
|
-
sh "gem install -l #{file}"
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
desc 'Run the test suite for the pure Ruby version'
|
|
24
|
-
Rake::TestTask.new('test') do |t|
|
|
25
|
-
t.warning = true
|
|
26
|
-
t.verbose = true
|
|
27
|
-
|
|
28
|
-
if File::ALT_SEPARATOR
|
|
29
|
-
t.test_files = FileList["test/windows/*.rb"] + FileList["test/test_version.rb"]
|
|
30
|
-
else
|
|
31
|
-
t.test_files = FileList['test/
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
namespace :test do
|
|
36
|
-
dir = File::ALT_SEPARATOR ? "windows" : "unix"
|
|
37
|
-
Rake::TestTask.new(:all) do |t|
|
|
38
|
-
t.warning = true
|
|
39
|
-
t.verbose = true
|
|
40
|
-
t.test_files = FileList["test/#{dir}/*.rb"] + FileList["test/test_version.rb"]
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
Rake::TestTask.new(:append) do |t|
|
|
44
|
-
t.warning = true
|
|
45
|
-
t.verbose = true
|
|
46
|
-
t.test_files = FileList["test/#{dir}/test_append.rb"]
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
Rake::TestTask.new(:aref) do |t|
|
|
50
|
-
t.warning = true
|
|
51
|
-
t.verbose = true
|
|
52
|
-
t.test_files = FileList["test/#{dir}/test_aref.rb"]
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
Rake::TestTask.new(:ascend) do |t|
|
|
56
|
-
t.warning = true
|
|
57
|
-
t.verbose = true
|
|
58
|
-
t.test_files = FileList["test/#{dir}/test_ascend.rb"]
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
Rake::TestTask.new(:children) do |t|
|
|
62
|
-
t.warning = true
|
|
63
|
-
t.verbose = true
|
|
64
|
-
t.test_files = FileList["test/#{dir}/test_children.rb"]
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
Rake::TestTask.new(:clean) do |t|
|
|
68
|
-
t.warning = true
|
|
69
|
-
t.verbose = true
|
|
70
|
-
t.test_files = FileList["test/#{dir}/test_clean.rb"]
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
Rake::TestTask.new(:clean!) do |t|
|
|
74
|
-
t.warning = true
|
|
75
|
-
t.verbose = true
|
|
76
|
-
t.test_files = FileList["test/#{dir}/test_clean_bang.rb"]
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
Rake::TestTask.new(:constructor) do |t|
|
|
80
|
-
t.warning = true
|
|
81
|
-
t.verbose = true
|
|
82
|
-
t.test_files = FileList["test/#{dir}/test_constructor.rb"]
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
Rake::TestTask.new(:descend) do |t|
|
|
86
|
-
t.warning = true
|
|
87
|
-
t.verbose = true
|
|
88
|
-
t.test_files = FileList["test/#{dir}/test_descend.rb"]
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
Rake::TestTask.new(:drive_number) do |t|
|
|
92
|
-
t.warning = true
|
|
93
|
-
t.verbose = true
|
|
94
|
-
t.test_files = FileList["test/#{dir}/test_drive_number.rb"]
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
Rake::TestTask.new(:each) do |t|
|
|
98
|
-
t.warning = true
|
|
99
|
-
t.verbose = true
|
|
100
|
-
t.test_files = FileList["test/#{dir}/test_each.rb"]
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
Rake::TestTask.new(:facade) do |t|
|
|
104
|
-
t.warning = true
|
|
105
|
-
t.verbose = true
|
|
106
|
-
t.test_files = FileList["test/#{dir}/test_facade.rb"]
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
Rake::TestTask.new(:is_absolute) do |t|
|
|
110
|
-
t.warning = true
|
|
111
|
-
t.verbose = true
|
|
112
|
-
t.test_files = FileList["test/#{dir}/test_is_absolute.rb"]
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
Rake::TestTask.new(:is_relative) do |t|
|
|
116
|
-
t.warning = true
|
|
117
|
-
t.verbose = true
|
|
118
|
-
t.test_files = FileList["test/#{dir}/test_is_relative.rb"]
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
Rake::TestTask.new(:is_root) do |t|
|
|
122
|
-
t.warning = true
|
|
123
|
-
t.verbose = true
|
|
124
|
-
t.test_files = FileList["test/#{dir}/test_is_root.rb"]
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
Rake::TestTask.new(:is_unc) do |t|
|
|
128
|
-
t.warning = true
|
|
129
|
-
t.verbose = true
|
|
130
|
-
t.test_files = FileList["test/#{dir}/test_is_unc.rb"]
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
Rake::TestTask.new(:join) do |t|
|
|
134
|
-
t.warning = true
|
|
135
|
-
t.verbose = true
|
|
136
|
-
t.test_files = FileList["test/#{dir}/test_join.rb"]
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
Rake::TestTask.new(:long_path) do |t|
|
|
140
|
-
t.warning = true
|
|
141
|
-
t.verbose = true
|
|
142
|
-
t.test_files = FileList["test/#{dir}/test_long_path.rb"]
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
Rake::TestTask.new(:misc) do |t|
|
|
146
|
-
t.warning = true
|
|
147
|
-
t.verbose = true
|
|
148
|
-
t.test_files = FileList["test/#{dir}/test_misc.rb"]
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
Rake::TestTask.new(:parent) do |t|
|
|
152
|
-
t.warning = true
|
|
153
|
-
t.verbose = true
|
|
154
|
-
t.test_files = FileList["test/#{dir}/test_parent.rb"]
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
Rake::TestTask.new(:pstrip) do |t|
|
|
158
|
-
t.warning = true
|
|
159
|
-
t.verbose = true
|
|
160
|
-
t.test_files = FileList["test/#{dir}/test_pstrip.rb"]
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
Rake::TestTask.new(:pstrip!) do |t|
|
|
164
|
-
t.warning = true
|
|
165
|
-
t.verbose = true
|
|
166
|
-
t.test_files = FileList["test/#{dir}/test_pstrip_bang.rb"]
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
Rake::TestTask.new(:realpath) do |t|
|
|
170
|
-
t.warning = true
|
|
171
|
-
t.verbose = true
|
|
172
|
-
t.test_files = FileList["test/#{dir}/test_realpath.rb"]
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
Rake::TestTask.new(:relative_path_from) do |t|
|
|
176
|
-
t.warning = true
|
|
177
|
-
t.verbose = true
|
|
178
|
-
t.test_files = FileList["test/#{dir}/test_relative_path_from.rb"]
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
Rake::TestTask.new(:root) do |t|
|
|
182
|
-
t.warning = true
|
|
183
|
-
t.verbose = true
|
|
184
|
-
t.test_files = FileList["test/#{dir}/test_root.rb"]
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
Rake::TestTask.new(:short_path) do |t|
|
|
188
|
-
t.warning = true
|
|
189
|
-
t.verbose = true
|
|
190
|
-
t.test_files = FileList["test/#{dir}/test_short_path.rb"]
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
Rake::TestTask.new(:to_a) do |t|
|
|
194
|
-
t.warning = true
|
|
195
|
-
t.verbose = true
|
|
196
|
-
t.test_files = FileList["test/#{dir}/test_to_a.rb"]
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
Rake::TestTask.new(:undecorate) do |t|
|
|
200
|
-
t.warning = true
|
|
201
|
-
t.verbose = true
|
|
202
|
-
t.test_files = FileList["test/#{dir}/test_undecorate.rb"]
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
Rake::TestTask.new(:undecorate!) do |t|
|
|
206
|
-
t.warning = true
|
|
207
|
-
t.verbose = true
|
|
208
|
-
t.test_files = FileList["test/#{dir}/test_undecorate_bang.rb"]
|
|
209
|
-
end
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
desc 'Run the
|
|
213
|
-
task :benchmark do
|
|
214
|
-
sh 'ruby -Ilib benchmarks/
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
desc 'Run the benchmark suite for
|
|
218
|
-
task :benchmark_plus do
|
|
219
|
-
sh 'ruby -Ilib benchmarks/bench_plus.rb'
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
|
|
1
|
+
require 'rake'
|
|
2
|
+
require 'rake/clean'
|
|
3
|
+
require 'rake/testtask'
|
|
4
|
+
|
|
5
|
+
CLEAN.include("**/*.gem", "**/*.rbc", "**/*.lock")
|
|
6
|
+
|
|
7
|
+
namespace :gem do
|
|
8
|
+
desc "Build the pathname2 gem"
|
|
9
|
+
task :create => [:clean] do
|
|
10
|
+
require 'rubygems/package'
|
|
11
|
+
spec = Gem::Specification.load('pathname2.gemspec')
|
|
12
|
+
spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
|
|
13
|
+
Gem::Package.build(spec)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
desc "Install the pathname2 gem"
|
|
17
|
+
task :install => [:create] do
|
|
18
|
+
file = Dir["*.gem"].first
|
|
19
|
+
sh "gem install -l #{file}"
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
desc 'Run the test suite for the pure Ruby version'
|
|
24
|
+
Rake::TestTask.new('test') do |t|
|
|
25
|
+
t.warning = true
|
|
26
|
+
t.verbose = true
|
|
27
|
+
|
|
28
|
+
if File::ALT_SEPARATOR
|
|
29
|
+
t.test_files = FileList["test/windows/*.rb"] + FileList["test/test_version.rb"]
|
|
30
|
+
else
|
|
31
|
+
t.test_files = FileList['test/test_pathname2.rb']
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
namespace :test do
|
|
36
|
+
dir = File::ALT_SEPARATOR ? "windows" : "unix"
|
|
37
|
+
Rake::TestTask.new(:all) do |t|
|
|
38
|
+
t.warning = true
|
|
39
|
+
t.verbose = true
|
|
40
|
+
t.test_files = FileList["test/#{dir}/*.rb"] + FileList["test/test_version.rb"]
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Rake::TestTask.new(:append) do |t|
|
|
44
|
+
t.warning = true
|
|
45
|
+
t.verbose = true
|
|
46
|
+
t.test_files = FileList["test/#{dir}/test_append.rb"]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
Rake::TestTask.new(:aref) do |t|
|
|
50
|
+
t.warning = true
|
|
51
|
+
t.verbose = true
|
|
52
|
+
t.test_files = FileList["test/#{dir}/test_aref.rb"]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
Rake::TestTask.new(:ascend) do |t|
|
|
56
|
+
t.warning = true
|
|
57
|
+
t.verbose = true
|
|
58
|
+
t.test_files = FileList["test/#{dir}/test_ascend.rb"]
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
Rake::TestTask.new(:children) do |t|
|
|
62
|
+
t.warning = true
|
|
63
|
+
t.verbose = true
|
|
64
|
+
t.test_files = FileList["test/#{dir}/test_children.rb"]
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
Rake::TestTask.new(:clean) do |t|
|
|
68
|
+
t.warning = true
|
|
69
|
+
t.verbose = true
|
|
70
|
+
t.test_files = FileList["test/#{dir}/test_clean.rb"]
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
Rake::TestTask.new(:clean!) do |t|
|
|
74
|
+
t.warning = true
|
|
75
|
+
t.verbose = true
|
|
76
|
+
t.test_files = FileList["test/#{dir}/test_clean_bang.rb"]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
Rake::TestTask.new(:constructor) do |t|
|
|
80
|
+
t.warning = true
|
|
81
|
+
t.verbose = true
|
|
82
|
+
t.test_files = FileList["test/#{dir}/test_constructor.rb"]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
Rake::TestTask.new(:descend) do |t|
|
|
86
|
+
t.warning = true
|
|
87
|
+
t.verbose = true
|
|
88
|
+
t.test_files = FileList["test/#{dir}/test_descend.rb"]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
Rake::TestTask.new(:drive_number) do |t|
|
|
92
|
+
t.warning = true
|
|
93
|
+
t.verbose = true
|
|
94
|
+
t.test_files = FileList["test/#{dir}/test_drive_number.rb"]
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
Rake::TestTask.new(:each) do |t|
|
|
98
|
+
t.warning = true
|
|
99
|
+
t.verbose = true
|
|
100
|
+
t.test_files = FileList["test/#{dir}/test_each.rb"]
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
Rake::TestTask.new(:facade) do |t|
|
|
104
|
+
t.warning = true
|
|
105
|
+
t.verbose = true
|
|
106
|
+
t.test_files = FileList["test/#{dir}/test_facade.rb"]
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
Rake::TestTask.new(:is_absolute) do |t|
|
|
110
|
+
t.warning = true
|
|
111
|
+
t.verbose = true
|
|
112
|
+
t.test_files = FileList["test/#{dir}/test_is_absolute.rb"]
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
Rake::TestTask.new(:is_relative) do |t|
|
|
116
|
+
t.warning = true
|
|
117
|
+
t.verbose = true
|
|
118
|
+
t.test_files = FileList["test/#{dir}/test_is_relative.rb"]
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
Rake::TestTask.new(:is_root) do |t|
|
|
122
|
+
t.warning = true
|
|
123
|
+
t.verbose = true
|
|
124
|
+
t.test_files = FileList["test/#{dir}/test_is_root.rb"]
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
Rake::TestTask.new(:is_unc) do |t|
|
|
128
|
+
t.warning = true
|
|
129
|
+
t.verbose = true
|
|
130
|
+
t.test_files = FileList["test/#{dir}/test_is_unc.rb"]
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
Rake::TestTask.new(:join) do |t|
|
|
134
|
+
t.warning = true
|
|
135
|
+
t.verbose = true
|
|
136
|
+
t.test_files = FileList["test/#{dir}/test_join.rb"]
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
Rake::TestTask.new(:long_path) do |t|
|
|
140
|
+
t.warning = true
|
|
141
|
+
t.verbose = true
|
|
142
|
+
t.test_files = FileList["test/#{dir}/test_long_path.rb"]
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
Rake::TestTask.new(:misc) do |t|
|
|
146
|
+
t.warning = true
|
|
147
|
+
t.verbose = true
|
|
148
|
+
t.test_files = FileList["test/#{dir}/test_misc.rb"]
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
Rake::TestTask.new(:parent) do |t|
|
|
152
|
+
t.warning = true
|
|
153
|
+
t.verbose = true
|
|
154
|
+
t.test_files = FileList["test/#{dir}/test_parent.rb"]
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
Rake::TestTask.new(:pstrip) do |t|
|
|
158
|
+
t.warning = true
|
|
159
|
+
t.verbose = true
|
|
160
|
+
t.test_files = FileList["test/#{dir}/test_pstrip.rb"]
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
Rake::TestTask.new(:pstrip!) do |t|
|
|
164
|
+
t.warning = true
|
|
165
|
+
t.verbose = true
|
|
166
|
+
t.test_files = FileList["test/#{dir}/test_pstrip_bang.rb"]
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
Rake::TestTask.new(:realpath) do |t|
|
|
170
|
+
t.warning = true
|
|
171
|
+
t.verbose = true
|
|
172
|
+
t.test_files = FileList["test/#{dir}/test_realpath.rb"]
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
Rake::TestTask.new(:relative_path_from) do |t|
|
|
176
|
+
t.warning = true
|
|
177
|
+
t.verbose = true
|
|
178
|
+
t.test_files = FileList["test/#{dir}/test_relative_path_from.rb"]
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
Rake::TestTask.new(:root) do |t|
|
|
182
|
+
t.warning = true
|
|
183
|
+
t.verbose = true
|
|
184
|
+
t.test_files = FileList["test/#{dir}/test_root.rb"]
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
Rake::TestTask.new(:short_path) do |t|
|
|
188
|
+
t.warning = true
|
|
189
|
+
t.verbose = true
|
|
190
|
+
t.test_files = FileList["test/#{dir}/test_short_path.rb"]
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
Rake::TestTask.new(:to_a) do |t|
|
|
194
|
+
t.warning = true
|
|
195
|
+
t.verbose = true
|
|
196
|
+
t.test_files = FileList["test/#{dir}/test_to_a.rb"]
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
Rake::TestTask.new(:undecorate) do |t|
|
|
200
|
+
t.warning = true
|
|
201
|
+
t.verbose = true
|
|
202
|
+
t.test_files = FileList["test/#{dir}/test_undecorate.rb"]
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
Rake::TestTask.new(:undecorate!) do |t|
|
|
206
|
+
t.warning = true
|
|
207
|
+
t.verbose = true
|
|
208
|
+
t.test_files = FileList["test/#{dir}/test_undecorate_bang.rb"]
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
desc 'Run the Pathname2 benchmark suite'
|
|
213
|
+
task :benchmark do
|
|
214
|
+
sh 'ruby -Ilib benchmarks/bench_pathname2.rb'
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
desc 'Run the benchmark suite for Pathname2#+ vs File.join'
|
|
218
|
+
task :benchmark_plus do
|
|
219
|
+
sh 'ruby -Ilib benchmarks/bench_plus.rb'
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Clean up afterwards
|
|
223
|
+
Rake::Task[:test].enhance do
|
|
224
|
+
Rake::Task[:clean].invoke
|
|
225
|
+
end
|
|
226
|
+
|
|
227
|
+
task :default => :test
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
#####################################################################
|
|
2
|
+
# bench_pathname.rb
|
|
3
|
+
#
|
|
4
|
+
# Benchmark suite for all methods of the Pathname2 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 RbConfig::CONFIG['host_os'] =~ /mingw|mswin/i
|
|
16
|
+
path1 = Pathname2.new("C:\\Program Files\\Windows NT")
|
|
17
|
+
path2 = Pathname2.new("Accessories")
|
|
18
|
+
path3 = Pathname2.new("C:\\Program Files\\..\\.\\Windows NT")
|
|
19
|
+
else
|
|
20
|
+
path1 = Pathname2.new("/usr/local")
|
|
21
|
+
path2 = Pathname2.new("bin")
|
|
22
|
+
path3 = Pathname2.new("/usr/../local/./bin")
|
|
23
|
+
path4 = Pathname2.new("/dev/stdin")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
MAX = 10000
|
|
27
|
+
|
|
28
|
+
Benchmark.bm(25) do |bench|
|
|
29
|
+
bench.report("Pathname2.new(path)"){
|
|
30
|
+
MAX.times{ Pathname2.new("/usr/local/bin") }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
bench.report("Pathname2#+(Pathname2)"){
|
|
34
|
+
MAX.times{ path1 + path2 }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
bench.report("Pathname2#+(String)"){
|
|
38
|
+
MAX.times{ path1 + path2 }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
bench.report("Pathname2#children"){
|
|
42
|
+
MAX.times{ path1.children }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
bench.report("Pathname2#pstrip"){
|
|
46
|
+
MAX.times{ path1.pstrip }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
bench.report("Pathname2#pstrip!"){
|
|
50
|
+
MAX.times{ path1.pstrip! }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
bench.report("Pathname2#to_a"){
|
|
54
|
+
MAX.times{ path1.to_a }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
bench.report("Pathname2#descend"){
|
|
58
|
+
MAX.times{ path1.descend{} }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
bench.report("Pathname2#ascend"){
|
|
62
|
+
MAX.times{ path1.ascend{} }
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
bench.report("Pathname2#root"){
|
|
66
|
+
MAX.times{ path1.root }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
bench.report("Pathname2#root?"){
|
|
70
|
+
MAX.times{ path1.root? }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
bench.report("Pathname2#<=>"){
|
|
74
|
+
MAX.times{ path1 <=> path2 }
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
bench.report("Pathname2#absolute?"){
|
|
78
|
+
MAX.times{ path1.absolute? }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
bench.report("Pathname2#relative?"){
|
|
82
|
+
MAX.times{ path1.relative? }
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
bench.report("Pathname2#clean"){
|
|
86
|
+
MAX.times{ path3.clean }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
bench.report("Pathname2#clean!"){
|
|
90
|
+
MAX.times{ path3.clean! }
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# Platform specific tests
|
|
94
|
+
if RbConfig::CONFIG['host_os'] =~ /mingw|mswin/i
|
|
95
|
+
bench.report("Pathname2.new(file_url)"){
|
|
96
|
+
MAX.times{ Pathname2.new("file:///C:/usr/local/bin") }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
bench.report("Pathname2#drive_number"){
|
|
100
|
+
MAX.times{ path1.drive_number }
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
bench.report("Pathname2#unc?"){
|
|
104
|
+
MAX.times{ path1.unc? }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
bench.report("Pathname2#undecorate"){
|
|
108
|
+
MAX.times{ path1.undecorate }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
bench.report("Pathname2#undecorate!"){
|
|
112
|
+
MAX.times{ path1.undecorate! }
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
bench.report("Pathname2#short_path"){
|
|
116
|
+
MAX.times{ path1.short_path }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
bench.report("Pathname2#long_path"){
|
|
120
|
+
MAX.times{ path1.long_path }
|
|
121
|
+
}
|
|
122
|
+
else
|
|
123
|
+
bench.report("Pathname2#realpath"){
|
|
124
|
+
MAX.times{ path4.realpath }
|
|
125
|
+
}
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
########################################################################
|
|
2
|
-
#
|
|
2
|
+
# example_pathname2.rb
|
|
3
3
|
#
|
|
4
4
|
# Some examples to demonstrate the behavior of the pathname2 library.
|
|
5
5
|
########################################################################
|
|
6
6
|
require 'pathname2'
|
|
7
7
|
|
|
8
|
-
puts "VERSION: " +
|
|
8
|
+
puts "VERSION: " + Pathname2::VERSION
|
|
9
9
|
|
|
10
|
-
path1 =
|
|
11
|
-
path2 =
|
|
10
|
+
path1 = Pathname2.new("foo/bar")
|
|
11
|
+
path2 = Pathname2.new("baz/blah")
|
|
12
12
|
|
|
13
|
-
path3 =
|
|
14
|
-
path4 =
|
|
13
|
+
path3 = Pathname2.new("foo/../bar")
|
|
14
|
+
path4 = Pathname2.new("../baz")
|
|
15
15
|
|
|
16
16
|
p path1 + path2 # foo/bar/baz/blah
|
|
17
17
|
p path3 + path4 # baz
|
|
@@ -22,4 +22,4 @@ path = pn{ "C:\\Documents and Settings\\snoopy\\My Documents" }
|
|
|
22
22
|
p path[0] # C:
|
|
23
23
|
p path[1] # Documents and Settings
|
|
24
24
|
p path[0,2] # C:\\Documents and Settings
|
|
25
|
-
p path[0..2] # C:\\Documents and Settings\\snoopy
|
|
25
|
+
p path[0..2] # C:\\Documents and Settings\\snoopy
|