Sha256: ad8b8279d6e9b5ff2af0ea8916f969aa9f9eb6dde7c98390b0135a1f3f035bd9
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
require 'digest/sha2' require 'shellwords' require 'sdoc' 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? || Marshal.load(#{name}_state_path.read) != #{name}_state rescue true end def write_#{name}_state #{name}_state_path.write(Marshal.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? in_progress_message %W[rm -r #{doc_dir}].shelljoin doc_dir.rmtree end build write_config_state @state = control_files_exist? ? :succeeded : :failed end rescue SystemExit @state = :failed end def succeeded? @state == :succeeded end def failed? @state == :failed end def loaded_gem_version(gem) Gem.loaded_specs[gem].version end def in_progress_message(message) if Progress.running? Progress.note = message else $stderr.puts message end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
doc-0.2.8 | lib/doc/base_task.rb |
doc-0.2.7 | lib/doc/base_task.rb |