libpath-ruby 0.2.2 → 0.2.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +33 -0
  3. data/README.md +25 -8
  4. data/examples/path_from_arg0.md +43 -43
  5. data/examples/path_from_arg0.rb +25 -23
  6. data/lib/libpath/constants/unix.rb +74 -74
  7. data/lib/libpath/constants/windows.rb +75 -75
  8. data/lib/libpath/constants.rb +20 -20
  9. data/lib/libpath/diagnostics/parameter_checking.rb +27 -26
  10. data/lib/libpath/diagnostics.rb +1 -1
  11. data/lib/libpath/exceptions/libpath_base_exception.rb +20 -21
  12. data/lib/libpath/exceptions/malformed_name_exception.rb +27 -27
  13. data/lib/libpath/exceptions.rb +1 -1
  14. data/lib/libpath/form/unix.rb +118 -118
  15. data/lib/libpath/form/windows.rb +228 -214
  16. data/lib/libpath/form.rb +20 -21
  17. data/lib/libpath/internal_/array.rb +57 -57
  18. data/lib/libpath/internal_/platform.rb +30 -31
  19. data/lib/libpath/internal_/string.rb +25 -20
  20. data/lib/libpath/internal_/unix/form.rb +124 -119
  21. data/lib/libpath/internal_/windows/drive.rb +80 -75
  22. data/lib/libpath/internal_/windows/form.rb +205 -194
  23. data/lib/libpath/libpath.rb +4 -1
  24. data/lib/libpath/path/unix.rb +120 -118
  25. data/lib/libpath/path/windows.rb +126 -124
  26. data/lib/libpath/path.rb +21 -21
  27. data/lib/libpath/util/unix.rb +261 -261
  28. data/lib/libpath/util/windows.rb +403 -403
  29. data/lib/libpath/util.rb +20 -20
  30. data/lib/libpath/version.rb +25 -26
  31. data/lib/libpath.rb +1 -1
  32. data/test/performance/benchmark_drive_letter.rb +50 -10
  33. data/test/performance/benchmark_gsub_string_or_regex.rb +27 -23
  34. data/test/performance/benchmark_rindex2.rb +56 -48
  35. data/test/performance/benchmark_split.rb +16 -10
  36. data/test/unit/compare/ts_all.rb +4 -4
  37. data/test/unit/equate/ts_all.rb +4 -4
  38. data/test/unit/equate/unix/ts_all.rb +4 -4
  39. data/test/unit/equate/windows/ts_all.rb +4 -4
  40. data/test/unit/exceptions/tc_libpath_base_exception.rb +10 -8
  41. data/test/unit/exceptions/tc_malformed_name_exception.rb +14 -12
  42. data/test/unit/exceptions/ts_all.rb +4 -4
  43. data/test/unit/form/tc_absolute_functions.rb +242 -240
  44. data/test/unit/form/ts_all.rb +4 -4
  45. data/test/unit/form/unix/tc_absolute_functions.rb +158 -155
  46. data/test/unit/form/unix/ts_all.rb +4 -4
  47. data/test/unit/form/windows/tc_absolute_functions.rb +628 -625
  48. data/test/unit/form/windows/ts_all.rb +4 -4
  49. data/test/unit/internal_/tc_array.rb +36 -32
  50. data/test/unit/internal_/ts_all.rb +4 -4
  51. data/test/unit/internal_/unix/form/tc_slash_functions.rb +38 -35
  52. data/test/unit/internal_/unix/form/ts_all.rb +4 -4
  53. data/test/unit/internal_/unix/tc_split_path.rb +387 -384
  54. data/test/unit/internal_/unix/ts_all.rb +4 -4
  55. data/test/unit/internal_/windows/form/tc_get_windows_volume.rb +157 -153
  56. data/test/unit/internal_/windows/form/tc_slash_functions.rb +39 -35
  57. data/test/unit/internal_/windows/form/ts_all.rb +4 -4
  58. data/test/unit/internal_/windows/tc_split_path.rb +874 -869
  59. data/test/unit/internal_/windows/ts_all.rb +4 -4
  60. data/test/unit/parse/ts_all.rb +4 -4
  61. data/test/unit/path/tc_path.rb +732 -732
  62. data/test/unit/path/ts_all.rb +4 -4
  63. data/test/unit/path/unix/tc_path.rb +544 -540
  64. data/test/unit/path/unix/ts_all.rb +4 -4
  65. data/test/unit/path/windows/tc_path.rb +608 -603
  66. data/test/unit/path/windows/ts_all.rb +4 -4
  67. data/test/unit/tc_version.rb +25 -22
  68. data/test/unit/ts_all.rb +4 -4
  69. data/test/unit/util/tc_combine_paths.rb +110 -105
  70. data/test/unit/util/tc_derive_relative_path.rb +8 -3
  71. data/test/unit/util/tc_make_path_canonical.rb +142 -138
  72. data/test/unit/util/ts_all.rb +4 -4
  73. data/test/unit/util/unix/tc_combine_paths.rb +38 -34
  74. data/test/unit/util/unix/tc_derive_relative_path.rb +80 -75
  75. data/test/unit/util/unix/tc_make_path_absolute.rb +74 -70
  76. data/test/unit/util/unix/tc_make_path_canonical.rb +95 -90
  77. data/test/unit/util/unix/ts_all.rb +4 -4
  78. data/test/unit/util/windows/tc_combine_paths.rb +82 -77
  79. data/test/unit/util/windows/tc_derive_relative_path.rb +98 -93
  80. data/test/unit/util/windows/tc_make_path_absolute.rb +105 -101
  81. data/test/unit/util/windows/tc_make_path_canonical.rb +158 -153
  82. data/test/unit/util/windows/ts_all.rb +4 -4
  83. 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
- $stderr.puts "requiring file '#{file}'" if $DEBUG
10
+ $stderr.puts "requiring file '#{file}'" if $DEBUG
11
11
 
12
- require file
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
- $stderr.puts "requiring file '#{file}'" if $DEBUG
18
+ $stderr.puts "requiring file '#{file}'" if $DEBUG
19
19
 
20
- require file
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
- A = ::LibPath::Internal_::Array
13
+ A = ::LibPath::Internal_::Array
12
14
 
13
- def test_empty_array
15
+ def test_empty_array
14
16
 
15
- assert_nil A.index([], 1)
16
- assert_nil A.index([], 1, 1)
17
- end
17
+ assert_nil A.index([], 1)
18
+ assert_nil A.index([], 1, 1)
19
+ end
18
20
 
19
- def test_simple_find
21
+ def test_simple_find
20
22
 
21
- assert_equal 0, A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 0)
22
- assert_equal 1, A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 1)
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
- assert_equal 0, A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 0, 0)
25
- assert_equal 1, A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 1, 0)
26
- assert_equal 1, A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 1, 1)
27
- end
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
- def test_not_found
31
+ def test_not_found
30
32
 
31
- assert_nil A.index([ 0, 2, 4, 6, 8 ], 1)
32
- assert_nil A.index([ 0, 2, 4, 6, 8 ], 1, 1)
33
- end
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
- def test_not_found_after_index
37
+ def test_not_found_after_index
36
38
 
37
- assert_nil A.index([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 1, 2)
38
- end
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
- A = ::LibPath::Internal_::Array
44
-
45
- def test_empty_array
45
+ A = ::LibPath::Internal_::Array
46
46
 
47
- assert_nil A.index2([], 0, 1)
48
- assert_nil A.index2([], 0, 1, 1)
49
- end
47
+ def test_empty_array
50
48
 
51
- def test_simple_find
49
+ assert_nil A.index2([], 0, 1)
50
+ assert_nil A.index2([], 0, 1, 1)
51
+ end
52
52
 
53
- assert_equal 0, A.index2([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 0, 1)
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
- assert_equal 0, A.index2([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 1, 0, 0)
57
- assert_equal 1, A.index2([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ], 2, 1, 0)
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
- $stderr.puts "requiring file '#{file}'" if $DEBUG
10
+ $stderr.puts "requiring file '#{file}'" if $DEBUG
11
11
 
12
- require file
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
- $stderr.puts "requiring file '#{file}'" if $DEBUG
18
+ $stderr.puts "requiring file '#{file}'" if $DEBUG
19
19
 
20
- require file
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
- F = ::LibPath::Internal_::Unix::Form
14
+ F = ::LibPath::Internal_::Unix::Form
14
15
 
15
- def test_char_is_path_name_separator?
16
+ def test_char_is_path_name_separator?
16
17
 
17
- assert_false F.char_is_path_name_separator?('')
18
- assert_false F.char_is_path_name_separator?('a')
19
- assert_false F.char_is_path_name_separator?('\\')
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
- assert F.char_is_path_name_separator?('/')
22
- end
22
+ assert F.char_is_path_name_separator?('/')
23
+ end
23
24
 
24
- def test_append_trailing_slash
25
+ def test_append_trailing_slash
25
26
 
26
- assert_equal '/', F.append_trailing_slash('')
27
- assert_equal '/', F.append_trailing_slash('/')
28
- assert_equal 'a/', F.append_trailing_slash('a')
29
- assert_equal 'a/', F.append_trailing_slash('a/')
30
- end
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
- def test_get_trailing_slash
33
+ def test_get_trailing_slash
33
34
 
34
- assert_nil F.get_trailing_slash('')
35
- assert_equal '/', F.get_trailing_slash('/')
36
- assert_nil F.get_trailing_slash('a')
37
- assert_nil F.get_trailing_slash('\\')
38
- assert_equal '/', F.get_trailing_slash('a/')
39
- end
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
- def test_has_trailing_slash
42
+ def test_has_trailing_slash
42
43
 
43
- assert_false F.has_trailing_slash?('')
44
- assert_true F.has_trailing_slash?('/')
45
- assert_false F.has_trailing_slash?('a')
46
- assert_false F.has_trailing_slash?('\\')
47
- assert_true F.has_trailing_slash?('a/')
48
- end
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
- def test_trim_trailing_slash
51
+ def test_trim_trailing_slash
51
52
 
52
- assert_equal '', F.trim_trailing_slash('')
53
- assert_equal '', F.trim_trailing_slash('/')
54
- assert_equal 'a', F.trim_trailing_slash('a')
55
- assert_equal '\\', F.trim_trailing_slash('\\')
56
- assert_equal 'a', F.trim_trailing_slash('a/')
57
- end
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
- $stderr.puts "requiring file '#{file}'" if $DEBUG
10
+ $stderr.puts "requiring file '#{file}'" if $DEBUG
11
11
 
12
- require file
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
- $stderr.puts "requiring file '#{file}'" if $DEBUG
18
+ $stderr.puts "requiring file '#{file}'" if $DEBUG
19
19
 
20
- require file
20
+ require file
21
21
  end
22
22