install_gem_from_source (GemManagement)

    # File lib/merb-core/tasks/gem_management.rb, line 126
      def install_gem_from_source(source_dir, *args)
        installed_gems = []
        opts = args.last.is_a?(Hash) ? args.pop : {}
        Dir.chdir(source_dir) do
          gem_name     = args[0] || File.basename(source_dir)
          gem_pkg_dir  = File.join(source_dir, 'pkg')
          gem_pkg_glob = File.join(gem_pkg_dir, "#{gem_name}-*.gem")
          skip_gems    = opts.delete(:skip) || []

          # Cleanup what's already there
          clobber(source_dir)
          FileUtils.mkdir_p(gem_pkg_dir) unless File.directory?(gem_pkg_dir)

          # Recursively process all gem packages within the source dir
          skip_gems << gem_name
          packages = package_all(source_dir, skip_gems)

          if packages.length == 1
            # The are no subpackages for the main package
            refresh = [gem_name]
          else
            # Gather all packages into the top-level pkg directory
            packages.each do |pkg|
              FileUtils.copy_entry(pkg, File.join(gem_pkg_dir, File.basename(pkg)))
            end

            # Finally package the main gem - without clobbering the already copied pkgs
            package(source_dir, false)

            # Gather subgems to refresh during installation of the main gem
            refresh = packages.map do |pkg|
              File.basename(pkg, '.gem')[/^(.*?)-([\d\.]+)$/, 1] rescue nil
            end.compact

            # Install subgems explicitly even if ignore_dependencies is set
            if opts[:ignore_dependencies]
              refresh.each do |name|
                gem_pkg = Dir[File.join(gem_pkg_dir, "#{name}-*.gem")][0]
                install_pkg(gem_pkg, opts)
              end
            end
          end

          ensure_bin_wrapper_for(opts[:install_dir], opts[:bin_dir], *installed_gems)

          # Finally install the main gem
          if install_pkg(Dir[gem_pkg_glob][0], opts.merge(:refresh => refresh))
            installed_gems = refresh
          else
            installed_gems = []
          end
        end
        installed_gems
      end