libpath-ruby 0.2.2 → 0.2.2.1

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 +71 -71
  7. data/lib/libpath/constants/windows.rb +72 -72
  8. data/lib/libpath/constants.rb +18 -19
  9. data/lib/libpath/diagnostics/parameter_checking.rb +25 -25
  10. data/lib/libpath/diagnostics.rb +1 -1
  11. data/lib/libpath/exceptions/libpath_base_exception.rb +13 -13
  12. data/lib/libpath/exceptions/malformed_name_exception.rb +23 -22
  13. data/lib/libpath/exceptions.rb +1 -1
  14. data/lib/libpath/form/unix.rb +104 -103
  15. data/lib/libpath/form/windows.rb +200 -199
  16. data/lib/libpath/form.rb +18 -18
  17. data/lib/libpath/internal_/array.rb +53 -53
  18. data/lib/libpath/internal_/platform.rb +24 -24
  19. data/lib/libpath/internal_/string.rb +18 -18
  20. data/lib/libpath/internal_/unix/form.rb +116 -116
  21. data/lib/libpath/internal_/windows/drive.rb +59 -59
  22. data/lib/libpath/internal_/windows/form.rb +189 -189
  23. data/lib/libpath/libpath.rb +3 -0
  24. data/lib/libpath/path/unix.rb +114 -112
  25. data/lib/libpath/path/windows.rb +120 -118
  26. data/lib/libpath/path.rb +18 -20
  27. data/lib/libpath/util/unix.rb +258 -258
  28. data/lib/libpath/util/windows.rb +400 -400
  29. data/lib/libpath/util.rb +18 -19
  30. data/lib/libpath/version.rb +23 -24
  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
@@ -1,15 +1,16 @@
1
1
  # ######################################################################## #
2
- # File: libpath/constants/windows.rb
2
+ # File: libpath/constants/windows.rb
3
3
  #
4
- # Purpose: LibPath::Constants::Windows module
4
+ # Purpose: LibPath::Constants::Windows module
5
5
  #
6
- # Created: 29th January 2019
7
- # Updated: 16th April 2019
6
+ # Created: 29th January 2019
7
+ # Updated: 6th April 2024
8
8
  #
9
- # Home: http://github.com/synesissoftware/libpath.Ruby
9
+ # Home: http://github.com/synesissoftware/libpath.Ruby
10
10
  #
11
- # Author: Matthew Wilson
11
+ # Author: Matthew Wilson
12
12
  #
13
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
13
14
  # Copyright (c) 2019, Matthew Wilson and Synesis Software
14
15
  # All rights reserved.
15
16
  #
@@ -43,7 +44,6 @@
43
44
  # ######################################################################## #
44
45
 
45
46
 
46
-
47
47
  =begin
48
48
  =end
49
49
 
@@ -55,84 +55,84 @@ module Windows # :nodoc:
55
55
  # any class or module including/extending module LibPath::Constants::Windows
56
56
  module LibPath_Constants_Windows_Details
57
57
 
58
- # Defines invalid characters
59
- module InvalidCharacters
60
-
61
- # Innately invalid characters
62
- module Innate
63
-
64
- # The list of characters
65
- LIST = [
66
-
67
- "\0",
68
- ]
69
- # The regular expression
70
- RE = /[#{LIST.map { |m| Regexp.escape m }.join}]/
71
- end # module Innate
72
-
73
- # Valid path name separator characters
74
- module PathNameSeparators
75
-
76
- # The list of characters
77
- LIST = [
78
-
79
- "\\",
80
- '/',
81
- ]
82
- # The regular expression
83
- RE = /[#{LIST.map { |m| Regexp.escape m }.join}]/
84
- end # module PathNameSeparators
85
-
86
- # Valid path separator characters
87
- module PathSeparators
88
-
89
- # The list of characters
90
- LIST = [
91
-
92
- ';',
93
- ]
94
- # The regular expression
95
- RE = /[#{LIST.map { |m| Regexp.escape m }.join}]/
96
- end # module PathSeparators
97
-
98
- # Invalid shell characters
99
- module Shell
100
-
101
- # The list of characters
102
- LIST = [
103
-
104
- '*',
105
- '<',
106
- '>',
107
- '?',
108
- '|',
109
- ]
110
- # The regular expression
111
- RE = /[#{LIST.map { |m| Regexp.escape m }.join}]/
112
- end # module Shell
113
- end # module InvalidCharacters
58
+ # Defines invalid characters
59
+ module InvalidCharacters
60
+
61
+ # Innately invalid characters
62
+ module Innate
63
+
64
+ # The list of characters
65
+ LIST = [
66
+
67
+ "\0",
68
+ ]
69
+ # The regular expression
70
+ RE = /[#{LIST.map { |m| Regexp.escape m }.join}]/
71
+ end # module Innate
72
+
73
+ # Valid path name separator characters
74
+ module PathNameSeparators
75
+
76
+ # The list of characters
77
+ LIST = [
78
+
79
+ "\\",
80
+ '/',
81
+ ]
82
+ # The regular expression
83
+ RE = /[#{LIST.map { |m| Regexp.escape m }.join}]/
84
+ end # module PathNameSeparators
85
+
86
+ # Valid path separator characters
87
+ module PathSeparators
88
+
89
+ # The list of characters
90
+ LIST = [
91
+
92
+ ';',
93
+ ]
94
+ # The regular expression
95
+ RE = /[#{LIST.map { |m| Regexp.escape m }.join}]/
96
+ end # module PathSeparators
97
+
98
+ # Invalid shell characters
99
+ module Shell
100
+
101
+ # The list of characters
102
+ LIST = [
103
+
104
+ '*',
105
+ '<',
106
+ '>',
107
+ '?',
108
+ '|',
109
+ ]
110
+ # The regular expression
111
+ RE = /[#{LIST.map { |m| Regexp.escape m }.join}]/
112
+ end # module Shell
113
+ end # module InvalidCharacters
114
114
  end # module LibPath_Constants_Windows_Details
115
115
 
116
116
  # @!visibility private
117
117
  def self.extended receiver # :nodoc:
118
118
 
119
- receiver.class_eval do
119
+ receiver.class_eval do
120
120
 
121
- extend LibPath_Constants_Windows_Details
122
- end
121
+ extend LibPath_Constants_Windows_Details
122
+ end
123
123
 
124
- $stderr.puts "#{receiver} extended by #{LibPath_Constants_Windows_Details}" if $DEBUG
124
+ $stderr.puts "#{receiver} extended by #{LibPath_Constants_Windows_Details}" if $DEBUG
125
125
  end
126
126
 
127
127
  # @!visibility private
128
128
  def self.included receiver # :nodoc:
129
129
 
130
- receiver.class_eval do
130
+ receiver.class_eval do
131
131
 
132
- include LibPath_Constants_Windows_Details
133
- end
132
+ include LibPath_Constants_Windows_Details
133
+ end
134
134
 
135
- $stderr.puts "#{receiver} included #{LibPath_Constants_Windows_Details}" if $DEBUG
135
+ $stderr.puts "#{receiver} included #{LibPath_Constants_Windows_Details}" if $DEBUG
136
136
  end
137
137
 
138
138
  extend LibPath_Constants_Windows_Details
@@ -142,6 +142,6 @@ end # module Windows
142
142
  end # module Constants
143
143
  end # module LibPath
144
144
 
145
- # ############################## end of file ############################# #
146
145
 
146
+ # ############################## end of file ############################# #
147
147
 
@@ -3,40 +3,39 @@ require 'libpath/internal_/platform'
3
3
 
4
4
  if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
5
5
 
6
- require 'libpath/constants/windows'
6
+ require 'libpath/constants/windows'
7
7
  else
8
8
 
9
- require 'libpath/constants/unix'
9
+ require 'libpath/constants/unix'
10
10
  end
11
11
 
12
12
  module LibPath # :nodoc:
13
13
  module Constants # :nodoc:
14
14
 
15
- if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
15
+ if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
16
16
 
17
- extend ::LibPath::Constants::Windows
18
- include ::LibPath::Constants::Windows
19
- else
17
+ extend ::LibPath::Constants::Windows
18
+ include ::LibPath::Constants::Windows
19
+ else
20
20
 
21
- extend ::LibPath::Constants::Unix
22
- include ::LibPath::Constants::Unix
23
- end
21
+ extend ::LibPath::Constants::Unix
22
+ include ::LibPath::Constants::Unix
23
+ end
24
24
 
25
- # @!visibility private
26
- def self.extended receiver # :nodoc:
25
+ # @!visibility private
26
+ def self.extended receiver # :nodoc:
27
27
 
28
- $stderr.puts "#{receiver} extended by #{self}" if $DEBUG
29
- end
28
+ $stderr.puts "#{receiver} extended by #{self}" if $DEBUG
29
+ end
30
30
 
31
- # @!visibility private
32
- def self.included receiver # :nodoc:
33
-
34
- $stderr.puts "#{receiver} included #{self}" if $DEBUG
35
- end
31
+ # @!visibility private
32
+ def self.included receiver # :nodoc:
36
33
 
34
+ $stderr.puts "#{receiver} included #{self}" if $DEBUG
35
+ end
37
36
  end # module Constants
38
37
  end # module LibPath
39
38
 
40
- # ############################## end of file ############################# #
41
39
 
40
+ # ############################## end of file ############################# #
42
41
 
@@ -2,45 +2,45 @@
2
2
  module LibPath # :nodoc:
3
3
  module Diagnostics # :nodoc:
4
4
 
5
- # @!visibility private
6
- def self.check_string_parameter param_value, param_name, **options # :nodoc:
5
+ # @!visibility private
6
+ def self.check_string_parameter param_value, param_name, **options # :nodoc:
7
7
 
8
- case param_value
9
- when nil
8
+ case param_value
9
+ when nil
10
10
 
11
- unless options[:allow_nil]
11
+ unless options[:allow_nil]
12
12
 
13
- raise ::ArgumentError, "parameter '#{param_name}' may not be nil"
14
- end
13
+ raise ::ArgumentError, "parameter '#{param_name}' may not be nil"
14
+ end
15
15
 
16
- ;
17
- when ::String
16
+ ;
17
+ when ::String
18
18
 
19
- ;
20
- else
19
+ ;
20
+ else
21
21
 
22
- unless param_value.respond_to?(:to_str)
22
+ unless param_value.respond_to?(:to_str)
23
23
 
24
- raise ::TypeError, "parameter '#{param_name}' must be instance of #{::String} or respond to #to_str()"
25
- end
26
- end
27
- end
24
+ raise ::TypeError, "parameter '#{param_name}' must be instance of #{::String} or respond to #to_str()"
25
+ end
26
+ end
27
+ end
28
28
 
29
- # @!visibility private
30
- def self.check_options h, *args, **options # :nodoc:
29
+ # @!visibility private
30
+ def self.check_options h, *args, **options # :nodoc:
31
31
 
32
- if known = options[:known] then
32
+ if known = options[:known] then
33
33
 
34
- h.each_key do |k|
34
+ h.each_key do |k|
35
35
 
36
- raise ::ArgumentError, "unknown key '#{k}'" unless known.include?(k)
37
- end
38
- end
36
+ raise ::ArgumentError, "unknown key '#{k}'" unless known.include?(k)
37
+ end
38
+ end
39
39
 
40
- end
40
+ end
41
41
  end # module Diagnostics
42
42
  end # module LibPath
43
43
 
44
- # ############################## end of file ############################# #
45
44
 
45
+ # ############################## end of file ############################# #
46
46
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  require 'libpath/diagnostics/parameter_checking'
3
3
 
4
- # ############################## end of file ############################# #
5
4
 
5
+ # ############################## end of file ############################# #
6
6
 
@@ -1,16 +1,17 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: libpath/exceptions/libpath_base_exception.rb
3
+ # File: libpath/exceptions/libpath_base_exception.rb
4
4
  #
5
- # Purpose: LibPathBaseException class
5
+ # Purpose: LibPathBaseException class
6
6
  #
7
- # Created: 30th January 2019
8
- # Updated: 16th April 2019
7
+ # Created: 30th January 2019
8
+ # Updated: 6th April 2024
9
9
  #
10
- # Home: http://github.com/synesissoftware/libpath.Ruby
10
+ # Home: http://github.com/synesissoftware/libpath.Ruby
11
11
  #
12
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -44,7 +45,6 @@
44
45
  # ######################################################################## #
45
46
 
46
47
 
47
-
48
48
  =begin
49
49
  =end
50
50
 
@@ -58,20 +58,20 @@ class LibPathBaseException < StandardError
58
58
 
59
59
  =begin
60
60
 
61
- # TODO include Xqsr3's WithCause
61
+ # TODO include Xqsr3's WithCause
62
62
  =end
63
63
 
64
- def self.new *args
64
+ def self.new *args
65
65
 
66
- raise NoMethodError, "private method `new' called for #{self}:Class" if self == LibPathBaseException
66
+ raise NoMethodError, "private method `new' called for #{self}:Class" if self == LibPathBaseException
67
67
 
68
- super
69
- end
68
+ super
69
+ end
70
70
  end
71
71
 
72
72
  end # module Exceptions
73
73
  end # module LibPath
74
74
 
75
- # ############################## end of file ############################# #
76
75
 
76
+ # ############################## end of file ############################# #
77
77
 
@@ -1,16 +1,17 @@
1
1
 
2
2
  # ######################################################################## #
3
- # File: libpath/exceptions/malformed_name_exception.rb
3
+ # File: libpath/exceptions/malformed_name_exception.rb
4
4
  #
5
- # Purpose: MalformedNameException class
5
+ # Purpose: MalformedNameException class
6
6
  #
7
- # Created: 30th January 2019
8
- # Updated: 16th April 2019
7
+ # Created: 30th January 2019
8
+ # Updated: 6th April 2024
9
9
  #
10
- # Home: http://github.com/synesissoftware/libpath.Ruby
10
+ # Home: http://github.com/synesissoftware/libpath.Ruby
11
11
  #
12
- # Author: Matthew Wilson
12
+ # Author: Matthew Wilson
13
13
  #
14
+ # Copyright (c) 2019-2024, Matthew Wilson and Synesis Information Systems
14
15
  # Copyright (c) 2019, Matthew Wilson and Synesis Software
15
16
  # All rights reserved.
16
17
  #
@@ -44,42 +45,42 @@
44
45
  # ######################################################################## #
45
46
 
46
47
 
47
-
48
48
  =begin
49
49
  =end
50
50
 
51
51
  require 'libpath/exceptions/libpath_base_exception'
52
52
 
53
+
53
54
  module LibPath # :nodoc:
54
55
  module Exceptions # :nodoc:
55
56
 
56
57
  # Exception thrown when a malformed name is encountered
57
58
  class MalformedNameException < LibPathBaseException
58
59
 
59
- # Initialises an instance from the given +name+ and optional +message+
60
- #
61
- # * *Parameters:*
62
- # - +name+ (String) The name that is malformed
63
- # - +message+ (String) {optional} The message. If +nil+ the message "malformed name '#{name}'" is used
64
- def initialize name, message = nil
60
+ # Initialises an instance from the given +name+ and optional +message+
61
+ #
62
+ # * *Parameters:*
63
+ # - +name+ (String) The name that is malformed
64
+ # - +message+ (String) {optional} The message. If +nil+ the message "malformed name '#{name}'" is used
65
+ def initialize name, message = nil
65
66
 
66
- unless message
67
+ unless message
67
68
 
68
- message = "malformed name '#{name}'"
69
- end
69
+ message = "malformed name '#{name}'"
70
+ end
70
71
 
71
- super message
72
+ super message
72
73
 
73
- @name = name
74
- end
74
+ @name = name
75
+ end
75
76
 
76
- # (String) The name that is malformed
77
- attr_reader :name
77
+ # (String) The name that is malformed
78
+ attr_reader :name
78
79
  end
79
80
 
80
81
  end # module Exceptions
81
82
  end # module LibPath
82
83
 
83
- # ############################## end of file ############################# #
84
84
 
85
+ # ############################## end of file ############################# #
85
86
 
@@ -2,6 +2,6 @@
2
2
  require 'libpath/exceptions/libpath_base_exception'
3
3
  require 'libpath/exceptions/malformed_name_exception'
4
4
 
5
- # ############################## end of file ############################# #
6
5
 
6
+ # ############################## end of file ############################# #
7
7