libpath-ruby 0.2.2 → 0.2.2.2
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 +74 -74
- data/lib/libpath/constants/windows.rb +75 -75
- data/lib/libpath/constants.rb +20 -20
- data/lib/libpath/diagnostics/parameter_checking.rb +27 -26
- data/lib/libpath/diagnostics.rb +1 -1
- data/lib/libpath/exceptions/libpath_base_exception.rb +20 -21
- data/lib/libpath/exceptions/malformed_name_exception.rb +27 -27
- data/lib/libpath/exceptions.rb +1 -1
- data/lib/libpath/form/unix.rb +118 -118
- data/lib/libpath/form/windows.rb +228 -214
- data/lib/libpath/form.rb +20 -21
- data/lib/libpath/internal_/array.rb +57 -57
- data/lib/libpath/internal_/platform.rb +30 -31
- data/lib/libpath/internal_/string.rb +25 -20
- data/lib/libpath/internal_/unix/form.rb +124 -119
- data/lib/libpath/internal_/windows/drive.rb +80 -75
- data/lib/libpath/internal_/windows/form.rb +205 -194
- data/lib/libpath/libpath.rb +4 -1
- data/lib/libpath/path/unix.rb +120 -118
- data/lib/libpath/path/windows.rb +126 -124
- data/lib/libpath/path.rb +21 -21
- data/lib/libpath/util/unix.rb +261 -261
- data/lib/libpath/util/windows.rb +403 -403
- data/lib/libpath/util.rb +20 -20
- data/lib/libpath/version.rb +25 -26
- 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
data/lib/libpath/path/unix.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
|
2
2
|
# ######################################################################## #
|
3
|
-
# File:
|
3
|
+
# File: libpath/path/unix.rb
|
4
4
|
#
|
5
|
-
# Purpose:
|
5
|
+
# Purpose: LibPath::Path::Unix module
|
6
6
|
#
|
7
|
-
# Created:
|
8
|
-
# Updated:
|
7
|
+
# Created: 21st January 2019
|
8
|
+
# Updated: 7th April 2024
|
9
9
|
#
|
10
|
-
# Home:
|
10
|
+
# Home: http://github.com/synesissoftware/libpath.Ruby
|
11
11
|
#
|
12
|
-
# Author:
|
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
|
|
@@ -52,119 +52,121 @@ require 'libpath/diagnostics'
|
|
52
52
|
require 'libpath/internal_/unix/form'
|
53
53
|
require 'libpath/util/unix'
|
54
54
|
|
55
|
-
|
56
|
-
module
|
57
|
-
module
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
end
|
55
|
+
|
56
|
+
module LibPath
|
57
|
+
module Path
|
58
|
+
|
59
|
+
module Unix
|
60
|
+
|
61
|
+
# Class representing a parsed path (for UNIX)
|
62
|
+
class ParsedPath
|
63
|
+
|
64
|
+
# @!visibility private
|
65
|
+
module ParsedPath_Constants # :nodoc: all
|
66
|
+
|
67
|
+
INIT_VALID_OPTIONS = %i{ home locator pwd }
|
68
|
+
INIT_MPA_COMMON_OPTIONS = %i{ home locator pwd }
|
69
|
+
INIT_DRP_COMMON_OPTIONS = %i{ home locator pwd }
|
70
|
+
end
|
71
|
+
|
72
|
+
# Initialises an instance from the given +path+, optional
|
73
|
+
# +search_directory+ and options
|
74
|
+
#
|
75
|
+
# === Signature
|
76
|
+
#
|
77
|
+
# * *Parameters:*
|
78
|
+
# - +path+ (String) The path. May not be +nil+
|
79
|
+
# - +search_directory+ (String) The search_directory, from which the relative attributes are calculated for the path. May be +nil+
|
80
|
+
# - +options+ (Hash) Options
|
81
|
+
#
|
82
|
+
# * *Options:*
|
83
|
+
# - +????+
|
84
|
+
#
|
85
|
+
# * *Exceptions:*
|
86
|
+
# - +ArgumentError+ Raised if +path+ is +nil+
|
87
|
+
def initialize path, search_directory = nil, **options
|
88
|
+
|
89
|
+
raise ::ArgumentError, "path may not be nil or empty" if path.nil? || path.empty?
|
90
|
+
|
91
|
+
_Diagnostics = ::LibPath::Diagnostics
|
92
|
+
_Internal_Form = ::LibPath::Internal_::Unix::Form
|
93
|
+
_Util = ::LibPath::Util::Unix
|
94
|
+
_C = ::LibPath::Path::Unix::ParsedPath::ParsedPath_Constants
|
95
|
+
|
96
|
+
_Diagnostics.check_options(options, known: _C::INIT_VALID_OPTIONS)
|
97
|
+
|
98
|
+
|
99
|
+
abs_path = _Util.make_path_absolute(path, make_canonical: true, **options.select { |k| _C::INIT_MPA_COMMON_OPTIONS.include?(k) })
|
100
|
+
|
101
|
+
_, _, f2_dir, f3_basename, f4_stem, f5_ext, f6_dir_parts, _ = _Internal_Form.split_path(abs_path)
|
102
|
+
|
103
|
+
@given_path = path
|
104
|
+
@absolute_path = abs_path
|
105
|
+
@compare_path = _Util.make_compare_path abs_path
|
106
|
+
@directory = f2_dir
|
107
|
+
@directory_path = f2_dir
|
108
|
+
@directory_parts = f6_dir_parts
|
109
|
+
|
110
|
+
@file_full_name = f3_basename
|
111
|
+
@file_name_only = f4_stem
|
112
|
+
@file_extension = f5_ext
|
113
|
+
|
114
|
+
if search_directory
|
115
|
+
|
116
|
+
drp_options = options.select { |k| _C::INIT_DRP_COMMON_OPTIONS.include?(k) }
|
117
|
+
|
118
|
+
search_directory = _Util.make_path_absolute(search_directory, make_canonical: true, **options.select { |k| _C::INIT_MPA_COMMON_OPTIONS.include?(k) })
|
119
|
+
search_directory = _Internal_Form.append_trailing_slash search_directory
|
120
|
+
|
121
|
+
@search_directory = search_directory
|
122
|
+
@search_relative_path = _Util.derive_relative_path(search_directory, abs_path, **drp_options)
|
123
|
+
@search_relative_path = _Internal_Form.append_trailing_slash(@search_relative_path) if _Internal_Form.char_is_path_name_separator?(abs_path[-1])
|
124
|
+
@search_relative_directory_path = _Internal_Form.append_trailing_slash _Util.derive_relative_path(search_directory, f2_dir, **drp_options)
|
125
|
+
@search_relative_directory_parts = @search_relative_directory_path.split('/').map { |v| v + '/' }
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# (String) The path given to initialise the instance
|
130
|
+
attr_reader :given_path
|
131
|
+
# (String) The full-path of the instance
|
132
|
+
attr_reader :absolute_path
|
133
|
+
# (String) A normalised form of #path that can be used in comparisons
|
134
|
+
attr_reader :compare_path
|
135
|
+
# (String) The entry's directory (excluding the #drive if on Windows)
|
136
|
+
attr_reader :directory
|
137
|
+
# (String) The full path of the entry's directory
|
138
|
+
attr_reader :directory_path
|
139
|
+
alias_method :dirname, :directory_path
|
140
|
+
# ([String]) An array of directory parts, where each part ends in the path name separator
|
141
|
+
attr_reader :directory_parts
|
142
|
+
# (String) The entry's file name (combination of #stem + #extension)
|
143
|
+
attr_reader :file_full_name
|
144
|
+
alias_method :basename, :file_full_name
|
145
|
+
# (String) The entry's file stem
|
146
|
+
attr_reader :file_name_only
|
147
|
+
alias_method :stem, :file_name_only
|
148
|
+
# (String) The entry's file extension
|
149
|
+
attr_reader :file_extension
|
150
|
+
alias_method :extension, :file_extension
|
151
|
+
# (String) The search directory if specified; +nil+ otherwise
|
152
|
+
attr_reader :search_directory
|
153
|
+
# (String) The #path relative to #search_directory; +nil+ if no search directory specified
|
154
|
+
attr_reader :search_relative_path
|
155
|
+
# (String) The #directory_path relative to #search_directory; +nil+ if no search directory specified
|
156
|
+
attr_reader :search_relative_directory_path
|
157
|
+
# ([String]) The #directory_parts relative to #search_directory; +nil+ if no search directory specified
|
158
|
+
attr_reader :search_relative_directory_parts
|
159
|
+
|
160
|
+
# (String) String form of path
|
161
|
+
def to_s
|
162
|
+
|
163
|
+
absolute_path
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end # module Unix
|
166
167
|
end # module Path
|
167
168
|
end # module LibPath
|
168
169
|
|
170
|
+
|
169
171
|
# ############################## end of file ############################# #
|
170
172
|
|
data/lib/libpath/path/windows.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
|
2
2
|
# ######################################################################## #
|
3
|
-
# File:
|
3
|
+
# File: libpath/path/windows.rb
|
4
4
|
#
|
5
|
-
# Purpose:
|
5
|
+
# Purpose: LibPath::Path::Windows module
|
6
6
|
#
|
7
|
-
# Created:
|
8
|
-
# Updated:
|
7
|
+
# Created: 21st January 2019
|
8
|
+
# Updated: 7th April 2024
|
9
9
|
#
|
10
|
-
# Home:
|
10
|
+
# Home: http://github.com/synesissoftware/libpath.Ruby
|
11
11
|
#
|
12
|
-
# Author:
|
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
|
|
@@ -52,125 +52,127 @@ require 'libpath/diagnostics'
|
|
52
52
|
require 'libpath/internal_/windows/form'
|
53
53
|
require 'libpath/util/windows'
|
54
54
|
|
55
|
-
|
56
|
-
module
|
57
|
-
module
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
end
|
55
|
+
|
56
|
+
module LibPath
|
57
|
+
module Path
|
58
|
+
|
59
|
+
module Windows
|
60
|
+
|
61
|
+
# Class representing a parsed path (for Windows)
|
62
|
+
class ParsedPath
|
63
|
+
|
64
|
+
# @!visibility private
|
65
|
+
module ParsedPath_Constants # :nodoc: all
|
66
|
+
|
67
|
+
INIT_VALID_OPTIONS = %i{ home locator pwd }
|
68
|
+
INIT_MPA_COMMON_OPTIONS = %i{ home locator pwd }
|
69
|
+
INIT_DRP_COMMON_OPTIONS = %i{ home locator pwd }
|
70
|
+
end
|
71
|
+
|
72
|
+
# Initialises an instance from the given +path+, optional
|
73
|
+
# +search_directory+ and options
|
74
|
+
#
|
75
|
+
# === Signature
|
76
|
+
#
|
77
|
+
# * *Parameters:*
|
78
|
+
# - +path+ (String) The path. May not be +nil+
|
79
|
+
# - +search_directory+ (String) The search_directory, from which the relative attributes are calculated for the path. May be +nil+
|
80
|
+
# - +options+ (Hash) Options
|
81
|
+
#
|
82
|
+
# * *Options:*
|
83
|
+
# - +????+
|
84
|
+
#
|
85
|
+
# * *Exceptions:*
|
86
|
+
# - +ArgumentError+ Raised if +path+ is +nil+
|
87
|
+
def initialize path, search_directory = nil, **options
|
88
|
+
|
89
|
+
raise ::ArgumentError, "path may not be nil or empty" if path.nil? || path.empty?
|
90
|
+
|
91
|
+
_Diagnostics = ::LibPath::Diagnostics
|
92
|
+
_Internal_Form = ::LibPath::Internal_::Windows::Form
|
93
|
+
_Util = ::LibPath::Util::Windows
|
94
|
+
_C = ::LibPath::Path::Windows::ParsedPath::ParsedPath_Constants
|
95
|
+
|
96
|
+
_Diagnostics.check_options(options, known: _C::INIT_VALID_OPTIONS)
|
97
|
+
|
98
|
+
|
99
|
+
abs_path = _Util.make_path_absolute(path, make_canonical: true, **options.select { |k| _C::INIT_MPA_COMMON_OPTIONS.include?(k) })
|
100
|
+
|
101
|
+
splits = _Internal_Form.split_path(abs_path)
|
102
|
+
|
103
|
+
_, f1_vol, f2_dir, f3_basename, f4_stem, f5_ext, f6_dir_parts, f7_abs_parts = *splits
|
104
|
+
|
105
|
+
@given_path = path
|
106
|
+
@absolute_path = abs_path
|
107
|
+
@compare_path = _Util.make_compare_path abs_path, splits: splits
|
108
|
+
@volume = f1_vol
|
109
|
+
@directory = f2_dir
|
110
|
+
@directory_path = "#{f1_vol}#{f2_dir}"
|
111
|
+
@directory_parts = f6_dir_parts
|
112
|
+
|
113
|
+
@file_full_name = f3_basename
|
114
|
+
@file_name_only = f4_stem
|
115
|
+
@file_extension = f5_ext
|
116
|
+
|
117
|
+
if search_directory
|
118
|
+
|
119
|
+
drp_options = options.select { |k| _C::INIT_DRP_COMMON_OPTIONS.include?(k) }
|
120
|
+
|
121
|
+
search_directory = _Util.make_path_canonical search_directory, make_slashes_canonical: true
|
122
|
+
search_directory = _Internal_Form.append_trailing_slash search_directory
|
123
|
+
|
124
|
+
@search_directory = search_directory
|
125
|
+
@search_relative_path = _Util.derive_relative_path(search_directory, abs_path, **drp_options)
|
126
|
+
@search_relative_path = _Internal_Form.append_trailing_slash(@search_relative_path) if _Internal_Form.char_is_path_name_separator?(abs_path[-1])
|
127
|
+
@search_relative_directory_path = _Internal_Form.append_trailing_slash _Util.derive_relative_path(search_directory, "#{f1_vol}#{f2_dir}", **drp_options)
|
128
|
+
@search_relative_directory_parts = @search_relative_directory_path.split('\\').map { |v| v + '\\' }
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# (String) The path given to initialise the instance
|
133
|
+
attr_reader :given_path
|
134
|
+
# (String) The full-path of the instance
|
135
|
+
attr_reader :absolute_path
|
136
|
+
# (String) A normalised form of #path that can be used in comparisons
|
137
|
+
attr_reader :compare_path
|
138
|
+
# (String) The Windows volume, which may be a drive, or a UNC specification
|
139
|
+
attr_reader :volume
|
140
|
+
# (String) The entry's directory (excluding the #drive if on Windows)
|
141
|
+
attr_reader :directory
|
142
|
+
# (String) The full path of the entry's directory (taking into account the
|
143
|
+
# #drive if on Windows)
|
144
|
+
attr_reader :directory_path
|
145
|
+
alias_method :dirname, :directory_path
|
146
|
+
# ([String]) An array of directory parts, where each part ends in the path name separator
|
147
|
+
attr_reader :directory_parts
|
148
|
+
# (String) The entry's file name (combination of #stem + #extension)
|
149
|
+
attr_reader :file_full_name
|
150
|
+
alias_method :basename, :file_full_name
|
151
|
+
# (String) The entry's file stem
|
152
|
+
attr_reader :file_name_only
|
153
|
+
alias_method :stem, :file_name_only
|
154
|
+
# (String) The entry's file extension
|
155
|
+
attr_reader :file_extension
|
156
|
+
alias_method :extension, :file_extension
|
157
|
+
# (String) The search directory if specified; +nil+ otherwise
|
158
|
+
attr_reader :search_directory
|
159
|
+
# (String) The #path relative to #search_directory; +nil+ if no search directory specified
|
160
|
+
attr_reader :search_relative_path
|
161
|
+
# (String) The #directory_path relative to #search_directory; +nil+ if no search directory specified
|
162
|
+
attr_reader :search_relative_directory_path
|
163
|
+
# ([String]) The #directory_parts relative to #search_directory; +nil+ if no search directory specified
|
164
|
+
attr_reader :search_relative_directory_parts
|
165
|
+
|
166
|
+
# (String) String form of path
|
167
|
+
def to_s
|
168
|
+
|
169
|
+
absolute_path
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end # module Windows
|
172
173
|
end # module Path
|
173
174
|
end # module LibPath
|
174
175
|
|
176
|
+
|
175
177
|
# ############################## end of file ############################# #
|
176
178
|
|
data/lib/libpath/path.rb
CHANGED
@@ -3,41 +3,41 @@ require 'libpath/internal_/platform'
|
|
3
3
|
|
4
4
|
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
5
5
|
|
6
|
-
|
6
|
+
require 'libpath/path/windows'
|
7
7
|
else
|
8
8
|
|
9
|
-
|
9
|
+
require 'libpath/path/unix'
|
10
10
|
end
|
11
11
|
|
12
|
-
module LibPath # :nodoc:
|
13
|
-
module Path # :nodoc:
|
14
12
|
|
15
|
-
|
13
|
+
module LibPath
|
14
|
+
# @!visibility private
|
15
|
+
module Path # :nodoc:
|
16
16
|
|
17
|
-
|
18
|
-
include ::LibPath::Path::Windows
|
19
|
-
else
|
17
|
+
if ::LibPath::Internal_::Platform::Constants::PLATFORM_IS_WINDOWS then
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
extend ::LibPath::Path::Windows
|
20
|
+
include ::LibPath::Path::Windows
|
21
|
+
else
|
24
22
|
|
25
|
-
|
26
|
-
|
23
|
+
extend ::LibPath::Path::Unix
|
24
|
+
include ::LibPath::Path::Unix
|
25
|
+
end
|
27
26
|
|
28
|
-
|
29
|
-
|
27
|
+
# @!visibility private
|
28
|
+
def self.extended receiver # :nodoc:
|
30
29
|
|
31
|
-
|
32
|
-
|
30
|
+
$stderr.puts "#{receiver} extended by #{self}" if $DEBUG
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
33
|
+
# @!visibility private
|
34
|
+
def self.included receiver # :nodoc:
|
36
35
|
|
36
|
+
$stderr.puts "#{receiver} included #{self}" if $DEBUG
|
37
|
+
end
|
37
38
|
end # module Path
|
38
39
|
end # module LibPath
|
39
40
|
|
40
|
-
# ############################## end of file ############################# #
|
41
|
-
|
42
41
|
|
42
|
+
# ############################## end of file ############################# #
|
43
43
|
|