Class: Doc::Merger
Instance Attribute Summary collapse
Attributes inherited from BaseTask
#config, #dir_name, #documentor, #title
Instance Method Summary
collapse
Methods inherited from BaseTask
#control_files_exist?, #doc_dir, #eql?, #failed?, #hash, #loaded_gem_version, #run?, state_methods, #succeeded?
Constructor Details
#initialize(documentor, options) ⇒ Merger
Returns a new instance of Merger.
4
5
6
7
8
9
10
11
12
13
|
# File 'lib/doc/merger.rb', line 4
def initialize(documentor, options)
super
@tasks = options[:tasks].uniq
@config = {
:title => title,
:dir_name => dir_name,
:tasks => tasks.map(&:config),
}
end
|
Instance Attribute Details
#tasks ⇒ Object
Returns the value of attribute tasks.
3
4
5
|
# File 'lib/doc/merger.rb', line 3
def tasks
@tasks
end
|
Instance Method Details
#build ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/doc/merger.rb', line 32
def build
$stderr.puts "Merging #{title}"
succeded_tasks = tasks.reject(&:failed?)
task_titles = succeded_tasks.map{ |task| task.title.gsub(',', '_') }
task_urls = succeded_tasks.map{ |task| task_url(task) }
cmd = Command.new('sdoc-merge', "_#{loaded_gem_version('sdoc')}_")
cmd.add "--op=#{doc_dir}"
cmd.add "--title=#{title}"
cmd.add "--names=#{task_titles.join(',')}"
cmd.add "--urls=#{task_urls.join(' ')}"
cmd.add *succeded_tasks.map(&:doc_dir)
cmd.run
end
|
#progress_message ⇒ Object
19
20
21
|
# File 'lib/doc/merger.rb', line 19
def progress_message
title
end
|
#run ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/doc/merger.rb', line 23
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
|
#symlink_children_to(path) ⇒ Object
53
54
55
56
57
|
# File 'lib/doc/merger.rb', line 53
def symlink_children_to(path)
tasks.reject(&:failed?).each do |task|
task.symlink_to(path)
end
end
|
#symlink_to(path) ⇒ Object
59
60
61
62
|
# File 'lib/doc/merger.rb', line 59
def symlink_to(path)
symlink_children_to(path)
super
end
|
#task_url(task) ⇒ Object
49
50
51
|
# File 'lib/doc/merger.rb', line 49
def task_url(task)
task.doc_dir.relative_path_from(doc_dir)
end
|