class RDoc::Data

Constants

VERSION

Public Class Methods

new(options) click to toggle source
# File lib/rdoc/data.rb, line 49
def initialize options
  data_dir = Gem.datadir('') || File.expand_path('../../../data', __FILE__)
  version = RUBY_VERSION.dup[0..-3] # strip the patch-level
  @source = File.join data_dir, version

  unless File.exist? @source then
    supported = Dir[File.join(data_dir, '*')].map do |dir|
      dir.sub File.join(data_dir, ''), ''
    end.sort

    raise Error, "Your ruby version #{version} is not supported, " \
                 "only #{supported.join ', '}"
  end

  @destination = RDoc::RI::Paths.system_dir
end
process_args(args) click to toggle source
# File lib/rdoc/data.rb, line 13
def self.process_args args
  options = {}

  if args.empty? or args.include? '--help' or
     not args.include? '--install' then
    puts "Usage: #{$0} [--verbose] [--dryrun] --install"
    puts
    puts "Installs updated ruby #{RUBY_VERSION} system ri data (core + stdlib)"
    exit 1
  elsif args.include? '--verbose' then
    options[:verbose] = true
  elsif args.include? '--dryrun' then
    options[:dryrun] = true
  end

  options
end
run(argv = ARGV) click to toggle source
# File lib/rdoc/data.rb, line 31
def self.run argv = ARGV
  options = process_args argv

  data = new options

  if options[:dryrun] then
    data.extend FileUtils::DryRun
  elsif options[:verbose] then
    data.extend FileUtils::Verbose
  else
    data.extend FileUtils
  end

  data.run
rescue Error => e
  abort e.message
end

Public Instance Methods

run() click to toggle source
# File lib/rdoc/data.rb, line 66
def run
  cd @source do
    files = Dir[File.join('**', '*.ri{d,}')]

    files.each do |file|
      dest_file = File.join @destination, file
      dest_dir = File.dirname dest_file

      mkdir_p dest_dir
      install file, dest_dir, :mode => 0644
    end
  end
end