Sha256: 3253806734623cf1c2651c7c56942e130c3fa1304af969b91d14e97b803dd147

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

module Doc
  class Merger < BaseTask
    attr_reader :tasks
    def initialize(documentor, options)
      super
      @tasks = options[:tasks].uniq

      @config = {
        :title => title,
        :dir_name => dir_name,
        :tasks => tasks.map(&:config),
      }
    end

    state_methods :failed, <<-RUBY
      tasks.map(&:failed?)
    RUBY

    def progress_message
      title
    end

    def run
      tasks.with_progress(progress_message).each do |task|
        Progress.note = task.dir_name
        task.run
      end
      super(failed_state_changed? || tasks.any?(&:succeeded?))
      write_failed_state if succeeded?
    end

    def build
      in_progress_message "Merging #{title}"

      succeded_tasks = tasks.reject(&:failed?)
      task_titles = succeded_tasks.map{ |task| task.title.gsub(',', '_') }.join(',')
      task_urls = succeded_tasks.map{ |task| task.doc_dir.relative_path_from(doc_dir).to_s.strip }.join(' ')

      cmd = Command.new('sdoc-merge', "_#{loaded_gem_version('sdoc')}_")
      cmd.add "--op=#{doc_dir}"
      cmd.add "--title=#{title}"
      cmd.add "--names=#{task_titles}"
      cmd.add "--urls=#{task_urls}"
      cmd.add *succeded_tasks.map(&:doc_dir)

      cmd.run
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
doc-0.2.8 lib/doc/merger.rb
doc-0.2.7 lib/doc/merger.rb