-
Notifications
You must be signed in to change notification settings - Fork 583
adds new parser called is_absolute_path #553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@logicminds rather than duplicating the code, i'd now switch validate_absolute_path to calling this function. |
@igalic I gave that some serious thought but I just assumed the performance would be better without having to call a puppet function from within a puppet function multiple times. This might be negligible if using once but it folks are using this 50 times across their entire catalog, a 100 ms delay adds up pretty quick. I have no benchmarks to back up my claim though. |
so, we have a loop candidates.each do |path|
function_is_absolute_path([path]) or raise Puppet::ParseError, ("#{path.inspect} is not an absolute path.")
end now, a compiler that cannot figure out that this is a hot-spot, and needs optimization probably isn't worth its money, even if it's free. imo, it's probably cheaper to keep the code in one parser function, than wonder why down the road the two of them are behaving differently. however: i'm not an stdlib maintainer, so lets wait what @puppetlabs has to say! |
Well that is definitely much cleaner. |
This PR is only adding a function while most of this conversation is about altering an existing function to rely on a yet to be included function. We need to have a new PR for altering the validation_absolute_path and keep discussing there instead of here. |
@logicminds I agree with @igalic. For maintainability purposes it would be best to use DRY principles. Also, I'd be a proponent of coupling the refactoring of |
ok I'll refactor soon and rebase. |
* is_absolute_path returns boolean true if the given path is absolute, returns false otherwise. * works for windows and unix
e72e310
to
1da820e
Compare
@bmjen this is ready to go. |
@logicminds Thanks! |
adds new parser called is_absolute_path
I really like the validate_absolute_path function and needed similar functionality to perform conditional logic on installer locations so I created the is_absolute_path function.
This uses the same code as the validate function but only accepts one argument and also returns a value.