Class: Musicality::Tasks::FileRaker
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Musicality::Tasks::FileRaker
- Defined in:
- lib/musicality/project/file_raker.rb
Defined Under Namespace
Classes: Audio, LilyPond, MIDI, SuperCollider, Visual, YAML
Instance Attribute Summary collapse
-
#file_ext ⇒ Object
readonly
Returns the value of attribute file_ext.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#subdirs ⇒ Object
readonly
Returns the value of attribute subdirs.
-
#task_name ⇒ Object
readonly
Returns the value of attribute task_name.
Instance Method Summary collapse
-
#initialize(parent_filelist, task_name, file_ext, &rule_block) ⇒ FileRaker
constructor
A new instance of FileRaker.
Constructor Details
#initialize(parent_filelist, task_name, file_ext, &rule_block) ⇒ FileRaker
Returns a new instance of FileRaker.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/musicality/project/file_raker.rb', line 7 def initialize parent_filelist, task_name, file_ext, &rule_block raise ArgumentError, "parent filelist is empty" if parent_filelist.empty? raise ArgumentError, "no rule block given" unless block_given? parent_exts = parent_filelist.map {|str| File.extname(str) }.uniq raise ArgumentError, "multiple file extensions in parent filelist: #{parent_filelist}" unless parent_exts.one? @task_name, @file_ext = task_name, file_ext @subdirs = parent_filelist.pathmap("#{Project::OUT_DIR}/%n") @files = parent_filelist.pathmap("#{Project::OUT_DIR}/%n/%n#{file_ext}") directory Project::OUT_DIR @subdirs.each { |subdir| directory subdir } task task_name => [Project::OUT_DIR] + @subdirs + @files find_parent_file = lambda do |f| parent_filelist.detect do |f2| File.basename(f2.ext("")) == File.basename(f.ext("")) end end rule file_ext => find_parent_file do |t| rule_block.call(t) end end |
Instance Attribute Details
#file_ext ⇒ Object (readonly)
Returns the value of attribute file_ext.
5 6 7 |
# File 'lib/musicality/project/file_raker.rb', line 5 def file_ext @file_ext end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
5 6 7 |
# File 'lib/musicality/project/file_raker.rb', line 5 def files @files end |
#subdirs ⇒ Object (readonly)
Returns the value of attribute subdirs.
5 6 7 |
# File 'lib/musicality/project/file_raker.rb', line 5 def subdirs @subdirs end |
#task_name ⇒ Object (readonly)
Returns the value of attribute task_name.
5 6 7 |
# File 'lib/musicality/project/file_raker.rb', line 5 def task_name @task_name end |