[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

When Rake goes "Ache!"

S. Robert James

11/17/2006 2:59:00 AM

What is the best way to set something to do when a Rake task fails?

I'd like something like:

task :migrate_safely => [:backup, :migrate] do
rescue
if :backup
:restore
end
end
end

Is there a way to do anything similar?

6 Answers

Jim Weirich

11/17/2006 7:48:00 PM

0

Robert James wrote:
> What is the best way to set something to do when a Rake task fails?
>
> I'd like something like:
>
> task :migrate_safely => [:backup, :migrate] do
> rescue
> if :backup
> :restore
> end
> end
> end
>
> Is there a way to do anything similar?

Does something like this work ...


$migrate_failed = false

task :default => :migrate_safely

task :backup do
puts "Backing Up"
end

task :migrate do
begin
puts "Migrating"
fail "Oops"
rescue
$migrate_failed = true
end
end

task :restore do
puts "Restoring"
end

task :migrate_safely => [:backup, :migrate] do
Rake::Task[:restore].invoke if $migrate_failed
puts "Migrated Safely"
end

--
Posted via http://www.ruby-....

S. Robert James

11/17/2006 7:57:00 PM

0


Jim Weirich wrote:
> Does something like this work ...
>
>
> $migrate_failed = false
> task :migrate do
> begin
> puts "Migrating"
> fail "Oops"
> rescue
> $migrate_failed = true
> end
> end

Thanks - will try it out. Not all fails throw exceptions (right? it's
considered a fail if sh "false"), but I can always catch that and throw
an exception manually.

> --
> Posted via http://www.ruby-....
Wow! The famous Jim himself uses ruby-forum. Should quiet all those
who complain about it :-)

Jim Weirich

11/17/2006 8:11:00 PM

0

Robert James wrote:
> Jim Weirich wrote:
>> end
>> end
>
> Thanks - will try it out. Not all fails throw exceptions (right? it's
> considered a fail if sh "false"), but I can always catch that and throw
> an exception manually.

If the "sh" command fails, it will throw an exception that terminates
rake processing. So you shouldn't have a problem with that.

change the fail line in the example to:

sh "ruby -e 'exit(1)'"

to try it.

-- Jim Weirich

--
Posted via http://www.ruby-....

duke

10/20/2012 6:15:00 PM

0

On Fri, 19 Oct 2012 14:41:26 -0700, Jeanne Douglas <hlwdjsd2@NOSPAMgmail.com>
wrote:

>In article <e8b388h0nuu551d9kgb1ssvem4g9t9m0i6@4ax.com>,
> duke <duckgumbo32@cox.net> wrote:
>
>> On Thu, 18 Oct 2012 17:05:05 -0700, Jeanne Douglas <hlwdjsd2@NOSPAMgmail.com>
>> wrote:
>>
>> >In article <2tc088dmjrrfh9qv3qhbaunnseho1dlhgc@4ax.com>,
>> > duke <duckgumbo32@cox.net> wrote:
>> >
>> >> On Wed, 17 Oct 2012 16:25:37 -0700, Jeanne Douglas
>> >> <hlwdjsd2@NOSPAMgmail.com>
>> >> wrote:
>> >>
>> >> >In article <l31u78hmeebn67urn2h86592afdvsiq0vn@4ax.com>,
>> >> > duke <duckgumbo32@cox.net> wrote:
>> >> >
>> >> >> On Sun, 14 Oct 2012 16:20:08 -0700, Jeanne Douglas
>> >> >> <hlwdjsd2@NOSPAMgmail.com>
>> >> >> wrote:
>> >> >>
>> >> >> >In article <5f7m78916jhu80nuh0ppr48f78qn8vrh1f@4ax.com>,
>> >> >> > duke <duckgumbo32@cox.net> wrote:
>> >> >> >
>> >> >> >> On Sat, 13 Oct 2012 15:08:57 -0700, Jeanne Douglas
>> >> >> >> <hlwdjsd2@NOSPAMgmail.com>
>> >> >> >> wrote:
>> >> >> >>
>> >> >> >> >In article <nfKdndXX0_GXROTNnZ2dnUVZ_rudnZ2d@posted.sonicnet>,
>> >> >> >> > reports@scientology.org (Fred^4) wrote:
>> >> >> >> >
>> >> >> >> >> http://www.alternet.org/bill-maher-right-wing-christians...
>> >> >> >> >> -go
>> >> >> >> >> ds-
>> >> >> >> >> wor
>> >> >> >> >> k-w
>> >> >> >> >> hy-are-you-always-wrong
>> >> >> >> >>
>> >> >> >> >> Bill Maher to Right-Wing Christians: If You Do God's Work,
>> >> >> >> >> Why Are You Always Wrong?
>> >> >> >> >>
>> >> >> >> >> "Is the problem that you can't follow instructions, or is
>> >> >> >> >> Jesus just dicking you around?" Maher asks.
>> >> >> >> >> Well, rightards? Any of you fucking loons have an answer?
>> >> >> >> >
>> >> >> >> >It was AWESOME!!!
>> >> >> >> >As usual.
>> >> >> >>
>> >> >> >> >And it was great seeing Darrell Issa getting his ass kicked again.
>> >> >> >> >His
>> >> >> >> >fake smile is even scarier than Romney's.
>> >> >> >>
>> >> >> >> You're a muslim from Libya, aren't you.
>> >> >> >
>> >> >> >Ahhhh, there's another tell that they've lost the argument.
>> >> >>
>> >> >> But won the war.
>> >> >
>> >> >What war?
>> >>
>> >> The one we're talking about.
>> >
>> >There's no war in this conversation.
>> >So answer the question.
>>
>> Buckwheat went awol on 911 this year for 2 weeks. Mitt will kick his ass
>> Monday
>> about why.
>
>You mean like he kicked ass with Libya on Tuesday?

Yep. The moderator says she was wrong supporting buckwheat.

The dukester, American - American
********************************************
A vote for obama is a vote for the end of
democracy in America as we know it. Let the
rolling thunder guide your decision at the
ballot box to put an end to Imperial Obama.
May God bless America.
********************************************

Jeanne Douglas

10/20/2012 10:57:00 PM

0

In article <gfq588983jjt8pgv3kffa8nr0f1v0lgm59@4ax.com>,
duke <duckgumbo32@cox.net> wrote:

> On Fri, 19 Oct 2012 14:41:26 -0700, Jeanne Douglas <hlwdjsd2@NOSPAMgmail.com>
> wrote:
>
> >In article <e8b388h0nuu551d9kgb1ssvem4g9t9m0i6@4ax.com>,
> > duke <duckgumbo32@cox.net> wrote:
> >
> >> On Thu, 18 Oct 2012 17:05:05 -0700, Jeanne Douglas
> >> <hlwdjsd2@NOSPAMgmail.com>
> >> wrote:
> >>
> >> >In article <2tc088dmjrrfh9qv3qhbaunnseho1dlhgc@4ax.com>,
> >> > duke <duckgumbo32@cox.net> wrote:
> >> >
> >> >> On Wed, 17 Oct 2012 16:25:37 -0700, Jeanne Douglas
> >> >> <hlwdjsd2@NOSPAMgmail.com>
> >> >> wrote:
> >> >>
> >> >> >In article <l31u78hmeebn67urn2h86592afdvsiq0vn@4ax.com>,
> >> >> > duke <duckgumbo32@cox.net> wrote:
> >> >> >
> >> >> >> On Sun, 14 Oct 2012 16:20:08 -0700, Jeanne Douglas
> >> >> >> <hlwdjsd2@NOSPAMgmail.com>
> >> >> >> wrote:
> >> >> >>
> >> >> >> >In article <5f7m78916jhu80nuh0ppr48f78qn8vrh1f@4ax.com>,
> >> >> >> > duke <duckgumbo32@cox.net> wrote:
> >> >> >> >
> >> >> >> >> On Sat, 13 Oct 2012 15:08:57 -0700, Jeanne Douglas
> >> >> >> >> <hlwdjsd2@NOSPAMgmail.com>
> >> >> >> >> wrote:
> >> >> >> >>
> >> >> >> >> >In article <nfKdndXX0_GXROTNnZ2dnUVZ_rudnZ2d@posted.sonicnet>,
> >> >> >> >> > reports@scientology.org (Fred^4) wrote:
> >> >> >> >> >
> >> >> >> >> >> http://www.alternet.org/bill-maher-right-wing-christi...
> >> >> >> >> >> -do
> >> >> >> >> >> -go
> >> >> >> >> >> ds-
> >> >> >> >> >> wor
> >> >> >> >> >> k-w
> >> >> >> >> >> hy-are-you-always-wrong
> >> >> >> >> >>
> >> >> >> >> >> Bill Maher to Right-Wing Christians: If You Do God's Work,
> >> >> >> >> >> Why Are You Always Wrong?
> >> >> >> >> >>
> >> >> >> >> >> "Is the problem that you can't follow instructions, or is
> >> >> >> >> >> Jesus just dicking you around?" Maher asks.
> >> >> >> >> >> Well, rightards? Any of you fucking loons have an answer?
> >> >> >> >> >
> >> >> >> >> >It was AWESOME!!!
> >> >> >> >> >As usual.
> >> >> >> >>
> >> >> >> >> >And it was great seeing Darrell Issa getting his ass kicked
> >> >> >> >> >again.
> >> >> >> >> >His
> >> >> >> >> >fake smile is even scarier than Romney's.
> >> >> >> >>
> >> >> >> >> You're a muslim from Libya, aren't you.
> >> >> >> >
> >> >> >> >Ahhhh, there's another tell that they've lost the argument.
> >> >> >>
> >> >> >> But won the war.
> >> >> >
> >> >> >What war?
> >> >>
> >> >> The one we're talking about.
> >> >
> >> >There's no war in this conversation.
> >> >So answer the question.
> >>
> >> Buckwheat went awol on 911 this year for 2 weeks. Mitt will kick his ass
> >> Monday
> >> about why.
> >
> >You mean like he kicked ass with Libya on Tuesday?
>
> Yep. The moderator says she was wrong supporting buckwheat.

Of course, she said no such thing.

--
JD

"Osama Bin Laden is dead and GM is alive."--VP Joseph Biden

Gray Guest

10/21/2012 9:04:00 AM

0

Jeanne Douglas <hlwdjsd2@NOSPAMgmail.com> wrote in news:hlwdjsd2-
405DD7.15564420102012@news.giganews.com:

>>
>> Yep. The moderator says she was wrong supporting buckwheat.
>
> Of course, she said no such thing.

Um are you on the rag, stupid?

Candy Crowley admits Romney was right on Libya
http://www.humanevents.com/2012/10/17/candy-crowley-admits-r...
right-on-libya/

One of 19,700,000 results hits for "candy mitt was right"

>
> --
> JD
>
> "Osama Bin Laden is dead and GM is alive."--VP Joseph Biden

Ambassador Stevens and 3 other Americans are dead and Al Quaeda doesn't
seem quite so on the ropes as dear leader imagined.

And GM still owes us how many billions?

--
Refusenik #1

Libs suffer from Eleutherophobia. And there is no cure.