class Doc::BaseTask

Attributes

config[R]
dir_name[R]
documentor[R]
title[R]

Public Class Methods

new(documentor, options) click to toggle source
# File lib/doc/base_task.rb, line 9
def initialize(documentor, options)
  @documentor = documentor
  @title = options[:title].to_s
  @dir_name = options[:dir_name].to_s
  doc_dir.touch if doc_dir.exist?
end
state_methods(name, data_code_for_state) click to toggle source
# File lib/doc/base_task.rb, line 20
    def self.state_methods(name, data_code_for_state)
      class_eval <<-RUBY, __FILE__, __LINE__
        def #{name}_state
          @#{name}_state ||= #{data_code_for_state}
        end
        def #{name}_state_path
          doc_dir / '.#{name}_state'
        end
        def #{name}_state_changed?
          !#{name}_state_path.exist? || YAML.load(#{name}_state_path.read) != #{name}_state
        rescue
          true
        end
        def write_#{name}_state
          #{name}_state_path.write(YAML.dump(#{name}_state))
        end
      RUBY
    end

Public Instance Methods

control_files_exist?() click to toggle source
# File lib/doc/base_task.rb, line 50
def control_files_exist?
  %w[created.rid index.html].all? do |name|
    (doc_dir / name).exist?
  end
end
doc_dir() click to toggle source
# File lib/doc/base_task.rb, line 16
def doc_dir
  documentor.docs_dir / dir_name
end
eql?(other) click to toggle source
# File lib/doc/base_task.rb, line 46
def eql?(other)
  config.eql?(other.config)
end
failed?() click to toggle source
# File lib/doc/base_task.rb, line 84
def failed?
  @state == :failed
end
hash() click to toggle source
# File lib/doc/base_task.rb, line 43
def hash
  config.hash
end
loaded_gem_version(gem) click to toggle source
# File lib/doc/base_task.rb, line 88
def loaded_gem_version(gem)
  Gem.loaded_specs[gem].version
end
run(force = false) click to toggle source
# File lib/doc/base_task.rb, line 61
def run(force = false)
  if force || run?
    if doc_dir.exist?
      $stderr.puts %W[rm -r #{doc_dir}].shelljoin
      doc_dir.rmtree
    end
    Progress.note = title
    build
    write_config_state
    @state = control_files_exist? ? :succeeded : :failed
  end
rescue SystemExit
  @state = :failed
end
run?() click to toggle source
# File lib/doc/base_task.rb, line 56
def run?
  config_state_changed? || !control_files_exist?
end
succeeded?() click to toggle source
# File lib/doc/base_task.rb, line 80
def succeeded?
  @state == :succeeded
end