Sha256: f5d2053a2fac798a3a3d9792047a4e840fcf18832939a24ef4eae1735e73e667

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 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 run
      tasks.with_progress('build').each(&:run)
      super(failed_state_changed?)
      write_failed_state if succeeded?
    end

    def build
      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

5 entries across 5 versions & 1 rubygems

Version Path
doc-0.2.3 lib/doc/merger.rb
doc-0.2.2 lib/doc/merger.rb
doc-0.2.1 lib/doc/merger.rb
doc-0.2.0 lib/doc/merger.rb
doc-0.1.0 lib/doc/merger.rb