* 1 Fedora Weekly News Issue 265
o 1.1 Announcements
+ 1.1.1 Fedora Announcement News
# 1.1.1.1 Infrastructure Outage Notification: 2011-03-02 1200 UTC
-> 1500 UTC
# 1.1.1.2 Updated: Outage: Ibiblio/ipv6 servers - 2011-03-02 14:00
UTC
* 1.1.1.2.1 Reason for outage
* 1.1.1.2.2 Contact Information
+ 1.1.2 Fedora Events
# 1.1.2.1 Upcoming Events (Dec 2010 - Feb 2011)
# 1.1.2.2 Past Events
# 1.1.2.3 Additional information
o 1.2 Fedora In the News
+ 1.2.1 Who Contributes the Most to LibreOffice? (Linux Journal)
+ 1.2.2 Fedora 15 alpha delayed - Btrfs may be default in 16 (H Online)
+ 1.2.3 Beyond FUDCon with Robyn Bergeron, Fedora Program Manager (Linux
Magazine)
o 1.3 Ambassadors
+ 1.3.1 Welcome New Ambassadors
+ 1.3.2 Summary of traffic on Ambassadors mailing list
+ 1.3.3 Summary of events reported on Ambassadors mailing list
+ 1.3.4 Summary of traffic on FAmSCo mailing list
o 1.4 QualityAssurance
+ 1.4.1 Test Days
+ 1.4.2 Fedora 15 Alpha preparation
+ 1.4.3 Bodhi improvements
+ 1.4.4 FreeIPA Test Day problems and proposals
+ 1.4.5 Complications for Delta ISO users
+ 1.4.6 IPv6 testing
+ 1.4.7 Using abrt during Test Days
o 1.5 Security Advisories
+ 1.5.1 Fedora 14 Security Advisories
+ 1.5.2 Fedora 13 Security Advisories
o 1.6 LATAM Fedora!
+ 1.6.1 Ruby Capítulo 1: El primer contacto
# 1.6.1.1 Aprovechando el espacio
# 1.6.1.2 Los "Hola mundo"
* 1.6.1.2.1 holamundo.rb
* 1.6.1.2.2 holamundo.rb
# 1.6.1.3 Ruby es un lenguaje de programación orientado a objetos
# 1.6.1.4 Pero no necesito clases
# 1.6.1.5 Clases base
* 1.6.1.5.1 Cadenas de caracteres, String
* 1.6.1.5.2 Arreglos, Array
* 1.6.1.5.3 Arreglos indexados arbitrariamente, Hash
* 1.6.1.5.4 Recapitulación rápida, los objetos y sus métodos,
¿documentación?
# 1.6.1.6 Ruby es dinámico ¿ 2 + 2 = 4 ?
* 1.6.1.6.1 fixnum_mod.rb
* 1.6.1.6.2 Y ahora ejecutamos nuestro programa:
# 1.6.1.7 Estructuras de control
# 1.6.1.8 Lazos e iteradores
* 1.6.1.8.1 Lazo con for y loop:
- Fedora Weekly News Issue 265 -
Welcome to Fedora Weekly News Issue 265[1] for the week ending March 2, 2011. What follows
are some highlights from this issue.
Our issue kicks off with a couple outage announcements from this past week, followed by
three articles 'In the News', including an interview with Fedora Program Manager,
Robyn Bergeron. In Ambassador news, summaries of traffic on the Ambassador and FAmSCo
lists, and QA brings us a whole slew of Test Day details over the next few weeks, Fedora
15 prep and bodhi improvements. Security Advisories keeps us updated with security-related
patches released this past week. We're also very pleased this week to kick off our
foreign language content initiative, which developed out of FUDCon Tempe, with a new Latin
American beat, all in Spanish. To start off, we have part one of a Ruby on Fedora primer,
contributed by Guillermo Gómez, a Fedora Ambassador in Venezuela. If you would like to
contribute Fedora-related content in your language, please send a note to the editors!
An audio version of some issues of FWN - FAWN - are available! You can listen to existing
issues[2] on the Internet Archive. If anyone is interested in helping spread the load of
FAWN production, please contact us!
If you are interested in contributing to Fedora Weekly News, please see our 'join'
page[3]. We welcome reader feedback: news(a)lists.fedoraproject.org
FWN Editorial Team: Pascal Calarco, Adam Williamson
1.
http://fedoraproject.org/wiki/FWN/Issue265
2.
http://www.archive.org/search.php?query=subject%3A%22FWN%22
3.
http://fedoraproject.org/wiki/NewsProject/Join
-- Announcements --
In this section, we cover announcements from the Fedora Project, including general
announcements[1], development announcements[2] and Events[3].
Contributing Writer: Rashadul Islam
1.
http://lists.fedoraproject.org/pipermail/announce/
2.
http://lists.fedoraproject.org/pipermail/devel-announce/
3.
http://fedoraproject.org/wiki/Events
--- Fedora Announcement News ---
The announcement list is always exclusive for the Fedora Community. Please, visit the past
announcements at[1]
1.
https://admin.fedoraproject.org/mailman/listinfo/announce
---- Infrastructure Outage Notification: 2011-03-02 1200 UTC -> 1500 UTC ----
Stephen John Smoogen on Tue Mar 1 20:13:07 UTC 2011 announced[1],
"Tomorrow the services at ibiblio will be moved to a new physical location
*
ibiblio01.fedoraproject.org
* app05
* backup02
* ns02
* proxy04
* smtp-mm03
* torrent01"
1.
http://lists.fedoraproject.org/pipermail/announce/2011-March/002928.html
---- Updated: Outage: Ibiblio/ipv6 servers - 2011-03-02 14:00 UTC ----
Stephen John Smoogen on Tue Mar 1 22:09:31 UTC 2011 announced[1],
"Outage: Ibiblio/ipv6 servers - 2011-03-02 14:00 UTC
There will be an outage starting at UTC, 2011-03-02 14:00 which will last approximately 4
hours.
To convert UTC to your local time, take a look at[2] or run:
date -d '2011-03-02 14:00 UTC'
----- Reason for outage -----
metalabs is moving facilities and needs for our collocated server to move with them.
Systems will be down and getting new IP addresses with the move. [3]
----- Contact Information -----
Please join #fedora-admin in
irc.freenode.net or respond to this email to track the status
of this outage."
1.
http://lists.fedoraproject.org/pipermail/announce/2011-March/002929.html
2.
http://fedoraproject.org/wiki/Infrastructure/UTCHowto
3.
https://fedorahosted.org/fedora-infrastructure/ticket/2651
--- Fedora Events ---
The purpose of event is to build a global Fedora events calendar, and to identify
responsible Ambassadors for each event. The event page is laid out by quarter and by
region. Please maintain the layout, as it is crucial for budget planning. Events can be
added to this page whether or not they have an Ambassador owner. Events without an owner
are not eligible for funding, but being listed allows any Ambassador to take ownership of
the event and make it eligible for funding. In plain words, Fedora events are the
exclusive and source of marketing, learning and meeting all the fellow community people
around you. So, please mark your agenda with the following events to consider attending or
volunteering near you!
---- Upcoming Events (Dec 2010 - Feb 2011) ----
* North America (NA)[1]
* Central & South America (LATAM): [2]
* Europe, Middle East, and Africa (EMEA)[3]
* India, Asia, Australia (India/APJ)[4]
1.
http://fedoraproject.org/wiki/Events#FY12_Q1_.28March_2011_-_May_2011.29
2.
http://fedoraproject.org/wiki/Events#FY12_Q1_.28March_2011_-_May_2011.29_2
3.
http://fedoraproject.org/wiki/Events#FY12_Q1_.28March_2011_-_May_2011.29_3
4.
http://fedoraproject.org/wiki/Events#FY12_Q1_.28March_2011_-_May_2011.29_4
---- Past Events ----
Archive of Past Fedora Events[1]
1.
http://fedoraproject.org/wiki/FedoraEvents/PastEvents
---- Additional information ----
* Reimbursements -- reimbursement guidelines.
* Budget -- budget for the current quarter (as distributed by FAMSCo).
* Sponsorship -- how decisions are made to subsidize travel by community members.
* Organization -- event organization, budget information, and regional
responsibility.
* Event reports -- guidelines and suggestions.
* LinuxEvents -- a collection of calendars of Linux events.
-- Fedora In the News --
In this section, we cover news from the trade press and elsewhere that is re-posted to the
Fedora Marketing list[1].
http://fedoraproject.org/wiki/Marketing
Contributing Writer: Pascal Calarco
1.
http://lists.fedoraproject.org/pipermail/marketing/
--- Who Contributes the Most to LibreOffice? (Linux Journal) ---
Rahul Sundaram forwarded[1] an article from Linux Journal noting contributions to
LibreOffice:
"Bosdonnat began tracking line contributions in the middle of September 2010 with the
original 14 contributions being made by Oracle. Oracle actually contributes code to
OpenOffice.org, and then LibreOffice merges those changes, thus resulting in Oracle's
contributions to the new fork. These 112 contributions have continued throughout
development, but are dwarfed by the contributions of new developers."
These contributions make up well over half of the total new changes found in LibreOffice
as of mid-February. Weekly contributions in this area have averaged between 20 and 30 with
a total number of 517 line contributions.
Red Hat, who also contributed to
OpenOffice.org, has chipped in as well. With usually two
contributions per week, Red Hat developers have provided 39 patches since the fork."
The full article is available[2].
1.
http://lists.fedoraproject.org/pipermail/marketing/2011-March/013722.html
2.
http://www.linuxjournal.com/content/who-contributes-most-libreoffice
--- Fedora 15 alpha delayed - Btrfs may be default in 16 (H Online) ---
Rahul Sundaram forwarded[1] an an article in The H Online about the decision to push back
Fedora 15 alpha:
"The Fedora project has postponed the release of the first and only alpha version of
Fedora 15, originally scheduled for 1 March, by a week. This was due, at least in part, to
a bug in X Server that occurred in connection with keyboard layouts for such languages as
German or French and prevented users from successfully logging into GDM. Subsequent
milestones in the release schedule for Fedora 15 remain unaffected at present, and the
final release is still scheduled for 10 May.
The fifteenth Fedora release is currently planned to be the first version that won't
require a special boot parameter to be submitted to the installer in order to format a
storage device with the experimental Btrfs file system. Red Hat employee Josef Bacik, who
is heavily involved in the development of Btrfs, has now proposed on the project's
most important developer mailing list that Btrfs should be made the default file system in
Fedora 16, which is expected in late October or early November"
The full post is available[2].
1.
http://lists.fedoraproject.org/pipermail/marketing/2011-February/013713.html
2.
http://www.h-online.com/open/news/item/Fedora-15-alpha-delayed-Btrfs-may-...
--- Beyond FUDCon with Robyn Bergeron, Fedora Program Manager (Linux Magazine) ---
Rahul Sundaram forwarded[1] another article highlighting Fedora community leaders, this
with Robyn Bergeron, who remarked:
"I personally would love to see more folks getting involved in areas that don't
necessarily require coding skills. I think that there is enormous room for growth and
contribution in these areas, and there are plenty of Linux enthusiasts out there who have
the skills and imagination to make great contributions in these places."
The full article is available[2]
-- Ambassadors --
This section covers the news surrounding the Fedora Ambassadors Project[3].
Contributing Writer: Sankarshan Mukhopadhyay
1.
http://lists.fedoraproject.org/pipermail/marketing/2011-February/013714.html
2.
http://www.linux-magazine.com/Online/News/Beyond-FUDCon-with-Robyn-Berger...
3.
http://fedoraproject.org/wiki/Ambassadors
--- Welcome New Ambassadors ---
This week the Fedora Ambassadors Project had no new members joining.
--- Summary of traffic on Ambassadors mailing list ---
Pierros Papadeas posted [1] about Ambassador SOPs [2] on which FAmSCo has been working.
Clint Savage suggested [3] attending the FAD at SCaLE this year specifically mentioning
the Sysadmin Study Group
Buddhika Kurera informed [4] that the order for the FAm T-shirts [5] had been placed and
expected delivery is around end of March (impacted by the orders around the ICC Cricket
World Cup)
Neville A. Cross asked [6] if any other Fedora Project participants would be attending
PyCon from 2011-03-08 till 2011-03-13. Mark McIntyre responded [7] and provided his plans.
Max Spevack suggested [8] creating an Event page and also posting to devel at
lists.fedoraproject.org. The page [9] was created by Mark McIntyre
Pierre-Yves Chibon posted [10] the translated annual report [11] for Fedora-Fr, the French
speaking NPO.
David Ramsey provided prior notice [12] about Fedora 15 Test Days [13] coming up
David Ramsey posted [14] the draft Agenda [15] of the APAC meeting on 2011-03-05
Caius Chance informed [16] about having around 700 F14 LiveCDs with him at Brisbane and
wanted to get them to Fedora Ambassadors in APAC soonest. The thread [17] had requests
from Ambassadors who wanted the CDs.
Christoph Wickert announced [18] that the Trac instance used by the Fedora Board [19] was
open for ticket submissions by all FAS account holders.
Christoph Wickert provided an update [20] on the Fedora 14 media for EMEA
Max Spevack posted [21] an initial announcement of the Finance SIG [22]
David Ramsey posted [23] about Summer Coding Ideas for 2011 [24]
Larry Cafiero posted [25] Meeting Minutes from FAmNA meeting on 2011-03-01[26]
1.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017066...
2.
https://fedoraproject.org/wiki/Ambassadors_SOPs
3.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017071...
4.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017073...
5.
https://fedoraproject.org/wiki/User:Bckurera/APAC-shirts
6.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017077...
7.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017090...
8.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-March/017099.html
9.
https://fedoraproject.org/wiki/FedoraEvents/PyCon_2011
10.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017078...
11.
https://fedoraproject.org/wiki/Fedora-Fr_annual_report_2010
12.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017079...
13.
https://fedoraproject.org/wiki/Category:Fedora_15_Test_Days
14.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017081...
15.
https://fedoraproject.org/wiki/Meeting:APAC_Ambassadors_2011-03-05#Agenda
16.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017083...
17.
http://lists.fedoraproject.org/pipermail/famsco/2011-February/thread.html...
18.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017094...
19.
https://fedorahosted.org/board/newticket
20.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-February/017095...
21.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-March/017098.html
22.
http://lists.fedoraproject.org/pipermail/advisory-board/2011-March/010523...
23.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-March/017102.html
24.
https://fedoraproject.org/wiki/Summer_coding_ideas_for_2011
25.
http://lists.fedoraproject.org/pipermail/ambassadors/2011-March/017105.html
26.
http://meetbot.fedoraproject.org/fedora-meeting/2011-03-02/fedora-meeting...
--- Summary of events reported on Ambassadors mailing list ---
No event reports were posted to the Ambassadors mailing list.
--- Summary of traffic on FAmSCo mailing list ---
Caius Chance informed [1] about having around 700 F14 LiveCDs with him at Brisbane and
wanted to get them to Fedora Ambassadors in APAC soonest.
Max Spevack posted [2] an initial announcement of the Finance SIG [3]
1.
http://lists.fedoraproject.org/pipermail/famsco/2011-February/000687.html
2.
http://lists.fedoraproject.org/pipermail/famsco/2011-March/000688.html
3.
http://lists.fedoraproject.org/pipermail/advisory-board/2011-March/010523...
-- Quality Assurance --
In this section, we cover the activities of the QA team[1]. For more information on the
work of the QA team and how you can get involved, see the Joining page[2].
Contributing Writer: Adam Williamson
1.
http://fedoraproject.org/wiki/QA
2.
http://fedoraproject.org/wiki/QA/Join
--- Test Days ---
Thursday 2011-02-17 was Xfce 4.8[1] Test Day[2]. The event was well organized by the Xfce
team, and a dedicated group of testers was able to expose some important bugs to be
fixed.
The week of 2011-02-21 saw the traditional Graphics Test Week. Adam Williamson posted a
full recap of the event to the mailing list[3]. He noted that participation was up again
compared to the Fedora 14 events and that some important testing had been carried out, but
also noted a worrying trend in status of bugs from previous events, with many bugs
reported during the Fedora 13 and 14 events remaining unfixed. He promised to investigate
the causes of this.
This week (and next Tuesday!) is internationalization and localization Test Week, and Adam
Williamson put up a blog post[4] explaining the three Test Days this includes: the
Anaconda i18n and l10n Test Day on 2011-03-01[5], the desktop i18n Test Day on
2011-03-03[6] and the desktop l10n Test Day on 2011-03-08[7]. All these events are very
important to ensure that non-US-English-speaking users of Fedora get a great experience
with Fedora 15.
Thursday 2011-03-10 will be the second of three planned GNOME 3 Test Days[8], where
we'll continue to work with the GNOME team to test GNOME 3.0 and its integration with
Fedora 15 as rigorously as we can before the final release of both. We'll be repeating
the tests from the previous event to see how things have progressed, and also running some
new tests which have been added for this event. As before, this is a very important event
for both Fedora and GNOME and affects most Fedora users, so if you have a few minutes to
spare, please come along and help testing. Once again, live images will be available to
make it easier to test, and we'll have a new process in place for reporting crasher
bugs without the trouble of trying to install debuginfo packages on a live image!
1.
http://fedoraproject.org/wiki/Features/Xfce48
2.
http://fedoraproject.org/wiki/Test_Day:2011-02-17_Xfce
3.
http://lists.fedoraproject.org/pipermail/test-announce/2011-March/000200....
4.
http://www.happyassassin.net/2011/02/28/internationalization-and-localiza...
5.
http://fedoraproject.org/wiki/Test_Day:2011-03-01_L10n_i18n_Installation
6.
http://fedoraproject.org/wiki/Test_Day:2011-03-03_I18n_Desktop
7.
http://fedoraproject.org/wiki/Test_Day:2011-03-08_L10n_Desktop
8.
http://fedoraproject.org/wiki/Test_Day:2011-03-10_GNOME3_Beta
--- Fedora 15 Alpha preparation ---
The QA team has been busy over the last two weeks validating the Fedora 15 Alpha release,
with TC2[1], RC1[2], and RC2[3] candidate builds being posted and tested. As always, the
whole team chipped in with the all-important testing. In the end the RC1 image was not
accepted and the release delayed for a week[4] due to a significant bug with many
non-English keyboard layouts which was exposed during the testing. With this bug fixed,
the RC2 image was accepted as gold at the go/no-go meeting of 2011-03-02[5].
--- Bodhi improvements ---
At the weekly meeting of 2011-02-28[6], Luke Macken announced that package-specific test
case integration into Bodhi is now live, meaning that packages which have test cases
associated with them according to the package test plan SOP[7] will now have the test
cases displayed in Bodhi when an update for the package is under review. Also going live
in the new Bodhi release are the improvements to the automated messages Bodhi sends to
Bugzilla when an update's status changes, improvements discussed in previous issues of
this newsletter.
1.
http://lists.fedoraproject.org/pipermail/test-announce/2011-February/0001...
2.
http://lists.fedoraproject.org/pipermail/test-announce/2011-February/0001...
3.
http://lists.fedoraproject.org/pipermail/test-announce/2011-February/0001...
4.
http://lists.fedoraproject.org/pipermail/devel-announce/2011-February/000...
5.
http://meetbot.fedoraproject.org/fedora-meeting/2011-03-02/fedora_15_alph...
6.
http://fedoraproject.org/wiki/QA/Meetings/20110228
7.
http://fedoraproject.org/wiki/QA:SOP_package_test_plan_creation
--- FreeIPA Test Day problems and proposals ---
Dmitri Pal posted a comment to the FreeIPA Test Day trac ticket[1] noting that he was
unhappy with the way the event had turned out. Adam Williamson, James Laska and Jóhann
Guðmundsson joined in with suggestions to try and learn from this experience. Dmitri is
considering re-running the event with some tweaks.
1.
http://fedorahosted.org/fedora-qa/ticket/163#comment:10
--- Complications for Delta ISO users ---
Andre Robatino provided some detailed information[1] on what a change to the xz
compression scheme would mean for users of DeltaISOs. In a nutshell, users trying to use
Fedora 14 -> Fedora 15 DeltaISOs will need to use a workaround, detailed in the post,
if applying the ISO on a Fedora 14 system. Andre followed up later with a refinement of
the workaround[2].
1.
http://lists.fedoraproject.org/pipermail/test/2011-February/097009.html
2.
http://lists.fedoraproject.org/pipermail/test/2011-February/097284.html
--- IPv6 testing ---
A.J. Werkman provided a recap of some very solid testing he had performed on Fedora's
out-of-the-box IPv6 capabilities[1]. He identified some significant problems and reported
them as bugs, including anaconda refusing to work without an IPv4 DHCP lease, and
Fedora's Bugzilla not being available in the IPv6 domain.
1.
http://lists.fedoraproject.org/pipermail/test/2011-February/097153.html
--- Using abrt during Test Days ---
A thread[1] started by Mike Cloaked highlighted the issue of abrt being difficult or
impossible to use successfully from live images (such as during Test Days), in large part
due to the size of debuginfo packages. Adam Williamson pointed out[2] that the abrt
team's retrace server project[3] would be a perfect solution for this, but noted that
he had not yet tested using it. When he did, it seemed not yet to be ready for Fedora
15[4]. Jiri Moskovc said that the Fedora 15 support would soon be available[5].
1.
http://lists.fedoraproject.org/pipermail/test/2011-February/097271.html
2.
http://lists.fedoraproject.org/pipermail/test/2011-February/097289.html
3.
http://fedoraproject.org/wiki/Features/RetraceServer
4.
http://lists.fedoraproject.org/pipermail/test/2011-February/097299.html
5.
http://lists.fedoraproject.org/pipermail/test/2011-February/097314.html
-- Security Advisories --
In this section, we cover Security Advisories from fedora-package-announce from the past
week.
http://lists.fedoraproject.org/pipermail/package-announce
Contributing Writer: Pascal Calarco
--- Fedora 14 Security Advisories ---
none
--- Fedora 13 Security Advisories ---
* ruby-1.8.6.420-2.fc13 -
http://lists.fedoraproject.org/pipermail/package-announce/2011-March/0544...
* abcm2ps-5.9.21-1.fc13 -
http://lists.fedoraproject.org/pipermail/package-announce/2011-March/0544...
* telepathy-glib-0.11.16-2.fc13 -
http://lists.fedoraproject.org/pipermail/package-announce/2011-March/0544...
* telepathy-gabble-0.10.5-1.fc13 -
http://lists.fedoraproject.org/pipermail/package-announce/2011-March/0544...
-- LATAM Fedora! --
LATAM Fedora is a regular column of Spanish language contributions around open source
software. It is our first expansion into incorporating foreign language content into FWN.
This week's contribution is from Guillermo Gómez, a primer on Ruby. Enjoy!
--- Ruby Capítulo 1: El primer contacto ---
"Yo quería un lenguaje de programación más poderoso que Perl y más orientado a
objetos que Python. Entonces me acordé de mi viejo sueño y decidí diseñar mi propio
lenguaje. Al principio estuve jugando con él en el trabajo. Gradualmente creció lo
suficiente como para remplazar a Perl. Lo llamé Ruby en honor a esa piedra preciosa roja y
lo liberé al público en 1995."
Yukihiro Matsumoto, a.k.a. ``Matz Japan, October 2000
---- Aprovechando el espacio ----
Para comenzar en Fedora con Ruby vamos instalar lo mínimo necesario y sin perder mucho
espacio dando vueltas con teoría y opiniones, directo al grano. Abra una sesión de
emulación de terminal preferida y siga las siguientes instrucciones para instalar. En la
medida que desarrollemos esta columna dedicada a Ruby, entonces iremos descubriendo el
poder y flexibilidad de Ruby.
$ su -
<contraseña de root>
# yum install ruby ruby-rdoc ruby-ri
Para el editor, hay muchas opciones, mi editor de preferencia es Vim , pero puede usar el
de su preferencia, intente usar alguno que pueda resaltar sintaxis Ruby como mínimo. Puede
escoger desde entornos tan complejos y completos como Eclipse, hasta editores de
escritorio GUI como Gedit, o simples en consola como nano o complejos y sofisticados como
Vim y Emacs.
---- Los "Hola mundo" ----
La primera forma interactiva simple de ejecutar comandos Ruby es simplemente usar el
intérprete, simplemente ejecute el intérprete, ingrese los comandos y termine presionando
Ctrl-D para indicarle al intérprete que la entrada de comandos ha finalizado:
$ ruby
puts "Hola Mundo"
<Ctrl-D>
Hola Mundo
La segunda forma interactiva es con irb. irb es el acrónimo para Interactive Ruby. irb es
un shell Ruby, es decir, es un espacio donde puede evaluar su código al instante. En
próximas ediciones iremos desarrollando más el tema de irb, por ahora simplemente invoque
a irb e intente:
$ irb
irb(main):001:0> puts "Hola Mundo"
Hola Mundo
=> nil
irb(main):002:0>exit
$
Si lo que quiere es crear un programa Ruby que nos imprima "Hola Mundo" en la
salida del monitor, lance su editor e incluya el siguiente código fuente en un archivo
denominado holamundo.rb., guarde y salga de su editor.
----- holamundo.rb -----
1 puts "Hola Mundo"
Para ejecutar simplemente pásale al intérprete Ruby el archivo como argumento.
[gomix@fricky capitulo_1]$ ruby holamundo.rb
Hola Mundo
También puede usar el método "shebang" y convertir el archivo fuente Ruby en
ejecutable del sistema, edite su holamundo.rb para que luzca como se muestra en el listado
a continuación.
----- holamundo.rb -----
1 #!/usr/bin/ruby
2
3 puts "Hola Mundo"
[gomix@fricky capitulo_1]$ chmod +x holamundo.rb
[gomix@fricky capitulo_1]$ ./holamundo.rb
Hola Mundo
Existe la forma de pasarle directamente código Ruby al intérprete sin apoyo de archivos o
programas adicionales y sin entrar en modo interactivo.
$ ruby -e 'puts "Hola Mundo"'
Hola Mundo
---- Ruby es un lenguaje de programación orientado a objetos ----
Todo lo que usted manipula en Ruby es un objeto, y los resultados de dichas manipulaciones
a su vez, también son objetos. Cuando usted escribe código orientado a objetos normalmente
está modelando conceptos del mundo real en su código. Típicamente durante este proceso de
modelado usted descubrirá categorías de cosas que necesitan ser representadas en código.
En un reproductor de música el concepto de "canción" puede ser una de esas
categorías. En Ruby usted define una clase para representar cada una de esas entidades.
Una clase es una combinación de estado, por ejemplo el nombre de la canción, y métodos que
usan dicho estado, por ejemplo para reproducir la canción.
Una vez que tiene dichas clases usted creará instancias de dicha clase. Para el
reproductor de música que contiene la clase Cancion usted terminará teniendo instancias
separadas independientes para canciones populares como "Todo o nada",
"Canción para un amigo", "Amanecer llanero", y por el estilo. La
palabra objeto e instancia son intercambiables. En Ruby para crear dichas instancias u
objetos, se debe llamar a un método constructor de la clase, el método constructor
estandar se llama new.
1 cancion1 = Cancion.new("Amanecer llanero")
2 cancion2 = Cancion.new("Todo o nada")
Estas instancias son derivadas de la misma clase pero tienen características únicas.
Primero, cada objeto tiene un object_id único. Segundo, usted puede definir variables de
instancia, variables con valor que son únicos para cada instancia. Estas variables de
instancia mantienen el estado del objeto. Igualmente puede definir métodos de instancia
para acceder y/o alterar el estado del objeto, es decir, acceder y/o alterar las variables
de instancia. Rápidamente definamos nuestra clase Cancion. Ruby se puede leer fácilmente.
1 class Cancion
2 def titulo
3 @titulo
4 end
5
6 def titulo=(titulo_de_la_cancion)
7 @titulo = titulo_de_la_cancion.to_s
8 end
9 end
Claramente podemos ver y leer que hemos definido la clase de nombre Cancion con dos
métodos de instancia, titulo y titulo=. La variable de instancia se representa en @titulo
, con la notación de nombre de variable en minúscula precedida del símbolo @ .
Note la indentación que hemos implementado para representar la estructura, dos espacios es
cómun entre los Rubyeros (me gusta llamarlos así).
Es evidente que la plabra clave class establece el inicio de un bloque que se cierra con
end para definir una clase con nombre, en este ejemplo Cancion. Dentro de dicha estructura
también podemos identificar claramente la palabra clave def que igualmente define bloques
que se cierran también con la palabra clave end. def define dos métodos de instancia en
este ejemplo. Hablaremos más de def de forma recurrente en muchas ediciones de esta
columna.
Podemos probar nuestra clase en irb fácilmente, por ahora tipee con cuidado para no
equivocarse, luego le ofreceré más técnicas irb.
1 $ irb
2 >> class Cancion
3 >> def titulo
4 >> @titulo
5 >> end
6 >> def titulo=(titulo_de_la_cancion)
7 >> @titulo = titulo_de_la_cancion.to_s
8 >> end
9 >> end
10 => nil
11 >> cancion1 = Cancion.new
12 => #<Cancion:0xb76e25c8>
13 >> cancion1.titulo="Alma llanera"
14 => "Alma llanera"
15 >> cancion1.titulo
16 => "Alma llanera"
---- Pero no necesito clases ----
También se puede usar Ruby del modo procedimental, funcional, sin necesidad de crear
(explícitamente) clases y objetos.
1 $ irb
2 >> 2 + 2
3 => 4
Pero igual note que estamos trabajando con objetos de alguna clase, en nuestro ejemplo
Fixnum.
1 >> 2.class
2 => Fixnum
Puede definir métodos y llamarlos:
1 >> def saludo
2 >> puts "Hola Mundo"
3 >> end
4 => nil
5 >> saludo
6 Hola Mundo
7 => nil
---- Clases base ----
Ya que "todo" son objetos de alguna clase, más vale que comencemos por aprender
las más fundamentales del lenguaje, Fixnum, Bignum, Float, String, Array y Hash.
Números... Fixnum, Bignum, Float
Enteros, dejemos que nuestro código Ruby hable.
1 >> num = 8
2 => 8
3 >> 7.times do
4 ?> print num.class, " ", num, "\n"
5 >> num *= num
6 >> end
7 Fixnum 8
8 Fixnum 64
9 Fixnum 4096
10 Fixnum 16777216
11 Bignum 281474976710656
12 Bignum 79228162514264337593543950336
13 Bignum 6277101735386680763835789423207666416102355444464034512896
14 => 7
15 >> num = 3.14
16 => 3.14
17 >> 8.times do
18 ?> print num.class, " ", num, "\n"
19 >> num *= num
20 >> end
21 Float 3.14
22 Float 9.8596
23 Float 97.21171216
24 Float 9450.11698107869
25 Float 89304710.9560719
26 Float 7.97533139894754e+15
27 Float 6.36059109230385e+31
28 Float 4.04571190434951e+63
---- Cadenas de caracteres, String ----
1 >> "Hola Mundo".class
2 => String
3 >> "987".class
4 => String
<
---- Arreglos, Array ----
1 >> arreglo = ["a",1,"b",2]
2 => ["a", 1, "b", 2]
3 >> arreglo.class
4 => Array
5 >> arreglo[0]
6 => "a"
7 >> arreglo[1]
8 => 1
<
---- Arreglos indexados arbitrariamente, Hash ----
1 >> hash = { "color" => "rojo", "temperatura"
=> 75, 1 => "hoy"}
2 => {1=>"hoy", "temperatura"=>75,
"color"=>"rojo"}
3 >> hash.class
4 => Hash
5 >> hash["color"]
6 => "rojo"
7 >> hash["temperatura"]
8 => 75
9 >> hash[1]
10 => "hoy"
---- Recapitulación rápida, los objetos y sus métodos, ¿documentación? ----
Teniendo cualquier objeto de cualquier clase a la mano, para acceder a su métodos podemos
usar la sintaxis objeto.método. En el ejemplo abajo llamamos al popular método to_s que
nos ofrece una representación en String del objeto en cuestión.
1 >> hash.to_s
2 => "1hoytemperatura75colorrojo"
3 >> arreglo.to_s
4 => "a1b2"
5 >> 8.to_s
6 => "8"
Ahora bien, ¿dónde consigo la documentación de dichas clases y métodos? Demos la
bienvenida a ri para ayuda local en línea de comandos, y por supuesto, en la web a
http://www.ruby-doc.org/ . Francamente, en nuestros días la primera fuente de información
es la Web, y en segundo lugar, nuestros recursos locales como ri. Entonces, y para efectos
de esta serie de artículos, vamos a usar inicialmente Ruby 1.8.7.
*
http://www.ruby-doc.org/core-1.8.7/
*
http://www.ruby-doc.org/stdlib-1.8.7/
Ejemplo de salida ri (extracto).
$ ri Fixnum
------------------------------------------------ Class: Fixnum < Integer
A +Fixnum+ holds +Integer+ values that can be represented in a
native machine word (minus 1 bit). If any operation on a +Fixnum+
exceeds this range, the value is automatically converted to a
+Bignum+.
...
Instance methods:
-----------------
%, &, *, **, +, -, -@, /, <, <<, <=, <=>, ==, >, >=,
>>, [], ^,
__serialize__, abs, dclone, div, divmod, html_safe?, id2name,
modulo, power!, quo, rdiv, rpower, size, to_f, to_s, to_sym, xchr,
zero?, |, ~
---- Ruby es dinámico ¿ 2 + 2 = 4 ? ----
Uno de los aspectos notables de Ruby es su dinamismo, una forma de visualizarlo es hacer
uso del hecho que todas las clases están "abiertas" y es posible redefinir sus
métodos, por ejemplo:
----- fixnum_mod.rb -----
#!/usr/bin/ruby
#
class Fixnum
def +(otro)
100
end
end
puts (2+2).to_s
----- Y ahora ejecutamos nuestro programa: -----
$ ruby fixnum_mod.rb
100
Horror, hemos echado a perder el método sumar de Fixnum, por ello algunos consideran
peligroso los lenguajes dinámicos, sin embargo existe la forma de protegernos de este tipo
de modificaciones en el caso de que ello no sea deseable. El ejemplo sin embargo demuestra
que toda clase puede redefinir cualquiera de sus métodos en tiempo de ejecución, en
cualquier momento, este dinamismo le da gran poder a Ruby, piense en una clase u objeto
que evoluciona y gana funcionalidad en el tiempo de existencia del programa, o que la
pierde, su funcionalidad puede mutar, cambiar. No puede devolver el cambio, no sin que le
enseñe cómo preservar el código sobrescrito, probablemente en la próxima edición de esta
columna.
---- Estructuras de control ----
Por supuesto que ningún lenguaje está completo si no tiene la capacidad de ejecución de
código condicionada, es decir, evaluar alguna condición o estado, y proceder en
consecuencia de distintas maneras. Abajo le resumimos las estructuras más comunes.
1 # Evaluacion máxima 20
2 if evaluacion < 10
3 puts "Usted reprobó la asignatura."
4 elsif evaluacion > 16
5 puts "Usted obtuvo un grado sobresaliente."
6 else
7 puts "Usted aprobó la materia."
8 end
1 unless unaCancion.duracion > 180 then
2 costo = .25
3 else
4 costo = .35
5 end
1 case forma
2 when Cuadrado, Rectangulo
3 # ...
4 when Circulo
5 # ...
6 when Triangulo
7 # ...
8 else
9 # ...
10 end
---- Lazos e iteradores ----
Un iterador en Ruby es simplemente un método que puede invocar un bloque de código. Note
como se pasa la referencia del bloque de código y este a su vez ejecutado por medio de la
llamada yield.
Ruby Salida
1 def tres_veces Hola mundo
2 yield Hola mundo
3 yield Hola mundo
4 yield
5 end
6
7 tres_veces { puts "Hola Mundo" }
Algunos iteradores son muy comunes en muchas clases Ruby para representar colecciones, por
ejemplo each en un arreglo simple. Note que each además de iterar por cada uno de los
elementos del arreglo, pasa un argumento al bloque de código ha ser ejecutado, en este
caso pasa el contenido correspondiente en el arreglo.
Ruby Salida
i| puts i } 1
3
5
7
9
Lazos con while y until.
Ruby Salida
1 peso = 5 10
2 while peso < 100 20
3 peso = peso * 2 40
4 puts peso 80
5 end 160
Ruby Salida
1 peso = 5 10
2 until peso > 100 20
3 peso = peso * 2 40
4 puts peso 80
5 end 160
---- Lazo con for y loop: ----
Ruby Salida
1 for i in 1..8 do 1
2 puts i 2
3 end 3
4
5
6
7
8
Ruby Salida
1 num = 0 En el lazo por 0 vez
2 loop do En el lazo por 2 vez
3 puts "En el lazo por #{num} vez" En el lazo por 2 vez
4 num += 1 En el lazo por 3 vez
5 break unless num < 5 En el lazo por 4 vez
6 end
De salida, por supuesto hay mucho más acerca de Ruby y su mundo, usted podrá hacer desde
pequeños guiones (scripts) hasta poderosas aplicaciones de escritorio o su último
desarrollo web, no se detenga aquí y espero que nos leamos en la próxima entrega de esta
publicación, envíeme sus comentarios a <gomix(a)fedoraproject.org>.
Nuestro trabajo es resolver problemas concretos, no alimentar al compilador con
cucharilla, nos gustan los lenguajes dinámicos que se adapten a nosotros sin reglas
rígidas que seguir.
Gomix_
- end FWN 265 -
---
Pascal Calarco, Fedora Ambassador, Indiana, USA