necktie 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +174 -0
- data/bin/necktie +2 -1
- data/lib/necktie/files.rb +29 -0
- data/lib/necktie/rake.rb +127 -0
- data/lib/necktie/services.rb +11 -7
- data/lib/necktie.rb +4 -54
- data/necktie.gemspec +3 -3
- data/vendor/rake/CHANGES +477 -0
- data/vendor/rake/MIT-LICENSE +21 -0
- data/vendor/rake/README.rdoc +194 -0
- data/vendor/rake/Rakefile +421 -0
- data/vendor/rake/TODO +20 -0
- data/vendor/rake/bin/rake +31 -0
- data/vendor/rake/doc/command_line_usage.rdoc +102 -0
- data/vendor/rake/doc/example/Rakefile1 +38 -0
- data/vendor/rake/doc/example/Rakefile2 +35 -0
- data/vendor/rake/doc/example/a.c +6 -0
- data/vendor/rake/doc/example/b.c +6 -0
- data/vendor/rake/doc/example/main.c +11 -0
- data/vendor/rake/doc/glossary.rdoc +51 -0
- data/vendor/rake/doc/jamis.rb +591 -0
- data/vendor/rake/doc/proto_rake.rdoc +127 -0
- data/vendor/rake/doc/rake.1.gz +0 -0
- data/vendor/rake/doc/rakefile.rdoc +566 -0
- data/vendor/rake/doc/rational.rdoc +151 -0
- data/vendor/rake/doc/release_notes/rake-0.4.14.rdoc +23 -0
- data/vendor/rake/doc/release_notes/rake-0.4.15.rdoc +35 -0
- data/vendor/rake/doc/release_notes/rake-0.5.0.rdoc +53 -0
- data/vendor/rake/doc/release_notes/rake-0.5.3.rdoc +78 -0
- data/vendor/rake/doc/release_notes/rake-0.5.4.rdoc +46 -0
- data/vendor/rake/doc/release_notes/rake-0.6.0.rdoc +141 -0
- data/vendor/rake/doc/release_notes/rake-0.7.0.rdoc +119 -0
- data/vendor/rake/doc/release_notes/rake-0.7.1.rdoc +59 -0
- data/vendor/rake/doc/release_notes/rake-0.7.2.rdoc +121 -0
- data/vendor/rake/doc/release_notes/rake-0.7.3.rdoc +47 -0
- data/vendor/rake/doc/release_notes/rake-0.8.0.rdoc +114 -0
- data/vendor/rake/doc/release_notes/rake-0.8.2.rdoc +165 -0
- data/vendor/rake/doc/release_notes/rake-0.8.3.rdoc +112 -0
- data/vendor/rake/doc/release_notes/rake-0.8.4.rdoc +147 -0
- data/vendor/rake/doc/release_notes/rake-0.8.5.rdoc +53 -0
- data/vendor/rake/doc/release_notes/rake-0.8.6.rdoc +55 -0
- data/vendor/rake/doc/release_notes/rake-0.8.7.rdoc +55 -0
- data/vendor/rake/install.rb +88 -0
- data/vendor/rake/lib/rake/alt_system.rb +108 -0
- data/vendor/rake/lib/rake/application.rb +579 -0
- data/vendor/rake/lib/rake/classic_namespace.rb +9 -0
- data/vendor/rake/lib/rake/clean.rb +35 -0
- data/vendor/rake/lib/rake/cloneable.rb +25 -0
- data/vendor/rake/lib/rake/contrib/compositepublisher.rb +24 -0
- data/vendor/rake/lib/rake/contrib/ftptools.rb +153 -0
- data/vendor/rake/lib/rake/contrib/publisher.rb +75 -0
- data/vendor/rake/lib/rake/contrib/rubyforgepublisher.rb +18 -0
- data/vendor/rake/lib/rake/contrib/sshpublisher.rb +47 -0
- data/vendor/rake/lib/rake/contrib/sys.rb +209 -0
- data/vendor/rake/lib/rake/default_loader.rb +10 -0
- data/vendor/rake/lib/rake/dsl.rb +136 -0
- data/vendor/rake/lib/rake/early_time.rb +18 -0
- data/vendor/rake/lib/rake/environment.rb +40 -0
- data/vendor/rake/lib/rake/ext/module.rb +60 -0
- data/vendor/rake/lib/rake/ext/string.rb +165 -0
- data/vendor/rake/lib/rake/ext/time.rb +14 -0
- data/vendor/rake/lib/rake/file_creation_task.rb +24 -0
- data/vendor/rake/lib/rake/file_list.rb +395 -0
- data/vendor/rake/lib/rake/file_task.rb +47 -0
- data/vendor/rake/lib/rake/file_utils.rb +108 -0
- data/vendor/rake/lib/rake/gempackagetask.rb +97 -0
- data/vendor/rake/lib/rake/invocation_chain.rb +51 -0
- data/vendor/rake/lib/rake/invocation_exception_mixin.rb +16 -0
- data/vendor/rake/lib/rake/lib/project.rake +24 -0
- data/vendor/rake/lib/rake/loaders/makefile.rb +44 -0
- data/vendor/rake/lib/rake/multi_task.rb +16 -0
- data/vendor/rake/lib/rake/name_space.rb +25 -0
- data/vendor/rake/lib/rake/packagetask.rb +184 -0
- data/vendor/rake/lib/rake/psuedo_status.rb +24 -0
- data/vendor/rake/lib/rake/rake_file_utils.rb +133 -0
- data/vendor/rake/lib/rake/rake_module.rb +25 -0
- data/vendor/rake/lib/rake/rake_test_loader.rb +15 -0
- data/vendor/rake/lib/rake/rdoctask.rb +209 -0
- data/vendor/rake/lib/rake/ruby182_test_unit_fix.rb +25 -0
- data/vendor/rake/lib/rake/rule_recursion_overflow_error.rb +20 -0
- data/vendor/rake/lib/rake/runtest.rb +23 -0
- data/vendor/rake/lib/rake/task.rb +318 -0
- data/vendor/rake/lib/rake/task_argument_error.rb +7 -0
- data/vendor/rake/lib/rake/task_arguments.rb +78 -0
- data/vendor/rake/lib/rake/task_manager.rb +328 -0
- data/vendor/rake/lib/rake/tasklib.rb +24 -0
- data/vendor/rake/lib/rake/testtask.rb +175 -0
- data/vendor/rake/lib/rake/win32.rb +55 -0
- data/vendor/rake/lib/rake.rb +72 -0
- data/vendor/rake/rake.blurb +19 -0
- data/vendor/rake/rake.gemspec +214 -0
- data/vendor/rake/rakelib/extra.rake +8 -0
- data/vendor/rake/rakelib/publish.rake +22 -0
- data/vendor/rake/rakelib/rbx.rake +82 -0
- data/vendor/rake/rakelib/ruby19.rake +88 -0
- data/vendor/rake/rakelib/tags.rake +18 -0
- data/vendor/rake/test/capture_stdout.rb +26 -0
- data/vendor/rake/test/check_expansion.rb +5 -0
- data/vendor/rake/test/check_no_expansion.rb +5 -0
- data/vendor/rake/test/contrib/test_sys.rb +47 -0
- data/vendor/rake/test/data/chains/Rakefile +15 -0
- data/vendor/rake/test/data/comments/Rakefile +18 -0
- data/vendor/rake/test/data/default/Rakefile +19 -0
- data/vendor/rake/test/data/dryrun/Rakefile +22 -0
- data/vendor/rake/test/data/file_creation_task/Rakefile +33 -0
- data/vendor/rake/test/data/imports/Rakefile +19 -0
- data/vendor/rake/test/data/imports/deps.mf +1 -0
- data/vendor/rake/test/data/multidesc/Rakefile +17 -0
- data/vendor/rake/test/data/namespace/Rakefile +66 -0
- data/vendor/rake/test/data/nosearch/dummy +1 -0
- data/vendor/rake/test/data/rakelib/test1.rb +5 -0
- data/vendor/rake/test/data/rakelib/test2.rake +3 -0
- data/vendor/rake/test/data/rbext/rakefile.rb +3 -0
- data/vendor/rake/test/data/sample.mf +14 -0
- data/vendor/rake/test/data/statusreturn/Rakefile +8 -0
- data/vendor/rake/test/data/sys/sys1.rake +3 -0
- data/vendor/rake/test/data/unittest/Rakefile +1 -0
- data/vendor/rake/test/data/unittest/subdir/README +0 -0
- data/vendor/rake/test/data/verbose/Rakefile +34 -0
- data/vendor/rake/test/filecreation.rb +32 -0
- data/vendor/rake/test/functional/functional_test.rb +15 -0
- data/vendor/rake/test/functional/session_based_tests.rb +442 -0
- data/vendor/rake/test/in_environment.rb +32 -0
- data/vendor/rake/test/lib/application_test.rb +769 -0
- data/vendor/rake/test/lib/clean_test.rb +15 -0
- data/vendor/rake/test/lib/definitions_test.rb +85 -0
- data/vendor/rake/test/lib/dsl_test.rb +41 -0
- data/vendor/rake/test/lib/earlytime_test.rb +35 -0
- data/vendor/rake/test/lib/environment_test.rb +18 -0
- data/vendor/rake/test/lib/extension_test.rb +63 -0
- data/vendor/rake/test/lib/file_creation_task_test.rb +62 -0
- data/vendor/rake/test/lib/file_task_test.rb +143 -0
- data/vendor/rake/test/lib/filelist_test.rb +623 -0
- data/vendor/rake/test/lib/fileutils_test.rb +251 -0
- data/vendor/rake/test/lib/ftp_test.rb +59 -0
- data/vendor/rake/test/lib/invocation_chain_test.rb +81 -0
- data/vendor/rake/test/lib/makefile_loader_test.rb +26 -0
- data/vendor/rake/test/lib/multitask_test.rb +53 -0
- data/vendor/rake/test/lib/namespace_test.rb +55 -0
- data/vendor/rake/test/lib/package_task_test.rb +118 -0
- data/vendor/rake/test/lib/pathmap_test.rb +210 -0
- data/vendor/rake/test/lib/pseudo_status_test.rb +26 -0
- data/vendor/rake/test/lib/rake_test.rb +41 -0
- data/vendor/rake/test/lib/rdoc_task_test.rb +88 -0
- data/vendor/rake/test/lib/require_test.rb +35 -0
- data/vendor/rake/test/lib/rules_test.rb +349 -0
- data/vendor/rake/test/lib/task_arguments_test.rb +89 -0
- data/vendor/rake/test/lib/task_manager_test.rb +173 -0
- data/vendor/rake/test/lib/task_test.rb +376 -0
- data/vendor/rake/test/lib/tasklib_test.rb +12 -0
- data/vendor/rake/test/lib/test_task_test.rb +77 -0
- data/vendor/rake/test/lib/testtask_test.rb +49 -0
- data/vendor/rake/test/lib/top_level_functions_test.rb +86 -0
- data/vendor/rake/test/lib/win32_test.rb +72 -0
- data/vendor/rake/test/rake_test_setup.rb +24 -0
- data/vendor/rake/test/reqfile.rb +3 -0
- data/vendor/rake/test/reqfile2.rb +3 -0
- data/vendor/rake/test/reqfile3.rake +3 -0
- data/vendor/rake/test/shellcommand.rb +3 -0
- data/vendor/rake/test/test_helper.rb +13 -0
- metadata +212 -56
- /data/{rush → vendor/rush}/README.rdoc +0 -0
- /data/{rush → vendor/rush}/Rakefile +0 -0
- /data/{rush → vendor/rush}/VERSION +0 -0
- /data/{rush → vendor/rush}/bin/rush +0 -0
- /data/{rush → vendor/rush}/bin/rushd +0 -0
- /data/{rush → vendor/rush}/lib/rush/access.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/array_ext.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/box.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/commands.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/config.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/dir.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/embeddable_shell.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/entry.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/exceptions.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/file.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/find_by.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/fixnum_ext.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/head_tail.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/local.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/process.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/process_set.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/remote.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/search_results.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/server.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/shell.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/ssh_tunnel.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush/string_ext.rb +0 -0
- /data/{rush → vendor/rush}/lib/rush.rb +0 -0
- /data/{rush → vendor/rush}/rush.gemspec +0 -0
- /data/{rush → vendor/rush}/spec/access_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/array_ext_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/base.rb +0 -0
- /data/{rush → vendor/rush}/spec/box_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/commands_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/config_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/dir_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/embeddable_shell_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/entry_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/file_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/find_by_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/fixnum_ext_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/local_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/process_set_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/process_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/remote_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/rush_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/search_results_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/shell_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/ssh_tunnel_spec.rb +0 -0
- /data/{rush → vendor/rush}/spec/string_ext_spec.rb +0 -0
- /data/{session → vendor/session}/lib/session-2.4.0.rb +0 -0
- /data/{session → vendor/session}/lib/session.rb +0 -0
- /data/{session → vendor/session}/test/session.rb +0 -0
@@ -0,0 +1,318 @@
|
|
1
|
+
require 'rake/invocation_exception_mixin'
|
2
|
+
|
3
|
+
module Rake
|
4
|
+
|
5
|
+
# #########################################################################
|
6
|
+
# A Task is the basic unit of work in a Rakefile. Tasks have associated
|
7
|
+
# actions (possibly more than one) and a list of prerequisites. When
|
8
|
+
# invoked, a task will first ensure that all of its prerequisites have an
|
9
|
+
# opportunity to run and then it will execute its own actions.
|
10
|
+
#
|
11
|
+
# Tasks are not usually created directly using the new method, but rather
|
12
|
+
# use the +file+ and +task+ convenience methods.
|
13
|
+
#
|
14
|
+
class Task
|
15
|
+
# List of prerequisites for a task.
|
16
|
+
attr_reader :prerequisites
|
17
|
+
|
18
|
+
# List of actions attached to a task.
|
19
|
+
attr_reader :actions
|
20
|
+
|
21
|
+
# Application owning this task.
|
22
|
+
attr_accessor :application
|
23
|
+
|
24
|
+
# Comment for this task. Restricted to a single line of no more than 50
|
25
|
+
# characters.
|
26
|
+
attr_reader :comment
|
27
|
+
|
28
|
+
# Full text of the (possibly multi-line) comment.
|
29
|
+
attr_reader :full_comment
|
30
|
+
|
31
|
+
# Array of nested namespaces names used for task lookup by this task.
|
32
|
+
attr_reader :scope
|
33
|
+
|
34
|
+
# File/Line locations of each of the task definitions for this
|
35
|
+
# task (only valid if the task was defined with the detect
|
36
|
+
# location option set).
|
37
|
+
attr_reader :locations
|
38
|
+
|
39
|
+
# Return task name
|
40
|
+
def to_s
|
41
|
+
name
|
42
|
+
end
|
43
|
+
|
44
|
+
def inspect
|
45
|
+
"<#{self.class} #{name} => [#{prerequisites.join(', ')}]>"
|
46
|
+
end
|
47
|
+
|
48
|
+
# List of sources for task.
|
49
|
+
attr_writer :sources
|
50
|
+
def sources
|
51
|
+
@sources ||= []
|
52
|
+
end
|
53
|
+
|
54
|
+
# First source from a rule (nil if no sources)
|
55
|
+
def source
|
56
|
+
@sources.first if defined?(@sources)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Create a task named +task_name+ with no actions or prerequisites. Use
|
60
|
+
# +enhance+ to add actions and prerequisites.
|
61
|
+
def initialize(task_name, app)
|
62
|
+
@name = task_name.to_s
|
63
|
+
@prerequisites = []
|
64
|
+
@actions = []
|
65
|
+
@already_invoked = false
|
66
|
+
@full_comment = nil
|
67
|
+
@comment = nil
|
68
|
+
@lock = Monitor.new
|
69
|
+
@application = app
|
70
|
+
@scope = app.current_scope
|
71
|
+
@arg_names = nil
|
72
|
+
@locations = []
|
73
|
+
end
|
74
|
+
|
75
|
+
# Enhance a task with prerequisites or actions. Returns self.
|
76
|
+
def enhance(deps=nil, &block)
|
77
|
+
@prerequisites |= deps if deps
|
78
|
+
@actions << block if block_given?
|
79
|
+
self
|
80
|
+
end
|
81
|
+
|
82
|
+
# Name of the task, including any namespace qualifiers.
|
83
|
+
def name
|
84
|
+
@name.to_s
|
85
|
+
end
|
86
|
+
|
87
|
+
# Name of task with argument list description.
|
88
|
+
def name_with_args # :nodoc:
|
89
|
+
if arg_description
|
90
|
+
"#{name}#{arg_description}"
|
91
|
+
else
|
92
|
+
name
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Argument description (nil if none).
|
97
|
+
def arg_description # :nodoc:
|
98
|
+
@arg_names ? "[#{(arg_names || []).join(',')}]" : nil
|
99
|
+
end
|
100
|
+
|
101
|
+
# Name of arguments for this task.
|
102
|
+
def arg_names
|
103
|
+
@arg_names || []
|
104
|
+
end
|
105
|
+
|
106
|
+
# Reenable the task, allowing its tasks to be executed if the task
|
107
|
+
# is invoked again.
|
108
|
+
def reenable
|
109
|
+
@already_invoked = false
|
110
|
+
end
|
111
|
+
|
112
|
+
# Clear the existing prerequisites and actions of a rake task.
|
113
|
+
def clear
|
114
|
+
clear_prerequisites
|
115
|
+
clear_actions
|
116
|
+
self
|
117
|
+
end
|
118
|
+
|
119
|
+
# Clear the existing prerequisites of a rake task.
|
120
|
+
def clear_prerequisites
|
121
|
+
prerequisites.clear
|
122
|
+
self
|
123
|
+
end
|
124
|
+
|
125
|
+
# Clear the existing actions on a rake task.
|
126
|
+
def clear_actions
|
127
|
+
actions.clear
|
128
|
+
self
|
129
|
+
end
|
130
|
+
|
131
|
+
# Invoke the task if it is needed. Prerequites are invoked first.
|
132
|
+
def invoke(*args)
|
133
|
+
task_args = TaskArguments.new(arg_names, args)
|
134
|
+
invoke_with_call_chain(task_args, InvocationChain::EMPTY)
|
135
|
+
end
|
136
|
+
|
137
|
+
# Same as invoke, but explicitly pass a call chain to detect
|
138
|
+
# circular dependencies.
|
139
|
+
def invoke_with_call_chain(task_args, invocation_chain) # :nodoc:
|
140
|
+
new_chain = InvocationChain.append(self, invocation_chain)
|
141
|
+
@lock.synchronize do
|
142
|
+
if application.options.trace
|
143
|
+
puts "** Invoke #{name} #{format_trace_flags}"
|
144
|
+
end
|
145
|
+
return if @already_invoked
|
146
|
+
@already_invoked = true
|
147
|
+
invoke_prerequisites(task_args, new_chain)
|
148
|
+
execute(task_args) if needed?
|
149
|
+
end
|
150
|
+
rescue Exception => ex
|
151
|
+
add_chain_to(ex, new_chain)
|
152
|
+
raise ex
|
153
|
+
end
|
154
|
+
protected :invoke_with_call_chain
|
155
|
+
|
156
|
+
def add_chain_to(exception, new_chain)
|
157
|
+
exception.extend(InvocationExceptionMixin) unless exception.respond_to?(:chain)
|
158
|
+
exception.chain = new_chain if exception.chain.nil?
|
159
|
+
end
|
160
|
+
private :add_chain_to
|
161
|
+
|
162
|
+
# Invoke all the prerequisites of a task.
|
163
|
+
def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
|
164
|
+
@prerequisites.each { |n|
|
165
|
+
prereq = application[n, @scope]
|
166
|
+
prereq_args = task_args.new_scope(prereq.arg_names)
|
167
|
+
prereq.invoke_with_call_chain(prereq_args, invocation_chain)
|
168
|
+
}
|
169
|
+
end
|
170
|
+
|
171
|
+
# Format the trace flags for display.
|
172
|
+
def format_trace_flags
|
173
|
+
flags = []
|
174
|
+
flags << "first_time" unless @already_invoked
|
175
|
+
flags << "not_needed" unless needed?
|
176
|
+
flags.empty? ? "" : "(" + flags.join(", ") + ")"
|
177
|
+
end
|
178
|
+
private :format_trace_flags
|
179
|
+
|
180
|
+
# Execute the actions associated with this task.
|
181
|
+
def execute(args=nil)
|
182
|
+
args ||= EMPTY_TASK_ARGS
|
183
|
+
if application.options.dryrun
|
184
|
+
puts "** Execute (dry run) #{name}"
|
185
|
+
return
|
186
|
+
end
|
187
|
+
if application.options.trace
|
188
|
+
puts "** Execute #{name}"
|
189
|
+
end
|
190
|
+
application.enhance_with_matching_rule(name) if @actions.empty?
|
191
|
+
@actions.each do |act|
|
192
|
+
case act.arity
|
193
|
+
when 1
|
194
|
+
act.call(self)
|
195
|
+
else
|
196
|
+
act.call(self, args)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# Is this task needed?
|
202
|
+
def needed?
|
203
|
+
true
|
204
|
+
end
|
205
|
+
|
206
|
+
# Timestamp for this task. Basic tasks return the current time for their
|
207
|
+
# time stamp. Other tasks can be more sophisticated.
|
208
|
+
def timestamp
|
209
|
+
@prerequisites.collect { |p| application[p, @scope].timestamp }.max || Time.now
|
210
|
+
end
|
211
|
+
|
212
|
+
# Add a description to the task. The description can consist of an option
|
213
|
+
# argument list (enclosed brackets) and an optional comment.
|
214
|
+
def add_description(description)
|
215
|
+
return if ! description
|
216
|
+
comment = description.strip
|
217
|
+
add_comment(comment) if comment && ! comment.empty?
|
218
|
+
end
|
219
|
+
|
220
|
+
# Writing to the comment attribute is the same as adding a description.
|
221
|
+
def comment=(description)
|
222
|
+
add_description(description)
|
223
|
+
end
|
224
|
+
|
225
|
+
# Add a comment to the task. If a comment alread exists, separate
|
226
|
+
# the new comment with " / ".
|
227
|
+
def add_comment(comment)
|
228
|
+
if @full_comment
|
229
|
+
@full_comment << " / "
|
230
|
+
else
|
231
|
+
@full_comment = ''
|
232
|
+
end
|
233
|
+
@full_comment << comment
|
234
|
+
if @full_comment =~ /\A([^.]+?\.)( |$)/
|
235
|
+
@comment = $1
|
236
|
+
else
|
237
|
+
@comment = @full_comment
|
238
|
+
end
|
239
|
+
end
|
240
|
+
private :add_comment
|
241
|
+
|
242
|
+
# Set the names of the arguments for this task. +args+ should be
|
243
|
+
# an array of symbols, one for each argument name.
|
244
|
+
def set_arg_names(args)
|
245
|
+
@arg_names = args.map { |a| a.to_sym }
|
246
|
+
end
|
247
|
+
|
248
|
+
# Return a string describing the internal state of a task. Useful for
|
249
|
+
# debugging.
|
250
|
+
def investigation
|
251
|
+
result = "------------------------------\n"
|
252
|
+
result << "Investigating #{name}\n"
|
253
|
+
result << "class: #{self.class}\n"
|
254
|
+
result << "task needed: #{needed?}\n"
|
255
|
+
result << "timestamp: #{timestamp}\n"
|
256
|
+
result << "pre-requisites: \n"
|
257
|
+
prereqs = @prerequisites.collect {|name| application[name, @scope]}
|
258
|
+
prereqs.sort! {|a,b| a.timestamp <=> b.timestamp}
|
259
|
+
prereqs.each do |p|
|
260
|
+
result << "--#{p.name} (#{p.timestamp})\n"
|
261
|
+
end
|
262
|
+
latest_prereq = @prerequisites.collect{|n| application[n, @scope].timestamp}.max
|
263
|
+
result << "latest-prerequisite time: #{latest_prereq}\n"
|
264
|
+
result << "................................\n\n"
|
265
|
+
return result
|
266
|
+
end
|
267
|
+
|
268
|
+
# ----------------------------------------------------------------
|
269
|
+
# Rake Module Methods
|
270
|
+
#
|
271
|
+
class << self
|
272
|
+
|
273
|
+
# Clear the task list. This cause rake to immediately forget all the
|
274
|
+
# tasks that have been assigned. (Normally used in the unit tests.)
|
275
|
+
def clear
|
276
|
+
Rake.application.clear
|
277
|
+
end
|
278
|
+
|
279
|
+
# List of all defined tasks.
|
280
|
+
def tasks
|
281
|
+
Rake.application.tasks
|
282
|
+
end
|
283
|
+
|
284
|
+
# Return a task with the given name. If the task is not currently
|
285
|
+
# known, try to synthesize one from the defined rules. If no rules are
|
286
|
+
# found, but an existing file matches the task name, assume it is a file
|
287
|
+
# task with no dependencies or actions.
|
288
|
+
def [](task_name)
|
289
|
+
Rake.application[task_name]
|
290
|
+
end
|
291
|
+
|
292
|
+
# TRUE if the task name is already defined.
|
293
|
+
def task_defined?(task_name)
|
294
|
+
Rake.application.lookup(task_name) != nil
|
295
|
+
end
|
296
|
+
|
297
|
+
# Define a task given +args+ and an option block. If a rule with the
|
298
|
+
# given name already exists, the prerequisites and actions are added to
|
299
|
+
# the existing task. Returns the defined task.
|
300
|
+
def define_task(*args, &block)
|
301
|
+
Rake.application.define_task(self, *args, &block)
|
302
|
+
end
|
303
|
+
|
304
|
+
# Define a rule for synthesizing tasks.
|
305
|
+
def create_rule(*args, &block)
|
306
|
+
Rake.application.create_rule(*args, &block)
|
307
|
+
end
|
308
|
+
|
309
|
+
# Apply the scope to the task name according to the rules for
|
310
|
+
# this kind of task. Generic tasks will accept the scope as
|
311
|
+
# part of the name.
|
312
|
+
def scope_name(scope, task_name)
|
313
|
+
(scope + [task_name]).join(':')
|
314
|
+
end
|
315
|
+
|
316
|
+
end # class << Rake::Task
|
317
|
+
end # class Rake::Task
|
318
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Rake
|
2
|
+
|
3
|
+
####################################################################
|
4
|
+
# TaskAguments manage the arguments passed to a task.
|
5
|
+
#
|
6
|
+
class TaskArguments
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
attr_reader :names
|
10
|
+
|
11
|
+
# Create a TaskArgument object with a list of named arguments
|
12
|
+
# (given by :names) and a set of associated values (given by
|
13
|
+
# :values). :parent is the parent argument object.
|
14
|
+
def initialize(names, values, parent=nil)
|
15
|
+
@names = names
|
16
|
+
@parent = parent
|
17
|
+
@hash = {}
|
18
|
+
names.each_with_index { |name, i|
|
19
|
+
@hash[name.to_sym] = values[i] unless values[i].nil?
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
# Create a new argument scope using the prerequisite argument
|
24
|
+
# names.
|
25
|
+
def new_scope(names)
|
26
|
+
values = names.collect { |n| self[n] }
|
27
|
+
self.class.new(names, values, self)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Find an argument value by name or index.
|
31
|
+
def [](index)
|
32
|
+
lookup(index.to_sym)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Specify a hash of default values for task arguments. Use the
|
36
|
+
# defaults only if there is no specific value for the given
|
37
|
+
# argument.
|
38
|
+
def with_defaults(defaults)
|
39
|
+
@hash = defaults.merge(@hash)
|
40
|
+
end
|
41
|
+
|
42
|
+
def each(&block)
|
43
|
+
@hash.each(&block)
|
44
|
+
end
|
45
|
+
|
46
|
+
def method_missing(sym, *args, &block)
|
47
|
+
lookup(sym.to_sym)
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_hash
|
51
|
+
@hash
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
@hash.inspect
|
56
|
+
end
|
57
|
+
|
58
|
+
def inspect
|
59
|
+
to_s
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
|
64
|
+
def lookup(name)
|
65
|
+
if @hash.has_key?(name)
|
66
|
+
@hash[name]
|
67
|
+
elsif ENV.has_key?(name.to_s)
|
68
|
+
ENV[name.to_s]
|
69
|
+
elsif ENV.has_key?(name.to_s.upcase)
|
70
|
+
ENV[name.to_s.upcase]
|
71
|
+
elsif @parent
|
72
|
+
@parent.lookup(name)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
EMPTY_TASK_ARGS = TaskArguments.new([], [])
|
78
|
+
end
|