Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rake Execute With Multiple Arguments

I'm calling a rake task within a task and I'm running into a roadblock when it comes to calling execute

response = Rake::Task["stuff:sample"].execute[:match => "HELLO"]

or

response = Rake::Task["stuff:sample"].execute[:match => "HELLO",:freq=>'100']

Calling task

task :sample, [:match,:freq] => :environment  do |t, args|

The error I get back is 'can't convert Hash into Integer'

Any ideas?

like image 482
devinross Avatar asked Jan 19 '23 08:01

devinross


1 Answers

I think the problem is in code you're not posting. Works fine for me:

james@James-Moores-iMac:/tmp$ head r.rb call.rb 
==> r.rb <==
task :sample, [:match,:freq] do |t, args|
  puts "hello world"
  puts args[:match]
end

==> call.rb <==
require 'rubygems'
require 'rake'
load 'r.rb'
Rake::Task["sample"].execute :match => "HELLO"
james@James-Moores-iMac:/tmp$ ruby call.rb 
hello world
HELLO
james@James-Moores-iMac:/tmp$ 
like image 85
James Moore Avatar answered Jan 25 '23 01:01

James Moore