libpath-ruby 0.2.2 → 0.2.2.1
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
- data/LICENSE +33 -0
- data/README.md +25 -8
- data/examples/path_from_arg0.md +43 -43
- data/examples/path_from_arg0.rb +25 -23
- data/lib/libpath/constants/unix.rb +71 -71
- data/lib/libpath/constants/windows.rb +72 -72
- data/lib/libpath/constants.rb +18 -19
- data/lib/libpath/diagnostics/parameter_checking.rb +25 -25
- data/lib/libpath/diagnostics.rb +1 -1
- data/lib/libpath/exceptions/libpath_base_exception.rb +13 -13
- data/lib/libpath/exceptions/malformed_name_exception.rb +23 -22
- data/lib/libpath/exceptions.rb +1 -1
- data/lib/libpath/form/unix.rb +104 -103
- data/lib/libpath/form/windows.rb +200 -199
- data/lib/libpath/form.rb +18 -18
- data/lib/libpath/internal_/array.rb +53 -53
- data/lib/libpath/internal_/platform.rb +24 -24
- data/lib/libpath/internal_/string.rb +18 -18
- data/lib/libpath/internal_/unix/form.rb +116 -116
- data/lib/libpath/internal_/windows/drive.rb +59 -59
- data/lib/libpath/internal_/windows/form.rb +189 -189
- data/lib/libpath/libpath.rb +3 -0
- data/lib/libpath/path/unix.rb +114 -112
- data/lib/libpath/path/windows.rb +120 -118
- data/lib/libpath/path.rb +18 -20
- data/lib/libpath/util/unix.rb +258 -258
- data/lib/libpath/util/windows.rb +400 -400
- data/lib/libpath/util.rb +18 -19
- data/lib/libpath/version.rb +23 -24
- data/lib/libpath.rb +1 -1
- data/test/performance/benchmark_drive_letter.rb +50 -10
- data/test/performance/benchmark_gsub_string_or_regex.rb +27 -23
- data/test/performance/benchmark_rindex2.rb +56 -48
- data/test/performance/benchmark_split.rb +16 -10
- data/test/unit/compare/ts_all.rb +4 -4
- data/test/unit/equate/ts_all.rb +4 -4
- data/test/unit/equate/unix/ts_all.rb +4 -4
- data/test/unit/equate/windows/ts_all.rb +4 -4
- data/test/unit/exceptions/tc_libpath_base_exception.rb +10 -8
- data/test/unit/exceptions/tc_malformed_name_exception.rb +14 -12
- data/test/unit/exceptions/ts_all.rb +4 -4
- data/test/unit/form/tc_absolute_functions.rb +242 -240
- data/test/unit/form/ts_all.rb +4 -4
- data/test/unit/form/unix/tc_absolute_functions.rb +158 -155
- data/test/unit/form/unix/ts_all.rb +4 -4
- data/test/unit/form/windows/tc_absolute_functions.rb +628 -625
- data/test/unit/form/windows/ts_all.rb +4 -4
- data/test/unit/internal_/tc_array.rb +36 -32
- data/test/unit/internal_/ts_all.rb +4 -4
- data/test/unit/internal_/unix/form/tc_slash_functions.rb +38 -35
- data/test/unit/internal_/unix/form/ts_all.rb +4 -4
- data/test/unit/internal_/unix/tc_split_path.rb +387 -384
- data/test/unit/internal_/unix/ts_all.rb +4 -4
- data/test/unit/internal_/windows/form/tc_get_windows_volume.rb +157 -153
- data/test/unit/internal_/windows/form/tc_slash_functions.rb +39 -35
- data/test/unit/internal_/windows/form/ts_all.rb +4 -4
- data/test/unit/internal_/windows/tc_split_path.rb +874 -869
- data/test/unit/internal_/windows/ts_all.rb +4 -4
- data/test/unit/parse/ts_all.rb +4 -4
- data/test/unit/path/tc_path.rb +732 -732
- data/test/unit/path/ts_all.rb +4 -4
- data/test/unit/path/unix/tc_path.rb +544 -540
- data/test/unit/path/unix/ts_all.rb +4 -4
- data/test/unit/path/windows/tc_path.rb +608 -603
- data/test/unit/path/windows/ts_all.rb +4 -4
- data/test/unit/tc_version.rb +25 -22
- data/test/unit/ts_all.rb +4 -4
- data/test/unit/util/tc_combine_paths.rb +110 -105
- data/test/unit/util/tc_derive_relative_path.rb +8 -3
- data/test/unit/util/tc_make_path_canonical.rb +142 -138
- data/test/unit/util/ts_all.rb +4 -4
- data/test/unit/util/unix/tc_combine_paths.rb +38 -34
- data/test/unit/util/unix/tc_derive_relative_path.rb +80 -75
- data/test/unit/util/unix/tc_make_path_absolute.rb +74 -70
- data/test/unit/util/unix/tc_make_path_canonical.rb +95 -90
- data/test/unit/util/unix/ts_all.rb +4 -4
- data/test/unit/util/windows/tc_combine_paths.rb +82 -77
- data/test/unit/util/windows/tc_derive_relative_path.rb +98 -93
- data/test/unit/util/windows/tc_make_path_absolute.rb +105 -101
- data/test/unit/util/windows/tc_make_path_canonical.rb +158 -153
- data/test/unit/util/windows/ts_all.rb +4 -4
- metadata +9 -8
@@ -7,16 +7,16 @@ this_dir = File.expand_path(File.dirname(__FILE__))
|
|
7
7
|
# all tc_*rb in current directory
|
8
8
|
Dir[File.join(this_dir, 'tc_*rb')].each do |file|
|
9
9
|
|
10
|
-
|
10
|
+
$stderr.puts "requiring file '#{file}'" if $DEBUG
|
11
11
|
|
12
|
-
|
12
|
+
require file
|
13
13
|
end
|
14
14
|
|
15
15
|
# all ts_*rb in immediate sub-directories
|
16
16
|
Dir[File.join(this_dir, '*', 'ts_*rb')].each do |file|
|
17
17
|
|
18
|
-
|
18
|
+
$stderr.puts "requiring file '#{file}'" if $DEBUG
|
19
19
|
|
20
|
-
|
20
|
+
require file
|
21
21
|
end
|
22
22
|
|
@@ -2,61 +2,65 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), *(['..'] * 3), 'lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'libpath/internal_/array'
|
6
7
|
|
7
8
|
require 'test/unit'
|
8
9
|
|
10
|
+
|
9
11
|
class Test_Internal_Array_index < Test::Unit::TestCase
|
10
12
|
|
11
|
-
|
13
|
+
A = ::LibPath::Internal_::Array
|
12
14
|
|
13
|
-
|
15
|
+
def test_empty_array
|
14
16
|
|
15
|
-
|
16
|
-
|
17
|
-
|
17
|
+
assert_nil A.index([], 1)
|
18
|
+
assert_nil A.index([], 1, 1)
|
19
|
+
end
|
18
20
|
|
19
|
-
|
21
|
+
def test_simple_find
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
+
assert_equal 0, A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 0)
|
24
|
+
assert_equal 1, A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 1)
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
assert_equal 0, A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 0, 0)
|
27
|
+
assert_equal 1, A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 1, 0)
|
28
|
+
assert_equal 1, A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 1, 1)
|
29
|
+
end
|
28
30
|
|
29
|
-
|
31
|
+
def test_not_found
|
30
32
|
|
31
|
-
|
32
|
-
|
33
|
-
|
33
|
+
assert_nil A.index([ 0, 2, 4, 6, 8 ], 1)
|
34
|
+
assert_nil A.index([ 0, 2, 4, 6, 8 ], 1, 1)
|
35
|
+
end
|
34
36
|
|
35
|
-
|
37
|
+
def test_not_found_after_index
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
assert_nil A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 1, 2)
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
class Test_Internal_Array_index2 < Test::Unit::TestCase
|
42
44
|
|
43
|
-
|
44
|
-
|
45
|
-
def test_empty_array
|
45
|
+
A = ::LibPath::Internal_::Array
|
46
46
|
|
47
|
-
|
48
|
-
assert_nil A.index2([], 0, 1, 1)
|
49
|
-
end
|
47
|
+
def test_empty_array
|
50
48
|
|
51
|
-
|
49
|
+
assert_nil A.index2([], 0, 1)
|
50
|
+
assert_nil A.index2([], 0, 1, 1)
|
51
|
+
end
|
52
52
|
|
53
|
-
|
54
|
-
assert_equal 1, A.index2([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 2, 1)
|
53
|
+
def test_simple_find
|
55
54
|
|
56
|
-
|
57
|
-
|
58
|
-
assert_equal 1, A.index2([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 8, 1, 1)
|
59
|
-
end
|
55
|
+
assert_equal 0, A.index2([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 0, 1)
|
56
|
+
assert_equal 1, A.index2([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 2, 1)
|
60
57
|
|
58
|
+
assert_equal 0, A.index2([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 1, 0, 0)
|
59
|
+
assert_equal 1, A.index2([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 2, 1, 0)
|
60
|
+
assert_equal 1, A.index2([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 8, 1, 1)
|
61
|
+
end
|
61
62
|
end
|
62
63
|
|
64
|
+
|
65
|
+
# ############################## end of file ############################# #
|
66
|
+
|
@@ -7,16 +7,16 @@ this_dir = File.expand_path(File.dirname(__FILE__))
|
|
7
7
|
# all tc_*rb in current directory
|
8
8
|
Dir[File.join(this_dir, 'tc_*rb')].each do |file|
|
9
9
|
|
10
|
-
|
10
|
+
$stderr.puts "requiring file '#{file}'" if $DEBUG
|
11
11
|
|
12
|
-
|
12
|
+
require file
|
13
13
|
end
|
14
14
|
|
15
15
|
# all ts_*rb in immediate sub-directories
|
16
16
|
Dir[File.join(this_dir, '*', 'ts_*rb')].each do |file|
|
17
17
|
|
18
|
-
|
18
|
+
$stderr.puts "requiring file '#{file}'" if $DEBUG
|
19
19
|
|
20
|
-
|
20
|
+
require file
|
21
21
|
end
|
22
22
|
|
@@ -2,59 +2,62 @@
|
|
2
2
|
|
3
3
|
$:.unshift File.join(File.dirname(__FILE__), *(['..'] * 5), 'lib')
|
4
4
|
|
5
|
+
|
5
6
|
require 'libpath/internal_/unix/form'
|
6
7
|
|
8
|
+
require 'xqsr3/extensions/test/unit'
|
7
9
|
require 'test/unit'
|
8
10
|
|
9
|
-
require 'xqsr3/extensions/test/unit'
|
10
11
|
|
11
12
|
class Test_Internal_Unix_Form_slash_functions < Test::Unit::TestCase
|
12
13
|
|
13
|
-
|
14
|
+
F = ::LibPath::Internal_::Unix::Form
|
14
15
|
|
15
|
-
|
16
|
+
def test_char_is_path_name_separator?
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
assert_false F.char_is_path_name_separator?('')
|
19
|
+
assert_false F.char_is_path_name_separator?('a')
|
20
|
+
assert_false F.char_is_path_name_separator?('\\')
|
20
21
|
|
21
|
-
|
22
|
-
|
22
|
+
assert F.char_is_path_name_separator?('/')
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
+
def test_append_trailing_slash
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
assert_equal '/', F.append_trailing_slash('')
|
28
|
+
assert_equal '/', F.append_trailing_slash('/')
|
29
|
+
assert_equal 'a/', F.append_trailing_slash('a')
|
30
|
+
assert_equal 'a/', F.append_trailing_slash('a/')
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
+
def test_get_trailing_slash
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
assert_nil F.get_trailing_slash('')
|
36
|
+
assert_equal '/', F.get_trailing_slash('/')
|
37
|
+
assert_nil F.get_trailing_slash('a')
|
38
|
+
assert_nil F.get_trailing_slash('\\')
|
39
|
+
assert_equal '/', F.get_trailing_slash('a/')
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
+
def test_has_trailing_slash
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
assert_false F.has_trailing_slash?('')
|
45
|
+
assert_true F.has_trailing_slash?('/')
|
46
|
+
assert_false F.has_trailing_slash?('a')
|
47
|
+
assert_false F.has_trailing_slash?('\\')
|
48
|
+
assert_true F.has_trailing_slash?('a/')
|
49
|
+
end
|
49
50
|
|
50
|
-
|
51
|
+
def test_trim_trailing_slash
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
assert_equal '', F.trim_trailing_slash('')
|
54
|
+
assert_equal '', F.trim_trailing_slash('/')
|
55
|
+
assert_equal 'a', F.trim_trailing_slash('a')
|
56
|
+
assert_equal '\\', F.trim_trailing_slash('\\')
|
57
|
+
assert_equal 'a', F.trim_trailing_slash('a/')
|
58
|
+
end
|
58
59
|
end
|
59
60
|
|
60
61
|
|
62
|
+
# ############################## end of file ############################# #
|
63
|
+
|
@@ -7,16 +7,16 @@ this_dir = File.expand_path(File.dirname(__FILE__))
|
|
7
7
|
# all tc_*rb in current directory
|
8
8
|
Dir[File.join(this_dir, 'tc_*rb')].each do |file|
|
9
9
|
|
10
|
-
|
10
|
+
$stderr.puts "requiring file '#{file}'" if $DEBUG
|
11
11
|
|
12
|
-
|
12
|
+
require file
|
13
13
|
end
|
14
14
|
|
15
15
|
# all ts_*rb in immediate sub-directories
|
16
16
|
Dir[File.join(this_dir, '*', 'ts_*rb')].each do |file|
|
17
17
|
|
18
|
-
|
18
|
+
$stderr.puts "requiring file '#{file}'" if $DEBUG
|
19
19
|
|
20
|
-
|
20
|
+
require file
|
21
21
|
end
|
22
22
|
|