Class: Doc::BaseTask
- Inherits:
-
Object
- Object
- Doc::BaseTask
- Defined in:
- lib/doc/base_task.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#dir_name ⇒ Object
readonly
Returns the value of attribute dir_name.
-
#documentor ⇒ Object
readonly
Returns the value of attribute documentor.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #control_files_exist? ⇒ Boolean
- #doc_dir ⇒ Object
- #eql?(other) ⇒ Boolean
- #failed? ⇒ Boolean
- #hash ⇒ Object
-
#initialize(documentor, options) ⇒ BaseTask
constructor
A new instance of BaseTask.
- #loaded_gem_version(gem) ⇒ Object
- #run(force = false) ⇒ Object
- #run? ⇒ Boolean
- #succeeded? ⇒ Boolean
Constructor Details
#initialize(documentor, options) ⇒ BaseTask
Returns a new instance of BaseTask.
7 8 9 10 11 12 |
# File 'lib/doc/base_task.rb', line 7 def initialize(documentor, ) @documentor = documentor @title = [:title].to_s @dir_name = [:dir_name].to_s doc_dir.touch if doc_dir.exist? end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/doc/base_task.rb', line 6 def config @config end |
#dir_name ⇒ Object (readonly)
Returns the value of attribute dir_name.
6 7 8 |
# File 'lib/doc/base_task.rb', line 6 def dir_name @dir_name end |
#documentor ⇒ Object (readonly)
Returns the value of attribute documentor.
6 7 8 |
# File 'lib/doc/base_task.rb', line 6 def documentor @documentor end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/doc/base_task.rb', line 6 def title @title end |
Class Method Details
.state_methods(name, data_code_for_state) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/doc/base_task.rb', line 18 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 |
Instance Method Details
#control_files_exist? ⇒ Boolean
47 48 49 50 51 |
# File 'lib/doc/base_task.rb', line 47 def control_files_exist? %w[created.rid index.html].all? do |name| (doc_dir / name).exist? end end |
#doc_dir ⇒ Object
14 15 16 |
# File 'lib/doc/base_task.rb', line 14 def doc_dir documentor.docs_dir / dir_name end |
#eql?(other) ⇒ Boolean
43 44 45 |
# File 'lib/doc/base_task.rb', line 43 def eql?(other) config.eql?(other.config) end |
#failed? ⇒ Boolean
73 74 75 |
# File 'lib/doc/base_task.rb', line 73 def failed? @state == :failed end |
#hash ⇒ Object
40 41 42 |
# File 'lib/doc/base_task.rb', line 40 def hash config.hash end |
#loaded_gem_version(gem) ⇒ Object
77 78 79 |
# File 'lib/doc/base_task.rb', line 77 def loaded_gem_version(gem) Gem.loaded_specs[gem].version end |
#run(force = false) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/doc/base_task.rb', line 58 def run(force = false) if force || run? doc_dir.rmtree_verbose if doc_dir.exist? build write_config_state @state = control_files_exist? ? :succeeded : :failed end rescue SystemExit @state = :failed end |
#run? ⇒ Boolean
53 54 55 |
# File 'lib/doc/base_task.rb', line 53 def run? config_state_changed? || !control_files_exist? end |
#succeeded? ⇒ Boolean
69 70 71 |
# File 'lib/doc/base_task.rb', line 69 def succeeded? @state == :succeeded end |