From: "Derrick B." Date: 2013-01-06T02:13:20+09:00 Subject: Re: require "test/unit" unknown wrote in post #1091145: > Am 05.01.2013 16:45, schrieb tamouse mailing lists: >> On Fri, Jan 4, 2013 at 9:45 PM, Derrick B. wrote: >>> Thanks! This is all good information, but I feel I need to improve my >>> Ruby basics first before learning to use these frameworks. I will >>> install them to at least take a peek, though. >> >> There is much much more to programming that learning a bit of syntax. >> Learning *how* to structure and write the kinds of applications you >> want now is going to serve you as you progress. > > On the other hand, you can also get "lost" in a framework, especially > as a beginner. > > For not too complex (!) tasks you can already achieve much with a > single file containing all needed classes, the optparse library and > (of course) a test file or test files > -> no need to cut a gem; easy installation (copying into search path); > all code in one place. > > I often use the following structure: > > ----- > #!/usr/bin/env ruby > # short description, copyright > > require 'optparse' > require 'whatever' > > module MyApp # prevents name clashes > > # constants and class definitions > # ... > # ... > # ... > > class Application > # provides a run! method > end > > > if __FILE__ == $0 > Application.new.run! # not called if file is required (by tests) > end > > end # of module You know, for the longest time I keep telling myself I need to create template files for whatever language I feel like programming in that week, and never do it. I just keep jumping and start writing. One of these days! heh I installed methadone and it reminds me of Perl's Module::Starter, which I am currently playing around with. It appears to create almost an exact type of file/directory structure to then fill in your code and documentation. Very nice. -- Posted via http://www.ruby-forum.com/.