lib/appbundler/app.rb in appbundler-0.3.0 vs lib/appbundler/app.rb in appbundler-0.4.0

- old
+ new

@@ -105,47 +105,38 @@ @runtime_activate ||= begin statements = runtime_dep_specs.map {|s| %Q|gem "#{s.name}", "= #{s.version}"|} activate_code = "" activate_code << env_sanitizer << "\n" activate_code << statements.join("\n") << "\n" - activate_code << %Q|$:.unshift(File.expand_path("#{relative_app_lib_dir}", File.dirname(__FILE__)))\n| activate_code end end def binstub(bin_file) shebang + file_format_comment + runtime_activate + load_statement_for(bin_file) end def load_statement_for(bin_file) - "Kernel.load(File.expand_path('#{relative_bin_file(bin_file)}', File.dirname(__FILE__)))\n" + <<-E +bin_dir = File.dirname(__FILE__) +if File.symlink?(__FILE__) + bin_dir = File.dirname(File.readlink(__FILE__)) +end + +$:.unshift(File.expand_path("#{relative_app_lib_dir}", bin_dir)) +Kernel.load(File.expand_path('#{relative_bin_file(bin_file)}', bin_dir)) +E end def relative_bin_file(bin_file) bin_file_pathname = Pathname.new(bin_file) bindir_pathname = Pathname.new(target_bin_dir) bin_file_pathname.relative_path_from(bindir_pathname).to_s end def executables - spec_path = ["#{app_root}/#{name}-#{RUBY_PLATFORM}.gemspec", - "#{app_root}/#{name}.gemspec"].detect do |f| - File.exists?(f) - end - - if spec_path - spec = nil - Dir.chdir(app_root) do - spec = Gem::Specification::load(spec_path) - end - spec.executables.map do |e| - File.join(app_root, spec.bindir, e) - end - else - bin_dir_glob = File.join(app_root, "bin", "*") - Dir[bin_dir_glob] - end - + bin_dir_glob = File.join(app_root, "bin", "*") + Dir[bin_dir_glob] end def relative_app_lib_dir lib_dir_pathname = Pathname.new(app_lib_dir) bindir_pathname = Pathname.new(target_bin_dir)