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

Constructor Details

#initialize(options = {}) ⇒ MergeTask

Returns a new instance of MergeTask.



108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/sdoc_all/task.rb', line 108

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.



107
108
109
# File 'lib/sdoc_all/task.rb', line 107

def doc_path
  @doc_path
end

#tasksObject (readonly)

Returns the value of attribute tasks.



107
108
109
# File 'lib/sdoc_all/task.rb', line 107

def tasks
  @tasks
end

#titleObject (readonly)

Returns the value of attribute title.



107
108
109
# File 'lib/sdoc_all/task.rb', line 107

def title
  @title
end

#titlesObject (readonly)

Returns the value of attribute titles.



107
108
109
# File 'lib/sdoc_all/task.rb', line 107

def titles
  @titles
end

Instance Method Details

#clobber?Boolean

Returns:

  • (Boolean)


150
151
152
153
154
# File 'lib/sdoc_all/task.rb', line 150

def clobber?
  return true if super

  tasks.any?(&:clobber?)
end

#for_hashObject



146
147
148
# File 'lib/sdoc_all/task.rb', line 146

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

#occupied_doc_pathesObject



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

def occupied_doc_pathes
  [doc_path, parts_path]
end

#parts_pathObject



122
123
124
# File 'lib/sdoc_all/task.rb', line 122

def parts_path
  "#{doc_path}_parts"
end

#run(options = {}) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/sdoc_all/task.rb', line 126

def run(options = {})
  p clobber?
  if clobber?
    Base.remove_if_present(Base.docs_path + doc_path)

    tasks.each do |task|
      task.run(options)
    end

    Dir.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