How to execute code before and after a package is load?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

How to execute code before and after a package is load?

Adrian Kuhn
It need to turn off system notifications for TestCase while gofer updates
 SUnit. One way I see would be to execute some code snippet before and after
 loading. However the Script button in Monticello seems to be broken. I cannot
 add scripts to the package.

What can I do?

So the current way to load akuhn SUnit is

        [SystemChangeNotifier uniqueInstance noMoreNotificationsFor: TestCase.
        Gofer it
                displabePackageCache;
                squeaksource: 'akuhn';
                package: 'SUnit';
                package: 'SUnitGUI';
                load ] ensure: [ TestCase initialize ].

which is well ... quite ugly for a Gofer script.

--AA


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: How to execute code before and after a package is load?

Alexandre Bergel
To obtain the after behavior, the classical way is to define an  
'initialize' method on the class side of one your class.

Cheers,
Alexandre

On 29 Dec 2009, at 04:09, Adrian Kuhn wrote:

> It need to turn off system notifications for TestCase while gofer  
> updates
> SUnit. One way I see would be to execute some code snippet before  
> and after
> loading. However the Script button in Monticello seems to be broken.  
> I cannot
> add scripts to the package.
>
> What can I do?
>
> So the current way to load akuhn SUnit is
>
> [SystemChangeNotifier uniqueInstance noMoreNotificationsFor:  
> TestCase.
> Gofer it
>                displabePackageCache;
> squeaksource: 'akuhn';
> package: 'SUnit';
> package: 'SUnitGUI';
> load ] ensure: [ TestCase initialize ].
>
> which is well ... quite ugly for a Gofer script.
>
> --AA
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.






_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: How to execute code before and after a package is load?

Stéphane Ducasse
In reply to this post by Adrian Kuhn

On Dec 29, 2009, at 4:09 AM, Adrian Kuhn wrote:

> It need to turn off system notifications for TestCase while gofer updates
> SUnit. One way I see would be to execute some code snippet before and after
> loading. However the Script button in Monticello seems to be broken. I cannot
> add scripts to the package.


I **never** used scripts. I have no idea what they are (even if I guess) and more important
the door that they open into a space that we do not control is dangerous.
(Imagine people publishing a hell of scripts with no tool and metamodel support for them).
So please do not use them. Use the model with have, class, method, package.
In metacello there is a preload and postload if I remember.

May be Gofer should have a silent: #TestCase

> What can I do?
>
> So the current way to load akuhn SUnit is
>
> [SystemChangeNotifier uniqueInstance noMoreNotificationsFor: TestCase.
> Gofer it
>                displabePackageCache;
> squeaksource: 'akuhn';
> package: 'SUnit';
> package: 'SUnitGUI';
> load ] ensure: [ TestCase initialize ].
>
> which is well ... quite ugly for a Gofer script.
>
> --AA
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: How to execute code before and after a package is load?

Adrian Kuhn
Stéphane Ducasse <stephane.ducasse@...> writes:

> I **never** used scripts. I have no idea what they are (even if I guess) and
> more important the door that they open into a space that we do not control is
> dangerous.

They are pre- and postload code snippets. If you add 4 missing methods on
 package info you get them in monticello (but sometimes they seem not to
 execute when loading a package, so I gave up at that point...)

> In metacello there is a preload and postload if I remember.

How do I use metacello, any documentation / tutorial available?

cheers,
AA



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: How to execute code before and after a package is load?

Mariano Martinez Peck


On Tue, Dec 29, 2009 at 11:08 AM, Adrian Kuhn <[hidden email]> wrote:
Stéphane Ducasse <stephane.ducasse@...> writes:

> I **never** used scripts. I have no idea what they are (even if I guess) and
> more important the door that they open into a space that we do not control is
> dangerous.

They are pre- and postload code snippets. If you add 4 missing methods on
 package info you get them in monticello (but sometimes they seem not to
 execute when loading a package, so I gave up at that point...)

> In metacello there is a preload and postload if I remember.

How do I use metacello, any documentation / tutorial available?


http://code.google.com/p/metacello/wiki/Tutorial

I would recommend the "Image-based Tutorial".

If you want more examples you can check the

http://www.squeaksource.com/MetacelloRepository

Yes, Metacello does support post and pre doits  but the problem is that it is only at package level, not project. Dale is aware of this and already put in his todo list to have pre a post scripts for a whole project.
A simple hack is to put the post script to the last package.

Cheers

Mariano
 

cheers,
AA



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project