GIF87a; 404

MY HEART




Upload:

Command:

diavoloapp@3.138.137.25: ~ $
require 'rubygems/command'

class Gem::Commands::WhichCommand < Gem::Command
  def initialize
    super 'which', 'Find the location of a library file you can require',
          :search_gems_first => false, :show_all => false

    add_option '-a', '--[no-]all', 'show all matching files' do |show_all, options|
      options[:show_all] = show_all
    end

    add_option '-g', '--[no-]gems-first',
               'search gems before non-gems' do |gems_first, options|
      options[:search_gems_first] = gems_first
    end
  end

  def arguments # :nodoc:
    "FILE          name of file to find"
  end

  def defaults_str # :nodoc:
    "--no-gems-first --no-all"
  end

  def execute
    found = false

    options[:args].each do |arg|
      arg = arg.sub(/#{Regexp.union(*Gem.suffixes)}$/, '')
      dirs = $LOAD_PATH

      spec = Gem::Specification.find_by_path arg

      if spec then
        if options[:search_gems_first] then
          dirs = gem_paths(spec) + $LOAD_PATH
        else
          dirs = $LOAD_PATH + gem_paths(spec)
        end
      end

      # TODO: this is totally redundant and stupid
      paths = find_paths arg, dirs

      if paths.empty? then
        alert_error "Can't find ruby library file or shared library #{arg}"
      else
        say paths
        found = true
      end
    end

    terminate_interaction 1 unless found
  end

  def find_paths(package_name, dirs)
    result = []

    dirs.each do |dir|
      Gem.suffixes.each do |ext|
        full_path = File.join dir, "#{package_name}#{ext}"
        if File.exist? full_path and not File.directory? full_path then
          result << full_path
          return result unless options[:show_all]
        end
      end
    end

    result
  end

  def gem_paths(spec)
    spec.require_paths.collect { |d| File.join spec.full_gem_path, d }
  end

  def usage # :nodoc:
    "#{program_name} FILE [FILE ...]"
  end

end


Filemanager

Name Type Size Permission Actions
build_command.rb File 859 B 0644
cert_command.rb File 6.41 KB 0644
check_command.rb File 2.01 KB 0644
cleanup_command.rb File 3.82 KB 0644
contents_command.rb File 3.12 KB 0644
dependency_command.rb File 3.89 KB 0644
environment_command.rb File 4.16 KB 0644
fetch_command.rb File 1.49 KB 0644
generate_index_command.rb File 2.52 KB 0644
help_command.rb File 4.56 KB 0644
install_command.rb File 5.45 KB 0644
list_command.rb File 696 B 0644
lock_command.rb File 2.67 KB 0644
mirror_command.rb File 395 B 0644
outdated_command.rb File 866 B 0644
owner_command.rb File 1.9 KB 0644
pristine_command.rb File 3.66 KB 0644
push_command.rb File 2.02 KB 0644
query_command.rb File 8.11 KB 0644
rdoc_command.rb File 2.31 KB 0644
search_command.rb File 616 B 0644
server_command.rb File 2.35 KB 0644
setup_command.rb File 12.94 KB 0644
sources_command.rb File 3.62 KB 0644
specification_command.rb File 2.93 KB 0644
stale_command.rb File 704 B 0644
uninstall_command.rb File 3.07 KB 0644
unpack_command.rb File 4.06 KB 0644
update_command.rb File 5.8 KB 0644
which_command.rb File 1.87 KB 0644
yank_command.rb File 2.4 KB 0644