Class: SdocAll::Task
Instance Attribute Summary collapse
-
#doc_path ⇒ Object
readonly
Returns the value of attribute doc_path.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#main ⇒ Object
readonly
Returns the value of attribute main.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
-
#src_path ⇒ Object
readonly
Returns the value of attribute src_path.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #clobber? ⇒ Boolean
- #for_hash ⇒ Object
-
#initialize(options = {}) ⇒ Task
constructor
A new instance of Task.
- #occupied_doc_pathes ⇒ Object
- #run(options = {}) ⇒ Object
Methods inherited from BaseTask
#config_hash, #config_hash_path, #created_rid_path, #last_build_time
Constructor Details
#initialize(options = {}) ⇒ Task
Returns a new instance of Task.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/sdoc_all/task.rb', line 32 def initialize( = {}) [:paths] ||= [] [/^readme$/i, /^readme\.(?:txt|rdoc|markdown)$/i, /^readme\./i].each do |readme_r| [:main] ||= [:paths].grep(readme_r).first end @src_path = Pathname.new([:src_path]). @doc_path = [:doc_path] @paths = [:paths] @main = [:main] @title = [:title] @index = [:index] end |
Instance Attribute Details
#doc_path ⇒ Object (readonly)
Returns the value of attribute doc_path.
31 32 33 |
# File 'lib/sdoc_all/task.rb', line 31 def doc_path @doc_path end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
31 32 33 |
# File 'lib/sdoc_all/task.rb', line 31 def index @index end |
#main ⇒ Object (readonly)
Returns the value of attribute main.
31 32 33 |
# File 'lib/sdoc_all/task.rb', line 31 def main @main end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
31 32 33 |
# File 'lib/sdoc_all/task.rb', line 31 def paths @paths end |
#src_path ⇒ Object (readonly)
Returns the value of attribute src_path.
31 32 33 |
# File 'lib/sdoc_all/task.rb', line 31 def src_path @src_path end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
31 32 33 |
# File 'lib/sdoc_all/task.rb', line 31 def title @title end |
Instance Method Details
#clobber? ⇒ Boolean
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/sdoc_all/task.rb', line 86 def clobber? return true if super latest = [src_path.mtime, src_path.ctime].max created = last_build_time if created && latest < created src_path.find do |path| Find.prune if path.directory? && path.basename.to_s[0] == ?. latest = [latest, path.mtime, path.ctime].max break unless latest < created end end created.nil? || latest >= created end |
#for_hash ⇒ Object
80 81 82 83 84 |
# File 'lib/sdoc_all/task.rb', line 80 def for_hash for_hash = [src_path.to_s, doc_path.to_s, paths, main, title, last_build_time] for_hash << index if index for_hash end |
#occupied_doc_pathes ⇒ Object
101 102 103 |
# File 'lib/sdoc_all/task.rb', line 101 def occupied_doc_pathes [doc_path] end |
#run(options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/sdoc_all/task.rb', line 46 def run( = {}) if clobber? Base.remove_if_present(Base.docs_path + doc_path) cmd = %w(sdoc) cmd << '-o' << Base.docs_path + doc_path cmd << '-t' << title cmd << '-T' << 'direct' if src_path.directory? Dir.chdir(src_path) do cmd << '-m' << main if main Base.system(*cmd + paths) end if index custom_index_dir_name = 'custom_index' custom_index_path = Base.docs_path + doc_path + custom_index_dir_name Base.remove_if_present(custom_index_path) FileUtils.cp_r(index, custom_index_path) index_html = Base.docs_path + doc_path + 'index.html' index_html.write index_html.read.sub(/(<frame src=")[^"]+(" name="docwin" \/>)/, "\\1#{custom_index_dir_name}/index.html\\2") end else Base.system(*cmd + [src_path]) end if (Base.docs_path + doc_path).directory? config_hash_path.open('w') do |f| f.write(config_hash) end end end end |