module Hoe::Deps

Deps plugin for hoe.

Tasks Provided:

check_extra_deps

Install missing dependencies.

deps:email

Print a contact list for gems dependent on this gem

deps:fetch

Fetch all the dependent gems of this gem into tarballs

deps:list

List all the dependent gems of this gem

Constants

GEMURL

The main rubygems repository.

Public Instance Methods

define_deps_tasks() click to toggle source

Define tasks for plugin.

# File lib/hoe/deps.rb, line 23
def define_deps_tasks
  namespace :deps do
    desc "List all the dependent gems of this gem"
    task :list do
      deps_list_task
    end

    desc "Print a contact list for gems dependent on this gem"
    task :email do
      deps_email_task
    end

    desc "Fetch all the dependent gems of this gem into tarballs"
    task :fetch do
      deps_fetch_task
    end
  end

  desc "Install missing dependencies."
  task :check_extra_deps do
    check_extra_deps_task
  end

  desc "Install missing plugins."
  task :install_plugins do
    install_missing_plugins
  end
end
dependent_upon(name) click to toggle source

Return all the dependencies on the named rubygem.

# File lib/hoe/deps.rb, line 217
def dependent_upon name
  get_latest_gems.find_all { |gem|
    gem.dependencies.any? { |dep| dep.name == name }
  }
end
get_gems_by_name() click to toggle source

Return a hash of the latest rubygems keyed by name.

# File lib/hoe/deps.rb, line 188
def get_gems_by_name
  @@by_name ||= Hash[*get_latest_gems.map { |gem|
                       [gem.name, gem, gem.full_name, gem]
                     }.flatten]
end
get_latest_gems() click to toggle source

Return the latest rubygems.

# File lib/hoe/deps.rb, line 181
def get_latest_gems
  @@cache ||= Hash[*get_source_index.flatten].values
end
get_source_index() click to toggle source

Return the rubygems source index.

# File lib/hoe/deps.rb, line 148
def get_source_index
  @@index ||= nil

  return @@index if @@index

  dump = unless File.exist? ".source_index" then
           warn "Fetching full index and caching. This can take a while."
           url = GEMURL + "Marshal.#{Gem.marshal_version}.Z"
           dump = Gem::RemoteFetcher.fetcher.fetch_path url
           dump = Gem.inflate dump

           warn "stripping index to latest gems"
           ary = Marshal.load dump

           h = {}
           Hash[ary].values.sort.each { |spec| h[spec.name] = spec }
           ary = h.map { |_, v| [v.full_name, v] }

           dump = Marshal.dump ary

           open ".source_index", "wb" do |io| io.write dump end

           dump
         else
           open ".source_index", "rb" do |io| io.read end
         end

  @@index = Marshal.load dump
end
install_missing_plugins(plugins = Hoe.bad_plugins) click to toggle source

Installs plugins that aren’t currently installed

# File lib/hoe/deps.rb, line 197
def install_missing_plugins plugins = Hoe.bad_plugins
  version = ">= 0"

  plugins.each do |name|
    dash_name = name.to_s.gsub "_", "-"

    next if have_gem?("hoe-#{name}") or
              have_gem?(name) or
              have_gem?(dash_name)

    install_gem("hoe-#{name}", version, false) or
      install_gem(name, version, false) or
      install_gem(dash_name, version, false) or
      warn "could not install gem for #{name} plugin"
  end
end