Class: SdocAll::BaseTask

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

Direct Known Subclasses

MergeTask, Task

Instance Method Summary collapse

Instance Method Details

#clobber?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
28
29
30
# File 'lib/sdoc_all/task.rb', line 21

def clobber?
  full_doc_path = Base.docs_path + doc_path
  return true unless full_doc_path.exist?

  created_hash = config_hash_path.read rescue nil
  if created_hash != config_hash
    puts "#{title}: config changed, rebuilding".red
    return true
  end
end

#config_hashObject



5
6
7
# File 'lib/sdoc_all/task.rb', line 5

def config_hash
  Digest::SHA1.hexdigest(for_hash.inspect)
end

#config_hash_pathObject



9
10
11
# File 'lib/sdoc_all/task.rb', line 9

def config_hash_path
  Base.docs_path + doc_path + 'config.hash'
end

#created_rid_pathObject



13
14
15
# File 'lib/sdoc_all/task.rb', line 13

def created_rid_path
  Base.docs_path + doc_path + 'created.rid'
end

#last_build_timeObject



17
18
19
# File 'lib/sdoc_all/task.rb', line 17

def last_build_time
  Time.parse(created_rid_path.read) rescue nil
end

#run_if_clobberObject



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/sdoc_all/task.rb', line 32

def run_if_clobber
  if clobber?
    Base.remove_if_present(Base.docs_path + doc_path)
    yield
    if (Base.docs_path + doc_path).directory?
      config_hash_path.open('w') do |f|
        f.write(config_hash)
      end
    end
  end
end