Class: SdocAll::MergeTask

Inherits:
BaseTask show all
Defined in:
lib/sdoc_all/task.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseTask

#config_hash, #config_hash_path, #created_rid_path, #last_build_time, #run_if_clobber

Constructor Details

#initialize(options = {}) ⇒ MergeTask

Returns a new instance of MergeTask.



118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/sdoc_all/task.rb', line 118

def initialize(options = {})
  @doc_path = options[:doc_path]
  @title = options[:title]
  @tasks = options[:tasks_options].map do |task_options|
    Task.new(task_options.merge(
      :doc_path => "#{parts_path}/#{task_options[:doc_path]}",
      :title => "#{title}: #{task_options[:title]}"
    ))
  end
  @titles = options[:tasks_options].map do |task_options|
    task_options[:title]
  end
end

Instance Attribute Details

#doc_pathObject (readonly)

Returns the value of attribute doc_path.



117
118
119
# File 'lib/sdoc_all/task.rb', line 117

def doc_path
  @doc_path
end

#tasksObject (readonly)

Returns the value of attribute tasks.



117
118
119
# File 'lib/sdoc_all/task.rb', line 117

def tasks
  @tasks
end

#titleObject (readonly)

Returns the value of attribute title.



117
118
119
# File 'lib/sdoc_all/task.rb', line 117

def title
  @title
end

#titlesObject (readonly)

Returns the value of attribute titles.



117
118
119
# File 'lib/sdoc_all/task.rb', line 117

def titles
  @titles
end

Instance Method Details

#clobber?Boolean

Returns:

  • (Boolean)


159
160
161
162
163
# File 'lib/sdoc_all/task.rb', line 159

def clobber?
  return true if super

  tasks.any?(&:clobber?)
end

#for_hashObject



155
156
157
# File 'lib/sdoc_all/task.rb', line 155

def for_hash
  [doc_path.to_s, title, tasks.map(&:for_hash)]
end

#occupied_doc_pathesObject



165
166
167
# File 'lib/sdoc_all/task.rb', line 165

def occupied_doc_pathes
  [doc_path, parts_path]
end

#parts_pathObject



132
133
134
# File 'lib/sdoc_all/task.rb', line 132

def parts_path
  "#{doc_path}_parts"
end

#run(options = {}) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/sdoc_all/task.rb', line 136

def run(options = {})
  run_if_clobber do
    tasks.each do |task|
      Progress.start(task.title) do
        task.run(options)
      end
    end

    Base.chdir(Base.docs_path) do
      cmd = %w(sdoc-merge)
      cmd << '-o' << Base.docs_path + doc_path
      cmd << '-t' << title
      cmd << '-n' << titles.join(',')
      cmd << '-u' << tasks.map{ |task| "../#{task.doc_path}" }.join(' ')
      Base.system(*cmd + tasks.map(&:doc_path))
    end
  end
end