jeudi 8 mars 2018

How to pass keyword parameter to ruby rufus scheduler?

I am learning about redmine.

I am trying to receive email with rufus scheduler as explain here http://www.redmine.org/projects/redmine/wiki/RedmineReceivingEmails#Schedule-email-receiving-with-Rufus-Scheduler

I don't understand how to pass the parameter to scheduler like project, traker, allow_override etc.

Currently I am passing like this

require 'rubygems'
require 'rake'
require 'rufus-scheduler'

load File.join(Rails.root, 'Rakefile')

load File.join(Rails.root, 'Rakefile')

ENV['host']='imap-mail.outlook.com'
ENV['port']='993'
ENV['ssl']='true'
ENV['username']='username@domain.in'
ENV['password']='*********'

ENV['project'] = 'myproject'
ENV['tracker']='bug'
ENV['allow_override']='all'

scheduler = Rufus::Scheduler.new
Check emails every 1 mins
scheduler.interval '1m' do
task = Rake.application['redmine:email:receive_imap']
task.reenable
task.invoke
end

This is working fine but I don't pass these parameters as the ENVIRONMENT variable. Because It affects other views.

I was trying to pass this way, task = Rake.application['redmine:email:receive_imap project=myproject tracker=bug allow_override=all'] But I didn't work.

Can someone tell me the correct way to pass these parms to receive_imap task? Any help would be appreciated. Thanks.

Aucun commentaire:

Enregistrer un commentaire