Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve tests and docs for filename_from_key
- Loading branch information
Dan Mayer
committed
Feb 9, 2019
1 parent
3130012
commit c10da72
Showing
2 changed files
with
32 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,14 +61,31 @@ def merge_arrays(first, second) | |
merged | ||
end | ||
|
||
### | ||
# filename_from_key code takes: | ||
# key: which is a full path the same as reported by Coverage | ||
# roots: if a collection of all possible full app paths | ||
# EX: [Coverband.configuration.root_paths, "#{current_root}/"] | ||
# The LAST item should be the current file system root | ||
# it expands that expands and adds a '/' as that isn't there from Dir.pwd | ||
# | ||
# NOTEs on configuration.root_paths usage | ||
# strings: matching is pretty simple for full string paths | ||
# regex: to get regex to work for changing deploy directories | ||
# the regex must be double escaped in double quotes | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
danmayer
Owner
|
||
# (if using \d for example) | ||
# or use single qoutes | ||
# example: '/box/apps/app_name/releases/\d+/' | ||
# example: '/var/local/company/company.d/[0-9]*/' | ||
### | ||
def filename_from_key(key, roots) | ||
filename = key | ||
roots.each do |root| | ||
filename = filename.gsub(/^#{root}/, './') | ||
end | ||
# the filename for SimpleCov is expected to be a full path. | ||
# The filename for Coverage report is expected to be a full LOCAL path. | ||
# roots.last should be roots << current_root}/ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
# a fully expanded path of config.root | ||
# a fully expanded path of the file on the current runtime system | ||
filename = filename.gsub('./', roots.last) | ||
filename | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this sounds a bit dangerous or confusing to me... Our styleguide is to always use
"
for example.Perhaps allow passing a real
Regexp
if you want to match a regex, or a String if you do a simple match? Then the code can become even simpler, e.g.As a caller, I can define, e.g.