| Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
|---|---|---|---|---|
| lib/buildr/core/help.rb | 119 | 73 | 33.61%
|
36.99%
|
Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.
1 # Licensed to the Apache Software Foundation (ASF) under one or more |
2 # contributor license agreements. See the NOTICE file distributed with this |
3 # work for additional information regarding copyright ownership. The ASF |
4 # licenses this file to you under the Apache License, Version 2.0 (the |
5 # "License"); you may not use this file except in compliance with the License. |
6 # You may obtain a copy of the License at |
7 # |
8 # http://www.apache.org/licenses/LICENSE-2.0 |
9 # |
10 # Unless required by applicable law or agreed to in writing, software |
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
13 # License for the specific language governing permissions and limitations under |
14 # the License. |
15 |
16 |
17 require 'buildr/core/common' |
18 require 'buildr/core/project' |
19 |
20 |
21 module Buildr |
22 |
23 module Help #:nodoc: |
24 class << self |
25 |
26 def <<(arg) |
27 if arg.respond_to?(:call) |
28 texters << arg |
29 else |
30 texters << lambda { arg } |
31 end |
32 end |
33 |
34 def to_s |
35 texters.map(&:call).join("\n") |
36 end |
37 |
38 protected |
39 def texters |
40 @texters ||= [] |
41 end |
42 |
43 end |
44 end |
45 |
46 class << self |
47 def help(&block) |
48 Help << block if block_given? |
49 Help |
50 end |
51 end |
52 |
53 end |
54 |
55 |
56 task 'help' do |
57 # Greeater. |
58 puts 'Usage:' |
59 puts ' buildr [-f rakefile] {options} targets...' |
60 puts |
61 |
62 # Show only the top-level projects. |
63 projects.reject(&:parent).tap do |top_level| |
64 unless top_level.empty? |
65 puts 'Top-level projects (buildr help:projects for full list):' |
66 width = [top_level.map(&:name).map(&:size), 20].flatten.max |
67 top_level.each do |project| |
68 puts project.comment.to_s.empty? ? project.name : (" %-#{width}s # %s" % [project.name, project.comment]) |
69 end |
70 puts |
71 end |
72 end |
73 |
74 # Show all the top-level tasks, excluding projects. |
75 puts 'Common tasks:' |
76 task('help:tasks').invoke |
77 puts |
78 puts 'For help on command line options:' |
79 puts ' buildr --help' |
80 puts Buildr.help.to_s |
81 end |
82 |
83 |
84 module Buildr |
85 |
86 # :call-seq: |
87 # help() { ... } |
88 # |
89 # Use this to enhance the help task, e.g. to print some important information about your build, |
90 # configuration options, build instructions, etc. |
91 def help(&block) |
92 Buildr.help << block |
93 end |
94 |
95 end |
96 |
97 |
98 namespace 'help' do |
99 |
100 desc 'List all projects defined by this buildfile' |
101 task 'projects' do |
102 width = projects.map(&:name).map(&:size).max |
103 projects.each do |project| |
104 puts project.comment.to_s.empty? ? " #{project.name}" : (" %-#{width}s # %s" % [project.name, project.comment]) |
105 end |
106 end |
107 |
108 desc 'List all tasks available from this buildfile' |
109 task 'tasks' do |
110 Buildr.application.tasks.select(&:comment).reject { |task| Project === task }.tap do |tasks| |
111 width = [tasks.map(&:name).map(&:size), 20].flatten.max |
112 tasks.each do |task| |
113 printf " %-#{width}s # %s\n", task.name, task.comment |
114 end |
115 puts |
116 end |
117 end |
118 |
119 end |
Generated on 2011-07-06 23:35:37 -0700 with rcov 0.9.8