From 4c9a4724d619d84ccafd7fd79a544e8d4cc63ae0 Mon Sep 17 00:00:00 2001 From: Cyril David Date: Fri, 22 Mar 2013 16:02:41 -0300 Subject: [PATCH] Fix bug related to dep in a rubygem context. So the release of 1.0.5 was supposed to make dep work as a single script, mainly to simplify our workflow. That introduced a couple of bugs related to rubygems wrapping the script as a bin script. --- bin/dep | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/dep b/bin/dep index 9be029d..d095b1d 100755 --- a/bin/dep +++ b/bin/dep @@ -146,7 +146,10 @@ private end end -if __FILE__ == $0 +# So originally, this was just $0 == __FILE__, but +# since rubygems wraps the actual bin file in a loader +# script, we have to instead rely on a different condition. +if File.basename($0) == "dep" Dep::CLI.file = File.join(Dir.pwd, ".gems") Dep::CLI.prerelease = false @@ -160,7 +163,11 @@ if __FILE__ == $0 end on("--help") do - IO.popen("less", "w") { |f| f.write(DATA.read) } + # I hate this, but since rubygems does a wrapper + # script, we can't use the elegance of DATA.read :( + help = File.read(__FILE__).split(/^__END__/)[1] + + IO.popen("less", "w") { |f| f.write(help) } exit end @@ -184,7 +191,6 @@ if __FILE__ == $0 end __END__ - DEP(1) NAME