lib/appbundler/app.rb in appbundler-0.4.0 vs lib/appbundler/app.rb in appbundler-0.5.0
- old
+ new
@@ -114,17 +114,18 @@
def binstub(bin_file)
shebang + file_format_comment + runtime_activate + load_statement_for(bin_file)
end
def load_statement_for(bin_file)
+ name, version = app_spec.name, app_spec.version
+ bin_basename = File.basename(bin_file)
<<-E
-bin_dir = File.dirname(__FILE__)
-if File.symlink?(__FILE__)
- bin_dir = File.dirname(File.readlink(__FILE__))
-end
+gem "#{name}", "= #{version}"
-$:.unshift(File.expand_path("#{relative_app_lib_dir}", bin_dir))
-Kernel.load(File.expand_path('#{relative_bin_file(bin_file)}', bin_dir))
+spec = Gem::Specification.find_by_name("#{name}", "= #{version}")
+bin_file = spec.bin_file("#{bin_basename}")
+
+Kernel.load(bin_file)
E
end
def relative_bin_file(bin_file)
bin_file_pathname = Pathname.new(bin_file)