Class: Rake::CompileTask
Overview
Create a task that runs a set of tests.
Example:
Rake::CompileTask.new do |t|
t.files = FileList['lib/**/*.rb']
t.verbose = true
end
Example:
rake compile # regular compilation
Instance Attribute Summary (collapse)
-
- (Object) name
Name of test task.
-
- (Object) verbose
Whether to list each file that is compiled or not (defaults is false).
Instance Method Summary (collapse)
-
- (Object) define
Create the tasks defined by this task lib.
-
- (Object) files=(list)
Explicitly define the list of test files to be compiled.
-
- (CompileTask) initialize(name = :compile) {|_self| ... }
constructor
Create a testing task.
Methods inherited from TaskLib
Methods included from Cloneable
Constructor Details
- (CompileTask) initialize(name = :compile) {|_self| ... }
Create a testing task.
39 40 41 42 43 44 45 |
# File 'lib/rake/compiletask.rb', line 39 def initialize(name=:compile) @name = name @files = [] @verbose = false yield self if block_given? define end |
Instance Attribute Details
- (Object) name
Name of test task. (default is :compile)
26 27 28 |
# File 'lib/rake/compiletask.rb', line 26 def name @name end |
- (Object) verbose
Whether to list each file that is compiled or not (defaults is false)
29 30 31 |
# File 'lib/rake/compiletask.rb', line 29 def verbose @verbose end |
Instance Method Details
- (Object) define
Create the tasks defined by this task lib.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rake/compiletask.rb', line 48 def define desc "Compile files" + (@name==:compile ? "" : " for #{@name}") task @name do start_time = Time.now number_of_files = 0 @files.each do |source| compiled_name = "#{source}o" if File.exists?(compiled_name) && (File.mtime(compiled_name) > File.mtime(source)) next end if @verbose $stdout.puts compiled_name number_of_files += 1 end MacRuby::Compiler.compile_file(source) end if @verbose compile_time = Time.now - start_time $stdout.puts "Finished compile in %.6fs, %.6s files/s" % [compile_time, number_of_files / compile_time] end end self end |
- (Object) files=(list)
Explicitly define the list of test files to be compiled. list is expected to be an array of file names (a FileList is acceptable).
34 35 36 |
# File 'lib/rake/compiletask.rb', line 34 def files=(list) @files = list end |