ensure_bin_wrapper_for (GemManagement)

    # File lib/merb-core/tasks/gem_management.rb, line 280
      def ensure_bin_wrapper_for(gem_dir, bin_dir, *gems)
        options = gems.last.is_a?(Hash) ? gems.last : {}
        options[:no_minigems] ||= []
        if bin_dir && File.directory?(bin_dir)
          gems.each do |gem|
            if gemspec_path = Dir[File.join(gem_dir, 'specifications', "#{gem}-*.gemspec")].last
              spec = Gem::Specification.load(gemspec_path)
              enable_minigems = !options[:no_minigems].include?(spec.name)
              spec.executables.each do |exec|
                executable = File.join(bin_dir, exec)
                message "Writing executable wrapper #{executable}"
                File.open(executable, 'w', 0755) do |f|
                  f.write(executable_wrapper(spec, exec, enable_minigems))
                end
              end
            end
          end
        end
      end