Skip to content
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

Pathname.new(Dir.new('dir_name')) raises a TypeError #1154

Closed
senorprogrammer opened this issue Oct 23, 2013 · 2 comments
Closed

Pathname.new(Dir.new('dir_name')) raises a TypeError #1154

senorprogrammer opened this issue Oct 23, 2013 · 2 comments
Milestone

Comments

@senorprogrammer
Copy link

@senorprogrammer senorprogrammer commented Oct 23, 2013

Pathname.new should be able to accept a bare Dir.new instance as a param.

Expected Result

Returns a new instance of Pathname build from the Dir instance.

Actual Result

Raises a TypeError.

Steps to Reproduce

Test code (run from the Documents directory of a standard OS X user account).

d = Dir.new('Pictures')

pn = Pathname.new(d)

dir = pn.children.find { |child| child.directory? && child.basename.to_s == 'GoPro' }
puts dir.inspect

JRuby 1.7.5 result:

‼ ⚡ ruby dir_test.rb
TypeError: can't convert Dir into String
initialize at org/jruby/ext/pathname/RubyPathname.java:201
      (root) at dir_test.rb:7

MRI 1.9.3-p392 result:

✔ ⚡ ruby dir_test.rb
#<Pathname:Pictures/GoPro>

Work-around

pn = Pathname.new(d.path)
@enebo
Copy link
Member

@enebo enebo commented Oct 23, 2013

Ah simple missing method. Dir.to_path does not exist. I will add that.

@enebo enebo closed this in 02a9d82 Oct 23, 2013
@senorprogrammer
Copy link
Author

@senorprogrammer senorprogrammer commented Oct 23, 2013

Thanks Thomas!

enebo added a commit that referenced this issue Oct 24, 2013
…r missing to_path)
enebo added a commit that referenced this issue Oct 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants