Skip to content

Implement the basename() function to stdlib. #274

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

Closed
wants to merge 2 commits into from
Closed

Implement the basename() function to stdlib. #274

wants to merge 2 commits into from

Conversation

drq883
Copy link

@drq883 drq883 commented Jun 17, 2014

I always wondered why basename() wasn't in stdlib since dirname() was.

We ended up writing our own locallib module to implement the basename() function to keep from having to write inline ruby code. We were working on a nfs mounting module and wanted to default to the basename of the filer's exported path to be the default mount point. This new function gives us that feature.

This is just a modification of the dirname.rb file where all references to dirname were replaced with basename. This same implementation in our locallib works fine.

I have also updated the spec/ files to behave as I think they should.

Thanks for considering this new function.

dnlmengs pushed a commit to dnlmengs/puppetlabs-stdlib that referenced this pull request Sep 24, 2014
…lement the basename() function to stdlib.): now admits removing file extension, the ruby File.basename() way
@queeno
Copy link

queeno commented Oct 1, 2014

👍

) do |arguments|

raise(Puppet::ParseError, "basename(): Wrong number of arguments " +
"given (#{arguments.size} for 1)") if arguments.size < 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you get rid of this, and instead use :arity, please?
see, #249

@drq883
Copy link
Author

drq883 commented Oct 2, 2014

I just committed what you requested to drq883/puppetlabs-stdlib.

@underscorgan
Copy link
Contributor

@drq883 thank you for the contribution, and sorry it took so long to get back to you, but this is a very popular feature request and I prefer the implementation for #368 so I'm going to close this as it duplicates that request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants