Module: HelpHelpers

Defined in:
lib/mina/default.rb

Constant Summary collapse

SYSTEM_TASKS =
%w[help tasks init]

Instance Method Summary collapse

Instance Method Details

#get_tasks(&blk) ⇒ Object



63
64
65
# File 'lib/mina/default.rb', line 63

def get_tasks(&blk)
  Rake.application.tasks.select &blk
end


67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/mina/default.rb', line 67

def print_tasks(tasks, width=nil)
  name = Rake.application.name

  width ||= tasks.map { |t| t.name_with_args.length }.max || 10
  tasks.each do |t|
    if t.comment
      puts "  #{name} %-#{width}s   # %s" % [ t.name_with_args, t.comment ]
    else
      puts "  #{name} %s" % [ t.name_with_args ]
    end
  end
end

#show_task_help(options = {}) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/mina/default.rb', line 85

def show_task_help(options={})
  puts "Basic usage:"
  print_tasks system_tasks

  if top_tasks.any?
    puts "\nServer tasks:"
    print_tasks top_tasks
  end

  if sub_tasks.any? && options[:full]
    puts "\nMore tasks:"
    print_tasks sub_tasks
  end
end

#sub_tasksObject



83
# File 'lib/mina/default.rb', line 83

def sub_tasks()    get_tasks { |t| t.name.include?(':') }; end

#system_tasksObject



81
# File 'lib/mina/default.rb', line 81

def system_tasks() get_tasks { |t| SYSTEM_TASKS.include? t.name }; end

#top_tasksObject



82
# File 'lib/mina/default.rb', line 82

def top_tasks()    get_tasks { |t| ! t.name.include?(':') && t.comment && !system_tasks.include?(t) }; end