Class: JSWebBuilder::BuildTask
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- JSWebBuilder::BuildTask
- Defined in:
- lib/js_web_builder.rb
Instance Attribute Summary collapse
-
#deps ⇒ Object
Task prerequisites.
-
#description ⇒ Object
Description of the build task.
-
#inputdirs ⇒ Object
The input directories, can be a single string or an array.
-
#name ⇒ Object
Name of build task.
-
#outdir ⇒ Object
The output directory (default is ‘.’).
-
#pattern ⇒ Object
Glob pattern to match input files.
Instance Method Summary collapse
-
#define ⇒ Object
Create the tasks defined by this task lib.
-
#initialize(name = :js_build) {|_self| ... } ⇒ BuildTask
constructor
Create a testing task.
-
#make_file_list ⇒ Object
define.
Constructor Details
#initialize(name = :js_build) {|_self| ... } ⇒ BuildTask
Create a testing task.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/js_web_builder.rb', line 28 def initialize(name=:js_build) @name = name @description = "Building/Concatenating the JS files" @pattern = '*.js' @deps = [] @outdir = "." @inputdirs = [] # don't look here! @file_list = [] yield self if block_given? define end |
Instance Attribute Details
#deps ⇒ Object
Task prerequisites.
19 20 21 |
# File 'lib/js_web_builder.rb', line 19 def deps @deps end |
#description ⇒ Object
Description of the build task. (default is ‘Building/Concatenating the JS files’)
13 14 15 |
# File 'lib/js_web_builder.rb', line 13 def description @description end |
#inputdirs ⇒ Object
The input directories, can be a single string or an array
25 26 27 |
# File 'lib/js_web_builder.rb', line 25 def inputdirs @inputdirs end |
#name ⇒ Object
Name of build task. (default is :js_build)
10 11 12 |
# File 'lib/js_web_builder.rb', line 10 def name @name end |
#outdir ⇒ Object
The output directory (default is ‘.’)
22 23 24 |
# File 'lib/js_web_builder.rb', line 22 def outdir @outdir end |
#pattern ⇒ Object
Glob pattern to match input files. (default is ‘*.js’)
16 17 18 |
# File 'lib/js_web_builder.rb', line 16 def pattern @pattern end |
Instance Method Details
#define ⇒ Object
Create the tasks defined by this task lib.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/js_web_builder.rb', line 44 def define desc @description task @name => Array(deps) do unless Dir.exist?(@outdir) Dir.mkdir(@outdir) end make_file_list @file_list.each do |target| js = target.execute target_file = File.join(@outdir,File.basename(target.file)) File.open(target_file, 'w') { |f| f.write(js) } end end self end |
#make_file_list ⇒ Object
define
61 62 63 64 65 66 67 |
# File 'lib/js_web_builder.rb', line 61 def make_file_list # :nodoc: @inputdirs.each do |dir| Rake::FileList[File.join(dir,@pattern)].each do |file| @file_list << TargetFile.new(:file => file) end end end |