On Apr 23, 2013, at 10:59 AM, Jason Hsu, Android developer wrote:
> I'm looking for examples of Ruby scripts that are long AND well-written.
>
> I have a Ruby script for scraping information on stock ETFs and mutual funds and storing the data in a Postgres database at https://github.com/jhsu802701/bsf-scrape/blob/master/scrape.rb . While I need to make some minor changes to it (like providing external options to choose between the long and short version, as the "Enter blahblahblah within 20 seconds" approach doesn't work in a cron job), I know I need to make one major change: making the script better-written.
>
> Substantial parts of my script are cobbled together from examples of code for performing various tasks. (I'm quite new to Ruby.) I know that my script is far from optimal. What long Ruby scripts are considered to be the gold standards in Ruby style and techniques?
Long scripts may be the entire problem right there. A lot of the "masterful" Ruby I have seen is really brief, not long at all. If a method takes more than a handful of lines, it gets refactored into two or more shorter methods, these get organized into sensibly-designed classes, and no single script gets responsibility for more than one thing. I am in no way qualified to write like this, but I have seen it enough times to know that it's what I should be reaching for in my own work. Open up @tenderlove's CSSPool project, which parses CSS into Ruby objects. It's pretty hard to find a method more than 4 lines long anywhere within it.
Walter
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/SUsbmVAVbR8J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment