22nd - 28th July 2007
Ruby Weekly News is a summary of the week’s activity on the ruby-talk mailing list / the comp.lang.ruby newsgroup / Ruby forum, brought to you by Krishna Sankar.
This week we had ~1150 messages.
Tim had a good insight that helped me – he said ”..pick a small number of interesting threads and give a detailed description of them, rather than having lots and lots of really small summaries…” Am going to see if that works out.
Articles and Announcements
- MiniExiftool 0.4.0 released
- Ruby-VPI 17.0.0
- Less than one week left for July Ruby Project Spotlight <b>...</b>
- Ruby thread-dump Gem
- rfeedparser 0.9.93
- RDE 1.1.1
- Article : Why Ruby on Rails Succeeded
- mechanize 0.6.10 Released
- ActiveRecord::Extensions 0.7.0 Released!
- Ramaze version 0.1.3
- Ruby Certificate Program @ University of Washington <b>...</b>
- ANN: Sequel 0.1.9 Released
- icanhasaudio 0.0.2 Released
- (Alternative) Ruby Planet
- Ruby Chinese Community Open-Sourcing Project Management System
- To Diarmuid: Ruby on the Meraki Mini
- ZenTest 3.6.1 Released
- great new site for IT GURUS - www.itkong.com
- svn+http on RubyForge
- Proposals now being accepted for RubyConf 2007 presentations
- EURUKO 2007
- We’re keeping the conference fee as low as possible - last year it was just 20 Euro.
- The planning of the talks was quite dynamic, some folks who came as ‘attendant-only’ gave presentations later the same day,
- It’s your conference, so if you like to just contribute.
- Ruby Canada launched - The Canadian resource for all things Ruby
- rubyforge 0.4.3 Released
- hoe 1.2.2 Released
MiniExiftool is a wrapper library for the Exiftool command-line application (www.sno.phy.queensu.ca/~phil/exiftool/) written by Phil Harvay. One of the completest tool for reading and writing meta informations (EXIF, IPTC, XMP) on image files which supports many file formats including raw formats.
Ruby-VPI is a Ruby interface to IEEE 1364-2005 Verilog VPI and a platform for unit testing, rapid prototyping, and systems integration of Verilog modules through Ruby. It lets you create complex Verilog test benches easily and wholly in Ruby.
Just a reminder for those considering submitting a project for the O’Reilly Ruby Blog “Ruby Project Spotlight” series, you have until Sunday to email me your code samples.
There are details here: http://www.oreillynet.com/ruby/blog/2007/07/looking_for_july_ruby_pro…
I plan to keep the series going as long as I keep getting submissions, so if you can’t make it this month, expect to see another call for submissions next month.
“So a huge feature missed from the JVM is the ability to send SIGQUIT (ctrl-break) and get a list of running threads. This feature is a killer feature for tracking down hung processes, as it will allow you to see where threads are hung up.
I’ve written a small C extension for Ruby that will send a list of threads and their current file/line number executing to STDERR upon receiving a SIGQUIT. Simply install the gem and require ‘thread-dump’, and a trap will be registered with SIGQUIT within that process. (So, if you’re fork’ing stuff, you need to do the require within the fork, for example.) “
RDE is a Ruby IDE and Ruby editor on Windows. You can edit, run and debug your scripts quickly and easily. RDE debugger is the GUI wrapper of debug.rb. RDE editor has functions that syntax coloring, autocomplete and etc.
In this CIO article, Hal Fulton, author of The Ruby Way, explains what the programming community did right, and how others can learn from it.
http://www.cio.com/article/125851
Couple of interesting acronyms on the threads !
DROP Don’t Repeat Other People DRAIN Don’t Repeat Anything In No case DRIP Don’t repeat it, period..
The Mechanize library is used for automating interaction with websites. Mechanize automatically stores and sends cookies, follows redirects, can follow links, and submit forms. Form fields can be populated and submitted. Mechanize also keeps track of the sites that you have visited as a history.
ctiveRecord::Extension (aka ar-extensions) is a plugin to extend and enhance the functionality of ActiveRecord.
Ramaze is intended to be a light, simple and modular open-source web framework based on Ruby.
This release contains a much improved MySQL adapter, a new single-threaded database feature and a few bug fixes.
Hai! icanhasaudio? is an interface to lame for decoding ur MP3s.
An accumulator of feeds about Ruby http://www.phidz.com/Ruby
Ruby Chinese Community was dedicated to furthering Ruby language become popular in China. Recently, we have put a SVN server (http:// svn.ruby-lang.org.cn) and a project management system with Redmine (http://dev.ruby-lang.org.cn) to support open-sourcing projects.
” I have posted my experience using Ruby on the Meraki Minis. They are $50 wifi routers that do mesh networking. the run a version of OpenWRT and include lighttpd and ruby. I have a couple of example programs and a tutorial on how to program Ruby to do web access, CGI, and do IO on a file based on the querystring. “
ZenTest provides 4 different tools and 1 library: zentest, unit_diff, autotest, multiruby, and Test::Rails.
ZenTest scans your target and unit-test code and writes your missing code based on simple naming rules, enabling XP at a much quicker pace. ZenTest only works with Ruby and Test::Unit.
unit_diff is a command-line filter to diff expected results from actual results and allow you to quickly see exactly what is wrong.
autotest is a continous testing facility meant to be used during development. As soon as you save a file, autotest will run the corresponding dependent tests.
multiruby runs anything you want on multiple versions of ruby. Great for compatibility checking!
Focused solely on the community of IT specialists, web developers, technological experts, companies and individuals alike.
RubyForge now supports svn+http for read-only access to the svn repositories. For example:
$ svn checkout http://mongrel.rubyforge.org/svn/trunk/ mongrel A mongrel/test A mongrel/test/test_command.rb A mongrel/test/test_redirect_handler.rb A mongrel/test/test_response.rb A mongrel/test/test_stats.rb [ ... etc … ]
Presentation proposals for RubyConf 2007 are now being accepted. The form is at: http://proposals.rubycentral.org.
The deadline for proposals is August 20, 5:00 PM EDT.
RubyConf 2007 will be held November 2-4 at the Omni Charlotte Hotel, Charlotte, NC, USA.
a couple of weeks back I already made an announcement about this year’s European Ruby Conference (EURUKO).
Currently it’s planned for the weekend on the 3rd and 4th of November, which very unfortunately clashes nearly perfectly with RubyConf in in Charlotte, North Carolina (http://rubyconf.org/). Turns that it hard to find a date matching every constraint …
The general set up is like this:
Ruby Canada (http://rubycanada) is a new source for Ruby and Rails developers working in and around Canada. Without hyping it up to what it will be, what it is right now is an awesome resource for those looking for work.
A script which automates a limited set of rubyforge operations.
Hoe is a simple rake/rubygems helper for project Rakefiles. It generates all the usual tasks for projects including rdoc generation, testing, packaging, and deployment.
Quote of the Week
“A language that doesn’t affect the way you think about programming is not worth knowing.” – A. Perlis (as quoted by James Britt)
“A witty saying proves nothing.”—Voltaire (as quoted by Chris Game)
“The trouble with the world is that the stupid are cocksure and the intelligent are full of doubt.” – Bertrand Russell (as quoted by James Britt)
”...the number of UNIX installations has grown to 10, with more expected…” - Dennis Ritchie and Ken Thompson, June 1972 (as quoted by Darren Kirby)
Threads
checking if machine is 64-bit
The question was (from Suraj) a better way to check if a machine is 64-bi than :
require 'rbconfig'
is_machine_64_bit = ( Config::CONFIG["arch"] =~ /64/ )
An interesting solution (from Daniel Berger) :
if (2 33).kind_of?(Bignum)
\# 32 bit
else
\# 64 bit
end
[Might need some tweaking once the 128 bit operating systems show up…]
Suraj observed that “it takes 34 bits to represent 2 33, and 33 bits to represent 2 32. Thus, we can get away with only checking whether 2 ^ 32 is a Fixnum:
is_machine_64_bit = (2 32).is_a? Fixnum
Suraj followed with another idea: (-1.size) is 4 on a 32-bit machine and 8 on a 64-bit machine
Nobu added couple more ideas : If you are trying to compile an extension library:
is_machine_64_bit = check_sizeof("int") 64
is_machine_64_bit = try_static_assert("sizeof int 64")
or, better in C source(s):
\#if SIZEOF_VOIDP 8
Otherwise, if you want to know the current running platform is
64bit:
is_machine_64_bit = [0].pack("i!").size 8
Note that all of the above check for the size of int.
Question - Passing parameters by reference
The question was “How can I pass a reference to a method as an argument, so after finishing the execution of the method the argument gets updated with a new value. ( known as “pass by reference” in other languages )”
A good discussion followed.
In short, this would work with strings as strings are arrays underneath. So if one passes a string and makes changes inside, the changes will be reflected.
But for first class objects like Numbers (Fixnum,BigNum,...) are objects which themselves cannot be changed.
In short “I believe it’s a good practice to stop thinking in terms of pointers and start thinking in terms of objects. You don’t pass a variable by reference, you pass an object.’ (thus said Okushi)
Closely related thread : http://groups.google.com/group/ruby-talk-google/browse_thread/thread/31ad84bf4f2bc10b
object equivalence
The question was “I have two objects, a and b, both of the same class. I believe they have the same contents, but a.eql?(b) returns false”
Answer : ql? is just a method and therefore depends on the implementing object. By default, eql? returns true only if the objects being compared are the same object. And then, each class typically overrides eql? to do as the developer sees fit.
n00b if condition quest
Question How does one do if (a b or a c or a d or a f)
Discussion followed and some answers:
if [b,c,d,f].include?(a)
case a when b, c, d, f ... end
Static variables in Ruby.
This is an interesting discussion because static variables are very popular in other languages.
Some comments :
here are three kinds of variables in Ruby viz: local, @class_var and @instance_var. My tip, do not use @class_var, use @inst_var on the correct level.
If you mean static variables that are visible in a single method only, then no, there is no way to do it. You should probably rethink your design if it relies on such archaic features of other programming languages. :-)
“Static” is a misleading term, though. It’s just a local variable that happens to get wrapped in a closure. In general, I don’t think Ruby and the word “static” mix very well :-) Constants are sort of statically scoped, but that’s about it.
Why Ruby?
Couple of pointers (like the site http://ruby-doc.org/whyruby) and discussions on th merits of Ruby
how can i use a ruby class in object way
A conceptual discussion. The question was “We all know that we can use a class’object in main method in java,but how can I use a class’object after designing a class in ruby? Is there an only place like main method of java in which I can use my classes? is there a rule that can guide me to use my ruby class correctly?”
Answer : “Ruby is in its essence an interpreter. When you type in your command prompt >ruby my_script.rb the interpreter (that by itself is just another application) reads your file line by line and executes every line. Think of every line in Ruby as a command to the interpreter and that the interpreter executes every single line. That means you can use your classes anywhere you like as long as they were defined before.
... it’s quite different from Java. If you want to feel more comfortable think of your Ruby code written entirely inside one big ‘main’ Java function. Just remember – every line is executed! “
Why is it so hard to kill Ruby?
An interesting thread which goes asymptotic to the question, but entertaining …