This repository has been archived by the owner on Sep 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 153
Add a more robust cookbook_base_path helper to the API #520
Merged
Conversation
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
lib/foodcritic/api.rb
Outdated
# get list of items in the dir and intersect with metadata array. | ||
# until we get an interfact (we have a metadata) walk up the dir structure | ||
until (Dir.entries(file) & %w(metadata.rb metadata.json)).any? | ||
file = File.absolute_path(File.dirname(file.to_s)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can skip the File.absolute_path
since we've run File.expand_path
on its descendant
lib/foodcritic/api.rb
Outdated
# | ||
# @author Tim Smith - [email protected] | ||
# @since 11.0 | ||
# @param file [String, Pathname] relative or absolute path to a file in the cookbook |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it probably works with a Pathname
but we should test to be sure ;-)
josephholsten
approved these changes
Mar 16, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just needs tests. Which will require exciting mocking!
These aren’t used by core Foodcritic and will be removed in the next release. This will allow anyone using them internally to know so they can pull them into their own rules. Signed-off-by: Tim Smith <[email protected]>
Signed-off-by: Tim Smith <[email protected]>
Signed-off-by: Tim Smith <[email protected]>
Signed-off-by: Tim Smith <[email protected]>
Signed-off-by: Tim Smith <[email protected]>
Signed-off-by: Tim Smith <[email protected]>
tas50
force-pushed
the
path_helper
branch
2 times, most recently
from
March 21, 2017 06:44
48c53f4
to
b30c2d4
Compare
Signed-off-by: Tim Smith <[email protected]>
I can’t find a reason why we need this Signed-off-by: Tim Smith <[email protected]>
tas50
force-pushed
the
path_helper
branch
3 times, most recently
from
March 21, 2017 06:56
9c6b303
to
27904bb
Compare
tas50
changed the title
WIP: Add a more robust base path helper to the API
Add a more robust base path helper to the API
Mar 21, 2017
@josephholsten Fixed specs that haven't been running for a super long time and added a test of a few different scenarios |
Signed-off-by: Tim Smith <[email protected]>
¡super approval! |
tas50
changed the title
Add a more robust base path helper to the API
Add a more robust cookbook_base_path helper to the API
Mar 29, 2017
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The current methods of discovering the base path are flawed as they fail if the cookbook is within a directory named the same as a cookbook directory (templates, recipes, files, etc). This gives us an actual helper for finding the base path of a cookbook. We can migrate existing api calls and rules over to this in the future.
Signed-off-by: Tim Smith [email protected]