Class: MagicLoader::Task
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- MagicLoader::Task
- Defined in:
- lib/magic_loader/tasks.rb
Overview
Generates the MagicLoader rake task
Instance Method Summary collapse
-
#initialize(*paths) ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize(*paths) ⇒ Task
Returns a new instance of Task.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/magic_loader/tasks.rb', line 22 def initialize(*paths) = paths.last.is_a?(Hash) ? paths.pop : {} task_name = [:name] || 'magicload' task task_name do load_order = MagicLoader.require_all(*paths) strip_paths!(load_order, [:strip]) if [:strip] magic_block = [ BEGIN_MAGIC, MAGIC_WARNING, "# Run \"rake #{task_name}\" to regenerate", load_order.map { |t| "require #{t.dump}" }, END_MAGIC ].flatten.join("\n") if [:target] if File.exists? [:target] annotate_file [:target], magic_block else File.open([:target], "w") { |f| f << magic_block } end else puts magic_block end end end |