Class: UberDoc::Generate

Inherits:
Task
  • Object
show all
Defined in:
lib/uberdoc/tasks/generate_task.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Task

#initialize, known_tasks

Constructor Details

This class inherits a constructor from UberDoc::Task

Class Method Details

.should_run?(options) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/uberdoc/tasks/generate_task.rb', line 7

def self.should_run?(options)
    options.generate
end

Instance Method Details

#performObject

should_run?



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/uberdoc/tasks/generate_task.rb', line 11

def perform

    # Check if there already a doc file in this directory
    file_path = File.join(Dir.pwd, "UberDocMe")

    if File.exists?(file_path)
        puts "There is already an UberDocMe file in this directory"
        return
    end

    # Write the template file
    base_uberdocme = File.open(UberDoc::Util::template_file_path('UberDocMe.Base'), 'rb') { |file| file.read }
    File.open(file_path, 'w') {|f| f.write(base_uberdocme) }

end