ruby / ruby/rake

Pathname#pathmap is still (erronously) documented

Open
#348 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.5k
Forks
650
Avg merge
6m
Merged PRs (30d)
3

Description

The rake docs here still indicate that Pathname#pathmap exists. However, it was removed by #130

It would be easy enough to fix the docs. But perhaps a different question is, why was this removed from Pathname?

I expected the following to work, but instead got NoMethodError: undefined method 'pathmap' for #<Pathname

array_of_pathnames.each do |p|
  directory p.pathmap('%d')
end

Surely it's easy enough to use directory p.dirname. However, I have a lambda that is also used as a rule dep (to ensure the parent directories are created). I was hoping to use the same lambda when iterating over the array_of_pathnames.

dirname = ->(f) { f.pathmap('%d') }

pathnames.map(&dirname).map(&method(:directory))

rule %r{pattern} => dirname do |t|
  # stuff
end

As long as we're extending String, I'd expect the same extensions to work on the "more domain appropriate" Pathname.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked Pathname documentation and review issue #130 to understand why Pathname#pathmap was removed. Check the reported Ruby examples against the current API, then determine whether the documentation should only remove the method or also explain the supported alternative. Done means the docs accurately reflect the available Pathname methods and the scope is resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
build-system
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.