Sha256: a216aa299c6414f1c7c4655f92c1c32295243f3acd99b1dc7158546f5201e5af

Contents?: true

Size: 1.45 KB

Versions: 8

Compression:

Stored size: 1.45 KB

Contents

class SdocAll
  class Gems < Base
    def initialize(config)
      config ||= {}
      config = {:only => config} unless config.is_a?(Hash)

      @config = {
        :versions => config.delete(:versions).to_s.downcase,
        :only => config_only_option(config),
        :exclude => config_exclude_option(config),
      }

      raise_unknown_options_if_not_blank!(config)
    end

    def add_tasks(options = {})
      specs = config[:versions] == 'all' ? self.class.all_specs : self.class.latest_specs

      specs.sort_by!{ |spec| [spec.name.downcase, spec.sort_obj] }

      specs.delete_if{ |spec| !config[:only].include?(spec.name.downcase) } if config[:only]
      specs.delete_if{ |spec| config[:exclude].include?(spec.name.downcase) }

      specs.each do |spec|
        main = nil
        spec.rdoc_options.each_cons(2) do |options|
          main = options[1] if %w(--main -m).include?(options[0])
        end
        Base.add_task(
          :src_path => spec.full_gem_path,
          :doc_path => "gems.#{spec.full_name}",
          :paths => spec.require_paths + spec.extra_rdoc_files,
          :main => main,
          :title => "gems: #{spec.full_name}"
        )
      end
    end

    module ClassMethods
      def latest_specs
        Gem.source_index.latest_specs
      end

      def all_specs
        specs = []
        Gem.source_index.each do |_, spec|
          specs << spec
        end
        specs
      end
    end
    extend ClassMethods
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sdoc_all-0.2.0.8 lib/sdoc_all/gems.rb
sdoc_all-0.2.0.9 lib/sdoc_all/gems.rb
sdoc_all-0.2.0.10 lib/sdoc_all/gems.rb
sdoc_all-0.2.0.11 lib/sdoc_all/gems.rb
sdoc_all-0.2.1.0 lib/sdoc_all/gems.rb
sdoc_all-0.2.0.1 lib/sdoc_all/gems.rb
sdoc_all-0.2.0.6 lib/sdoc_all/gems.rb
sdoc_all-0.2.0.7 lib/sdoc_all/gems.rb