Sha256: 74b749578d4a585922bc76e59bfb3c08f50e017f08f4037a20c19e3170e88b26

Contents?: true

Size: 655 Bytes

Versions: 2

Compression:

Stored size: 655 Bytes

Contents

def create_task(taskname, task_object, &execute_body)
  taskclass = :"Albacore_TaskFor_#{taskname}"
  taskmethod = taskname.to_s.downcase.to_sym

  Object.class_eval(<<-EOF, __FILE__, __LINE__)
    def #{taskmethod}(name=:#{taskname}, *args, &block)
      Albacore.const_get("#{taskclass}").new(name, *args, &block)
    end
  EOF

  Albacore.class_eval do
    const_set(taskclass, Class.new(Albacore::AlbacoreTask) do
      define_method :execute do |name|
        task_object.load_config_by_task_name(name)
        call_task_block(task_object)
      	execute_body.call(task_object) unless execute_body.nil?
      end
    end)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
albacore-0.1.3 lib/rake/support/createtask.rb
albacore-0.1.2 lib/rake/support/createtask.rb