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

Comments

Projects
None yet
2 participants
@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

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Oct 23, 2013

Member

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

Member

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

This comment has been minimized.

Show comment
Hide comment
@senorprogrammer

senorprogrammer Oct 23, 2013

Thanks Thomas!

senorprogrammer commented Oct 23, 2013

Thanks Thomas!

enebo added a commit that referenced this issue Oct 24, 2013

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