pathname2 1.8.3 → 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 → CHANGES.md} +41 -29
- data/Gemfile +2 -0
- data/{MANIFEST → MANIFEST.md} +6 -5
- data/README.md +104 -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 +169 -171
- data/pathname2.gemspec +15 -13
- 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 +62 -57
- metadata.gz.sig +0 -0
- data/README +0 -97
- data/benchmarks/bench_pathname.rb +0 -127
|
@@ -1,127 +0,0 @@
|
|
|
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 RbConfig::CONFIG['host_os'] =~ /mingw|mswin/i
|
|
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 RbConfig::CONFIG['host_os'] =~ /mingw|mswin/i
|
|
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
|