Class: FilePathUtils
Class Method Summary collapse
-
.add_path?(path) ⇒ Boolean
Return whether the given path is to be aggregated (no aggregation modifier defaults to same as +:).
-
.no_aggregation_decorators(path) ⇒ Object
Get path (and glob) lopping off optional +: / -: prefixed aggregation modifiers.
-
.no_decorators(path) ⇒ Object
Extract path from between optional aggregation modifiers and up to last path separator before glob specifiers.
- .os_executable_ext(executable) ⇒ Object
-
.reform_subdirectory_glob(path) ⇒ Object
To recurse through all subdirectories, the RUby glob is <dir>//, but our paths use convenience convention of only <dir>/** at tail end of a path.
-
.standardize(path) ⇒ Object
Standardize path to use ‘/’ path separator & have no trailing path separator.
Instance Method Summary collapse
- #form_fail_results_filepath(build_output_path, filepath) ⇒ Object
- #form_mocks_source_filelist(path, mocks) ⇒ Object
- #form_pass_results_filelist(path, files) ⇒ Object
- #form_pass_results_filepath(build_output_path, filepath) ⇒ Object
- #form_preprocessed_file_directives_only_filepath(filepath, subdir) ⇒ Object
- #form_preprocessed_file_filepath(filepath, subdir) ⇒ Object
- #form_preprocessed_file_full_expansion_filepath(filepath, subdir) ⇒ Object
- #form_preprocessed_includes_list_filepath(filepath, subdir) ⇒ Object
-
#form_release_build_cache_path(filepath) ⇒ Object
release ###.
- #form_release_build_list_filepath(filepath) ⇒ Object
- #form_release_build_objects_filelist(files) ⇒ Object
- #form_release_dependencies_filelist(files) ⇒ Object
- #form_release_dependencies_filepath(filepath) ⇒ Object
- #form_runner_filepath_from_test(filepath) ⇒ Object
-
#form_test_build_cache_path(filepath) ⇒ Object
Tests ###.
- #form_test_build_list_filepath(filepath) ⇒ Object
- #form_test_build_map_filepath(build_output_path, filepath) ⇒ Object
- #form_test_build_objects_filelist(path, sources) ⇒ Object
- #form_test_dependencies_filelist(files) ⇒ Object
- #form_test_dependencies_filepath(filepath) ⇒ Object
- #form_test_executable_filepath(build_output_path, filepath) ⇒ Object
- #form_test_filepath_from_runner(filepath) ⇒ Object
Class Method Details
.add_path?(path) ⇒ Boolean
Return whether the given path is to be aggregated (no aggregation modifier defaults to same as +:)
77 78 79 |
# File 'lib/ceedling/file_path_utils.rb', line 77 def self.add_path?(path) return !path.strip.start_with?('-:') end |
.no_aggregation_decorators(path) ⇒ Object
Get path (and glob) lopping off optional +: / -: prefixed aggregation modifiers
82 83 84 |
# File 'lib/ceedling/file_path_utils.rb', line 82 def self.no_aggregation_decorators(path) return path.sub(/^(\+|-):/, '').strip() end |
.no_decorators(path) ⇒ Object
Extract path from between optional aggregation modifiers and up to last path separator before glob specifiers. Examples:
- '+:foo/bar/baz/' => 'foo/bar/baz'
- 'foo/bar/ba?' => 'foo/bar'
- 'foo/bar/baz/' => 'foo/bar/baz'
- 'foo/bar/baz/file.x' => 'foo/bar/baz/file.x'
- 'foo/bar/baz/file*.x' => 'foo/bar/baz'
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ceedling/file_path_utils.rb', line 51 def self.no_decorators(path) path = self.no_aggregation_decorators(path) # Find first occurrence of glob specifier: *, ?, {, }, [, ] find_index = (path =~ GLOB_PATTERN) # Return empty path if first character is part of a glob return '' if find_index == 0 # If path contains no glob, clean it up and return whole path return path.chomp('/') if (find_index.nil?) # Extract up to first glob specifier path = path[0..(find_index-1)] # Keep everything from start of path string up to and # including final path separator before glob character find_index = path.rindex('/') return path[0..(find_index-1)] if (not find_index.nil?) # Otherwise, return empty string # (Not enough of a usable path exists free of glob operators) return '' end |
.os_executable_ext(executable) ⇒ Object
38 39 40 41 |
# File 'lib/ceedling/file_path_utils.rb', line 38 def self.os_executable_ext(executable) return executable.ext('.exe') if SystemWrapper.windows? return executable end |
.reform_subdirectory_glob(path) ⇒ Object
To recurse through all subdirectories, the RUby glob is <dir>//, but our paths use convenience convention of only <dir>/** at tail end of a path.
88 89 90 91 92 |
# File 'lib/ceedling/file_path_utils.rb', line 88 def self.reform_subdirectory_glob(path) return path if path.end_with?( '/**/**' ) return path + '/**' if path.end_with?( '/**' ) return path end |
.standardize(path) ⇒ Object
Standardize path to use ‘/’ path separator & have no trailing path separator
29 30 31 32 33 34 35 36 |
# File 'lib/ceedling/file_path_utils.rb', line 29 def self.standardize(path) if path.is_a? String path.strip! path.gsub!(/\\/, '/') path.chomp!('/') end return path end |
Instance Method Details
#form_fail_results_filepath(build_output_path, filepath) ⇒ Object
131 132 133 |
# File 'lib/ceedling/file_path_utils.rb', line 131 def form_fail_results_filepath(build_output_path, filepath) return File.join( build_output_path, File.basename(filepath).ext(@configurator.extension_testfail) ) end |
#form_mocks_source_filelist(path, mocks) ⇒ Object
175 176 177 178 |
# File 'lib/ceedling/file_path_utils.rb', line 175 def form_mocks_source_filelist(path, mocks) list = (@file_wrapper.instantiate_file_list(mocks)) return list.map{ |file| File.join(path, File.basename(file).ext(@configurator.extension_source)) } end |
#form_pass_results_filelist(path, files) ⇒ Object
185 186 187 188 |
# File 'lib/ceedling/file_path_utils.rb', line 185 def form_pass_results_filelist(path, files) list = @file_wrapper.instantiate_file_list(files) return list.pathmap("#{path}/%n#{@configurator.extension_testpass}") end |
#form_pass_results_filepath(build_output_path, filepath) ⇒ Object
127 128 129 |
# File 'lib/ceedling/file_path_utils.rb', line 127 def form_pass_results_filepath(build_output_path, filepath) return File.join( build_output_path, File.basename(filepath).ext(@configurator.extension_testpass) ) end |
#form_preprocessed_file_directives_only_filepath(filepath, subdir) ⇒ Object
167 168 169 |
# File 'lib/ceedling/file_path_utils.rb', line 167 def form_preprocessed_file_directives_only_filepath(filepath, subdir) return File.join( @configurator.project_test_preprocess_files_path, subdir, PREPROCESS_DIRECTIVES_ONLY_DIR, File.basename(filepath) ) end |
#form_preprocessed_file_filepath(filepath, subdir) ⇒ Object
159 160 161 |
# File 'lib/ceedling/file_path_utils.rb', line 159 def form_preprocessed_file_filepath(filepath, subdir) return File.join( @configurator.project_test_preprocess_files_path, subdir, File.basename(filepath) ) end |
#form_preprocessed_file_full_expansion_filepath(filepath, subdir) ⇒ Object
163 164 165 |
# File 'lib/ceedling/file_path_utils.rb', line 163 def form_preprocessed_file_full_expansion_filepath(filepath, subdir) return File.join( @configurator.project_test_preprocess_files_path, subdir, PREPROCESS_FULL_EXPANSION_DIR, File.basename(filepath) ) end |
#form_preprocessed_includes_list_filepath(filepath, subdir) ⇒ Object
155 156 157 |
# File 'lib/ceedling/file_path_utils.rb', line 155 def form_preprocessed_includes_list_filepath(filepath, subdir) return File.join( @configurator.project_test_preprocess_includes_path, subdir, File.basename(filepath) + @configurator.extension_yaml ) end |
#form_release_build_cache_path(filepath) ⇒ Object
release ###
97 98 99 |
# File 'lib/ceedling/file_path_utils.rb', line 97 def form_release_build_cache_path(filepath) return File.join( @configurator.project_release_build_cache_path, File.basename(filepath) ) end |
#form_release_build_list_filepath(filepath) ⇒ Object
109 110 111 |
# File 'lib/ceedling/file_path_utils.rb', line 109 def form_release_build_list_filepath(filepath) return File.join( @configurator.project_release_build_output_path, File.basename(filepath).ext(@configurator.extension_list) ) end |
#form_release_build_objects_filelist(files) ⇒ Object
105 106 107 |
# File 'lib/ceedling/file_path_utils.rb', line 105 def form_release_build_objects_filelist(files) return (@file_wrapper.instantiate_file_list(files)).pathmap("#{@configurator.project_release_build_output_path}/%n#{@configurator.extension_object}") end |
#form_release_dependencies_filelist(files) ⇒ Object
113 114 115 |
# File 'lib/ceedling/file_path_utils.rb', line 113 def form_release_dependencies_filelist(files) return (@file_wrapper.instantiate_file_list(files)).pathmap("#{@configurator.project_release_dependencies_path}/%n#{@configurator.extension_dependencies}") end |
#form_release_dependencies_filepath(filepath) ⇒ Object
101 102 103 |
# File 'lib/ceedling/file_path_utils.rb', line 101 def form_release_dependencies_filepath(filepath) return File.join( @configurator.project_release_dependencies_path, File.basename(filepath).ext(@configurator.extension_dependencies) ) end |
#form_runner_filepath_from_test(filepath) ⇒ Object
135 136 137 |
# File 'lib/ceedling/file_path_utils.rb', line 135 def form_runner_filepath_from_test(filepath) return File.join( @configurator.project_test_runners_path, File.basename(filepath, @configurator.extension_source)) + @configurator.test_runner_file_suffix + EXTENSION_CORE_SOURCE end |
#form_test_build_cache_path(filepath) ⇒ Object
Tests ###
119 120 121 |
# File 'lib/ceedling/file_path_utils.rb', line 119 def form_test_build_cache_path(filepath) return File.join( @configurator.project_test_build_cache_path, File.basename(filepath) ) end |
#form_test_build_list_filepath(filepath) ⇒ Object
151 152 153 |
# File 'lib/ceedling/file_path_utils.rb', line 151 def form_test_build_list_filepath(filepath) return File.join( @configurator.project_test_build_output_path, File.basename(filepath).ext(@configurator.extension_list) ) end |
#form_test_build_map_filepath(build_output_path, filepath) ⇒ Object
147 148 149 |
# File 'lib/ceedling/file_path_utils.rb', line 147 def form_test_build_map_filepath(build_output_path, filepath) return File.join( build_output_path, File.basename(filepath).ext(@configurator.extension_map) ) end |
#form_test_build_objects_filelist(path, sources) ⇒ Object
171 172 173 |
# File 'lib/ceedling/file_path_utils.rb', line 171 def form_test_build_objects_filelist(path, sources) return (@file_wrapper.instantiate_file_list(sources)).pathmap("#{path}/%n#{@configurator.extension_object}") end |
#form_test_dependencies_filelist(files) ⇒ Object
180 181 182 183 |
# File 'lib/ceedling/file_path_utils.rb', line 180 def form_test_dependencies_filelist(files) list = @file_wrapper.instantiate_file_list(files) return list.pathmap("#{@configurator.project_test_dependencies_path}/%n#{@configurator.extension_dependencies}") end |
#form_test_dependencies_filepath(filepath) ⇒ Object
123 124 125 |
# File 'lib/ceedling/file_path_utils.rb', line 123 def form_test_dependencies_filepath(filepath) return File.join( @configurator.project_test_dependencies_path, File.basename(filepath).ext(@configurator.extension_dependencies) ) end |
#form_test_executable_filepath(build_output_path, filepath) ⇒ Object
143 144 145 |
# File 'lib/ceedling/file_path_utils.rb', line 143 def form_test_executable_filepath(build_output_path, filepath) return File.join( build_output_path, File.basename(filepath).ext(@configurator.extension_executable) ) end |
#form_test_filepath_from_runner(filepath) ⇒ Object
139 140 141 |
# File 'lib/ceedling/file_path_utils.rb', line 139 def form_test_filepath_from_runner(filepath) return filepath.sub(/#{TEST_RUNNER_FILE_SUFFIX}/, '') end |