I believe `File.realpath` is only available in ruby >= 1.9 and not in 1.8.7. We can probably just use 

    File.readlink(link_name)

here or use the realpath of the `Pathname` class

    require 'pathname'
    [...]
    Pathname.new(link_name).realpath.to_s

Also if the link name does not match the regex you will get an error

    NoMethodError: undefined method `[]' for nil:NilClass