I like to do my command line scripts like this:

file: reports.rb

class Reports
 def self.run(args)
  process_args(args)

  self.do_stuff
 end

 private
 def process_args(args)
  unless args.is_a?(Hash)
   @args = Hash[*args.collect{ |arg| arg.split(/\s|=/) }.flatten]
  else
   @args = args
  end
 end
end

at_exit do
  if File.expand_path($0) == File.expand_path(__FILE__)
    Reports.run(ARGV)
  end
end

Now if I want to run on the command line I can, like normal, but I can
also require 'reports', and interact with it from another script where
it behaves differently.

If I were you I'd start out by creating some tools to help you
program better, like a custom Logger class that emails you when errors
occur, or a reminder program that sends yourself text messages, you
could use that in your Logger also for critical errors.

I find myself having to always go back to stuff I wrote a long time
ago and add better error notification code.

-Jeff


On Tue, May 23, 2006 at 05:52:57AM +0900, corey konrad wrote:
> I guess i thought that would just sort of click after i learned a 
> language, but i guess that isnt how it works. I didnt really begin 
> learning ruby for any reason other than wanting to know how to program. 
> I tried getting my first internship doing programming and they said they 
> wanted someone with an extensive portfolio of software they have 
> developed. I have no idea what software to work on. I have looked at 
> some of the open source projects being done and i dont understand what i 
> am looking at....yet i understood the exercises form the book i was 
> learning from which went over the syntax and key words etc. Its pretty 
> confusing its almost like you have to run a program and try to figure 
> out wht part of a program is doing what even after you know a language. 
> Programming languages are pretty small things but what you can do with 
> them is amazing. Just a few words and some syntax rules and you can 
> build entire operating systems and video games etc. I just thought it 
> would be a more flowing process i guess. Like ok i am going to sit down 
> and write a music player all of my own or something but it doesnt work 
> that way, i think it would take me like a year to make something like 
> that if not longer. I think my expectations of programming were a bit 
> unrealistic.
> 
> 
> > Programming is not so much an art like poetry as a craft, like making a 
> > chair. I don't think you can just open up an editor and start typing 
> > code until you have an end in sight. You need an itch to scratch, a need 
> > to fill, a problem to solve. What drew you to the idea of learning 
> > programming to begin with? What did you hope to accomplish?