I like this but I am not sure if there are problems with this approach. It looks nice though...<br><br>-g.<br><br><div><span class="gmail_quote">On 1/4/07, <b class="gmail_sendername"><a href="mailto:transfire@gmail.com">transfire@gmail.com
</a></b> <<a href="mailto:transfire@gmail.com">transfire@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I'm cross posting this b/c it has to do with Ratchets:
<br><br>I'm having a little debate with myself. On my current project I have a<br>bunch of little reusable task scripts that a command line tool runs.<br>The scripts are written as the top-level (although I actually simulate
<br>the top-level when running them). So for example a script would just be<br>something like:<br><br> # example.rb<br><br> def example<br> puts "This is an example!"<br> end<br><br>Then on the command line I would do:
<br><br> % mytool example<br> This is an example!<br><br>That's all well and good, but many of the scripts have generally useful<br>routines and I would like them to be accessible by other programs too,<br>not just my command line tool. So I thoght maybe it would be better if
<br>a module were required to wrap the defs.<br><br> # another.rb<br><br> module MyToolAnother<br><br> def another<br> puts "This is another!"<br> end<br><br> end<br><br>That works, of course, but it adds an additonal layer of essentially
<br>redundant code, which IMHO is ugly.<br><br>Then I got to thinking. Why don't we write resuable lib in this fashion<br>anyway and just create our own containers on the fly when loading them?<br><br> MyToolExample = load_as_module "
example.rb"<br><br>What intersting about that is then we could determine in what capacity<br>it is to be used. For example:<br><br> # adds module_function<br> MyToolExample = load_as_function_module "example.rb
"<br><br> # adds self extend<br> MyToolExample = load_as_self_extended_module "example.rb"<br><br>Or even<br><br> MyToolExample = load_as_class "example.rb"<br><br>We could even have include and extend take a lib path.
<br><br> include "example.rb"<br><br>Of course this effectively puts encapsulation, at least at the top<br>level, on a per-file basis. But in many respects that seems kind of<br>nice. It increases flexability and reduces configuration complexity.
<br><br>So what do your think? Is this technique worth promoting? Or am I being<br>silly and should just wrap all my scripts in modules?<br><br>T.<br><br>_______________________________________________<br>Nitro-general mailing list
<br><a href="mailto:Nitro-general@rubyforge.org">Nitro-general@rubyforge.org</a><br><a href="http://rubyforge.org/mailman/listinfo/nitro-general">http://rubyforge.org/mailman/listinfo/nitro-general</a><br></blockquote></div>
<br><br clear="all"><br>-- <br><a href="http://blog.gmosx.com">http://blog.gmosx.com</a><br><a href="http://cull.gr">http://cull.gr</a><br><a href="http://www.joy.gr">http://www.joy.gr</a><br><a href="http://nitroproject.org">
http://nitroproject.org</a>