Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Fix for Issue 16 "Wrong::Config.read_here_or_higher can't handle absolute paths" #31

wants to merge 1 commit into


None yet
3 participants

I'm not the most experienced Rubyist, but I've been enjoying using Wrong, and thought I'd have a go at fixing this issue since most of my hobbyprogramming is done on windows.

My approach is simply to check whether a path is absolute or relative by calling File.file? on it.

@Ehyeh-Asher-Ehyeh Ehyeh-Asher-Ehyeh Fix for Issue 16 "Wrong::Config.read_here_or_higher can't handle abso…
…lute paths". Checks whether path is absolute or relative simply by calling File.file? on the path.

amatsuda commented Jul 23, 2014

Why not just File.expand_path(file, dir) ?

@Ehyeh-Asher-Ehyeh File.expand_path works similar:

> File.expand_path("/abs", '/root')
=> "/abs"
> File.expand_path("rel", '/root')
=> "/rel/root"
> File.expand_path("../rel", '/root/subroot')
=> "/root/rel"

You can replace your get_file_path by File.expand.

File.read File.expand(file, dir)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment