Forum: Ruby standard dry-run flag

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-01-15 23:52
(Received via mailing list)
is there a standard global var for dry-run? e.g. $DRYRUN. i've been
using $NOHARM myself, but decided i want to use whatever rake uses (I
assume it sets a global flag so task defs can use it if need be.) which
got me thinking it would probably be good if ruby had a standard for
this.

t.
10d4acbfdaccb4eee687a428ca00a5d8?d=identicon&s=25 Jim Weirich (weirich)
on 2007-01-16 04:13
Trans wrote:
> is there a standard global var for dry-run? e.g. $DRYRUN. i've been
> using $NOHARM myself, but decided i want to use whatever rake uses (I
> assume it sets a global flag so task defs can use it if need be.) which
> got me thinking it would probably be good if ruby had a standard for
> this.

Actually no, Rake does not store the dry-run flag in a global.  It is
stored in an options object that is local to the Rake::Application
object.  This allows multiple Rake::Applications running in the same
memory space, each with its own set of tasks and options.

Early versions of Rake used globals, but I've tried to avoid them as
much as possible in later versions.

-- Jim Weirich
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-01-16 04:57
(Received via mailing list)
Jim Weirich wrote:
> memory space, each with its own set of tasks and options.
curiuos, does that scenario actually arise?

but more important to me at the moment, how does one access the
--dry-run flag in one's task?

thanks,
t.
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-01-16 05:13
(Received via mailing list)
Trans wrote:
> > Actually no, Rake does not store the dry-run flag in a global.  It is
> > stored in an options object that is local to the Rake::Application
> > object.  This allows multiple Rake::Applications running in the same
> > memory space, each with its own set of tasks and options.
>
> curiuos, does that scenario actually arise?
>
> but more important to me at the moment, how does one access the
> --dry-run flag in one's task?

oh, i forgot to ask... $DRYRUN seems to be on the order of $DEBUG which
is built-into Ruby. that in itslef seesm a bit worrisome given your
point. can't setting $DEBUG in one memory space mess up another too?

t.
93d566cc26b230c553c197c4cd8ac6e4?d=identicon&s=25 Pit Capitain (Guest)
on 2007-01-16 11:08
(Received via mailing list)
Trans schrieb:
> Jim Weirich wrote:
>> (...)
>
> but more important to me at the moment, how does one access the
> --dry-run flag in one's task?

Tom, I've nether used Rake yet, but

   task.application.options.dryrun

should give you the desired information.

Regards,
Pit

PS: Welcome back, Jim! At least I have missed our posts.
93d566cc26b230c553c197c4cd8ac6e4?d=identicon&s=25 Pit Capitain (Guest)
on 2007-01-16 11:39
(Received via mailing list)
Sorry for the typos. Here's what I wanted to write...

Trans schrieb:
> Jim Weirich wrote:
>> (...)
>
> but more important to me at the moment, how does one access the
> --dry-run flag in one's task?

Tom, I've never used Rake yet, but

   task.application.options.dryrun

should give you the desired information.

Regards,
Pit

PS: Welcome back, Jim! At least I have missed your posts.
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2007-01-16 18:44
(Received via mailing list)
Pit Capitain wrote:
>
>    task.application.options.dryrun
>
> should give you the desired information.

thanks Pit. i'll try that.

t.
This topic is locked and can not be replied to.