Duncan Mac-Vicar P.


Archive for August, 2009

ruby block syntax

without comments

Reading a commit from DHH I found out a syntax I was not aware of.

Instead of doing:

[1,2,3,4,5,6,7,8,9,10].select { |x| x.even? }

You can do:

[1,2,3,4,5,6,7,8,9,10].select(&:even?)

When I asked in #rubyonrails irc channel about this syntax, I got enlightened: The first part is obvious: last argument starting with & is interpreted as a Proc and equivalent to passing a block, so it is not a &: operator but & and a symbol. How does the symbol work?

According to the people in the channel, it is rails magic. When I said that it works for me in irb I was told I must be running ruby 1.9, which I am not. After some discussion we realized this magic is in ruby 1.8.7 too.

The magic is of course, just Symbol#to_proc method ;-)

Written by duncan

August 27th, 2009 at 12:52 pm

Posted in Software

Tagged with , ,

Rails engines and static assets (public/)

without comments

I was very happy that Rails Engines got merged in Rails 2.3. However I never liked that engines did not support overlaying static assets like they do with controllers, models and views. Even worse, the discussion was around “mirroring” the engine’s assets into the application public/ directory (like you can see in this railcast).

I imagined that doing something more transparent would be non-trivial. But I never asked myself why. When mentioning this limitation to Daniel when explaining how we use engines in our code, he asked the magical question: “Why?”.

I have been looking at Rails’s Rack support recently. I love Rack. And if you see how Rails builds its complex pieces over such simple components based on Rack, you realize how good Rack is for the Ruby community as a base component.

So, I tried the very first though: Create a Rake middleware called StaticOverlay that is initialized with various overlay directories. When the middleware is called it will look for the file in the overlays, and if it finds it in one, it will serve it (using Rack::File), if not, it just call the application (or next middleware in the chain).

Once I put the rack middleware together it worked out of the box, so I started a thread in rails core list to find out whether this would be a valid approach to hack a real patch and add support for this in Rails itself.

Written by duncan

August 27th, 2009 at 12:33 pm

Posted in Software

Tagged with , ,

SUSE Appliance Program WebYaST alpha demo

with one comment

Together with the launch of SUSE Studio 1.0, an alpha demo of WebYaST was also included in the Appliance Kit preview. We talked about WebYaST earlier this year. The demo includes small functionality like setting the system language, system time, patches/updates and general status of your appliance.

WebYaST mission is to add value to your appliance by providing the basic setup requiring only a web browser. The idea is that you build your appliance with Studio and include WebYaST so you can perform setup, configuration and basic monitoring.

The WebYaST demo is available as an appliance (built with SUSE Studio) on the Novell Appliance Program page. Advanced users can follow the YaST:Web repository on the openSUSE Build Service.

Built with SUSE Studio

Haven’t tried SUSE Studio yet? Here is a nice demonstration video.

If you are an ISV, you may also want to checkout the upcoming SUSE Lifecycle Management Server, everything you need to serve your appliance customers with your application plus operating system updates.

Written by duncan

August 4th, 2009 at 11:09 am

Posted in Software

Tagged with

osc-plugin-overview 0.3 released

without comments

Packager’s favorite dashboard got a new version. Most patches were contributed by Michael Andres.

  • follow links to a package with different package name.
  • adapt to changed API to retrieve submitrequests.
  • support ‘changes=1′ in ini-inifile to print changelogs per section (like -c)
  • osc no longer takes the md5 as revision.
  • cleanup changelog diff temp files
  • suppress changelog diff if source does not provide changes ( like obssr)
  • let changes diff consider only repos that actually provide changes.

Get it from [the build service], or visit the home page here. You can read the introductory post here.

Written by duncan

August 4th, 2009 at 9:09 am

Posted in Software

Tagged with

Kopete Facebook plugin 0.1.3 released

with 24 comments

Available for openSUSE Factory in my home project. I also submitted to the KDE:KDE4:Factory:Desktop project where you may find it built for older releases using a newer KDE.

Changes:

  • Some connection fixes
  • The idle status icon is now shown
  • Basic user info widget (bug #198286)
  • Show contact status message! (bug #198284)
  • build system improvements
  • qjson 0.6.x is now required

Known bugs:

  • The plugin crashes when exiting Kopete. Some weird stuff with “myself” contact which seems to be deleted twice

Note: This plugin is not associated with Facebook in any way.

Written by duncan

August 4th, 2009 at 8:58 am

Posted in Software

Tagged with ,