Sha256: 912ac3e15658022c56672a4c166645c26bba73d43aa208f2f69c9eb9ef7d7b54
Contents?: true
Size: 1.99 KB
Versions: 1
Compression:
Stored size: 1.99 KB
Contents
require 'digest/sha2' require 'shellwords' require 'sdoc' require 'yaml' module Doc class BaseTask attr_reader :documentor, :title, :dir_name, :config 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 def doc_dir documentor.docs_dir / dir_name end 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 state_methods :config, <<-RUBY @config RUBY def hash config.hash end def eql?(other) config.eql?(other.config) end def control_files_exist? %w[created.rid index.html].all? do |name| (doc_dir / name).exist? end end def run? config_state_changed? || !control_files_exist? end abstract_method :build 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 def symlink_to(path) (path / doc_dir.basename).make_symlink(doc_dir.relative_path_from(path)) end def succeeded? @state == :succeeded end def failed? @state == :failed end def loaded_gem_version(gem) Gem.loaded_specs[gem].version end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
doc-0.5.0 | lib/doc/base_task.rb |