Class: SdocAll::Gems

Inherits:
Base
  • Object
show all
Extended by:
ClassMethods
Defined in:
lib/sdoc_all/parts/gems.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary

Constants included from Base::ClassMethods

Base::ClassMethods::BASE_PATH, Base::ClassMethods::DOCS_PATH, Base::ClassMethods::PUBLIC_PATH

Instance Attribute Summary

Attributes inherited from Base

#config

Instance Method Summary collapse

Methods included from ClassMethods

all_specs, latest_specs

Methods included from Base::ClassMethods

#add_merge_task, #add_task, #base_path, #clear, #docs_path, #entries, #inherited, #public_path, #remove_if_present, #short_name, #sources_path, #subclasses, #system, #tasks, #to_document, #used_sources, #with_env

Constructor Details

#initialize(raw_config) ⇒ Gems

Returns a new instance of Gems.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/sdoc_all/parts/gems.rb', line 3

def initialize(raw_config)
  raw_config ||= {}
  raw_config = {:only => raw_config} unless raw_config.is_a?(Hash)

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

  errors = []
  gem_names = unfiltered_specs.map{ |spec| spec.name.downcase }
  [:only, :exclude].each do |option|
    if config[option]
      config[option].each do |gem_name|
        errors << "#{option} #{gem_name} does not match any gem" unless gem_names.include?(gem_name)
      end
    end
  end
  unless errors.empty?
    raise ConfigError.new(errors.join("\n"))
  end

  if filtered_specs.empty?
    options = config.map do |option, values|
      "#{option} => #{Array(values).join(',')}" if values.present?
    end.compact.join(', ')
    raise ConfigError.new("no gems matches #{options}")
  end

  raise_unknown_options_if_not_blank!(raw_config)
end

Instance Method Details

#add_tasks(options = {}) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/sdoc_all/parts/gems.rb', line 36

def add_tasks(options = {})
  specs = filtered_specs.sort_by{ |spec| [spec.name.downcase, spec.sort_obj] }
  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