Class: Woro::TaskHelper
- Inherits:
-
Object
- Object
- Woro::TaskHelper
- Defined in:
- lib/woro/task_helper.rb
Class Method Summary collapse
-
.extract_description(task_content) ⇒ Object
Extract description from gist’s data content string.
- .print_task_list(tasks) ⇒ Object
-
.read_template_file ⇒ String
Read the rake task template.
-
.woro_task_files(directory, &block) ⇒ Object
Perform an action over all files within the woro task directory.
Class Method Details
.extract_description(task_content) ⇒ Object
Extract description from gist’s data content string.
- String
-
description string
28 29 30 |
# File 'lib/woro/task_helper.rb', line 28 def extract_description(task_content) task_content.match(/desc ['"]([a-zA-Z0-9\s]*)['"]/)[1] end |
.print_task_list(tasks) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/woro/task_helper.rb', line 6 def print_task_list(tasks) width ||= tasks.map { |t| t.name_with_args.length }.max || 10 tasks.each do |t| puts " %-#{width}s # %s" % [ t.name_with_args, t.comment ] end end |
.read_template_file ⇒ String
Read the rake task template
34 35 36 |
# File 'lib/woro/task_helper.rb', line 34 def read_template_file File.read(File.join(File.dirname(__FILE__), 'templates','task.rake') ) end |
.woro_task_files(directory, &block) ⇒ Object
Perform an action over all files within the woro task directory
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/woro/task_helper.rb', line 14 def woro_task_files(directory, &block) tasks = [] Dir.foreach(directory) do |file_name| if file_name.include? '.rake' data = File.read(File.join(directory, file_name)) tasks << yield(file_name, data) end end tasks end |