diff options
Diffstat (limited to 'rubygems_plugin.rb')
-rw-r--r-- | rubygems_plugin.rb | 107 |
1 files changed, 24 insertions, 83 deletions
diff --git a/rubygems_plugin.rb b/rubygems_plugin.rb index f003ae3..574c693 100644 --- a/rubygems_plugin.rb +++ b/rubygems_plugin.rb @@ -1,93 +1,34 @@ -[:pre_install, :pre_reset, :pre_uninstall, :post_build, :post_install, :post_reset, :post_uninstall].each do |meth| - block = Proc.new { puts 'This is ' + meth.to_s } - Gem.send(meth, &block) -end - -# class RDoc::RubygemsHook::Fedora < Rdoc::RubygemsHook -# def document options, destination -# -# end -# end -Gem.pre_install do - module RDoc - class RubygemsHook - alias generate_default generate - - def self.load_rdoc - return if @fedora_darkfish_version - - require_relative 'rdoc/generator/fedora_darkfish' - - @fedora_darkfish_version = Gem::Version.new '1.0.0' - end - - # def generate - # if Gem.rpmbuild? - # generate_fedora - # else - # generate_default - # end - # end - - def generate #_fedora - # Unfortunately the generator option for RDoc is not parametrized so - # this has been Copied from RDoc::RubygemsHook#generate - # and darkfish was replaced with fedora at the end of this method. - return if @spec.default_gem? - return unless @generate_ri or @generate_rdoc - - setup - - options = nil +# Make sure there are no `done_installing` hooks defined yet, so there is know +# starting position. +raise unless Gem.done_installing_hooks.empty? - args = @spec.rdoc_options - args.concat @spec.source_paths - args.concat @spec.extra_rdoc_files +# Initialize the RubyGems RDoc hook. +require "rubygems/rdoc" - case config_args = Gem.configuration[:rdoc] - when String then - args = args.concat config_args.split(' ') - when Array then - args = args.concat config_args - end +# Double check that there is only one `done_installing` hook loaded. +raise unless Gem.done_installing_hooks.size == 1 - delete_legacy_args args +# Subsequently drop the hook. +Gem.done_installing_hooks.pop - Dir.chdir @spec.full_gem_path do - options = ::RDoc::Options.new - options.default_title = "#{@spec.full_name} Documentation" - options.parse args - end +$LOAD_PATH.unshift __dir__ +require 'fedora_darkfish' - options.quiet = !Gem.configuration.really_verbose - - @rdoc = new_rdoc - @rdoc.options = options - - store = ::RDoc::Store.new - store.encoding = options.encoding - store.dry_run = options.dry_run - store.main = options.main_page - store.title = options.title - - @rdoc.store = store - - say "Parsing documentation for #{@spec.full_name}" - - Dir.chdir @spec.full_gem_path do - @rdoc.parse_files options.files - end +module Fedora + module RDoc + end +end - document 'ri', options, @ri_dir if - @generate_ri and (@force or not File.exist? @ri_dir) +class Fedora::RDoc::RubyGemsHook < RDoc::RubygemsHook + def self.generation_hook installer, specs + puts "FedoraRDoc.generation_hook - the `specs` could be modified to include additional `rdoc_options`" + super + end - document 'fedora', options, @rdoc_dir if - @generate_rdoc and (@force or not File.exist? @rdoc_dir) - end - end + def document generator, options, destination + generator = "fedora::#{generator}" + super end end -# Gem.post_install do -# puts require 'fedora_darkfish' -# end +Gem.done_installing(&Fedora::RDoc::RubyGemsHook.method(:generation_hook)) |