From: "R.. Kumar" Date: 2010-06-11T18:06:13+09:00 Subject: Re: creating a gem structure for command line program Thomas Sawyer wrote: > > First, there's two overarching ways to go about this: > > 1) put exe code in a bin/ file > 2) only put bootstrap code in bin/ to an lib/ file. > > Either way is fine. I tend to use #2 because it has some small > advantages --all code is in one place, relative requires are safe > within lib//. To give you an example, a bin/foo might look like: > > #!/usr/bin/env ruby > require 'foo/main.rb' > Foo.main(*ARGV) > > And that's all. Then in lib/foo/main.rb you would define a Foo.main > method to handle command-line invocation. > > And remember the advantages of encapsulation. Maruku's executables > lack this, so they cannot be reused, inherited, unit tested, etc. This (#2) is roughly how the "cheat" gem does it. I think it will take me a few minutes to change it. Thanks a lot. -- Posted via http://www.ruby-forum.com/.