Category Archives: Coding

Pacgem – Rubygems installer for Arch Linux

I created a pacman wrapper program which allows direct installation of rubygems. It is called pacgem and available in AUR.

The program does the following steps:

  1. Resolve gem dependencies
  2. Create PKGBUILD
  3. Generate package using makepkg
  4. Check package with namcap
  5. Optionally install package with sudo pacman -U

The generates package tries to do the best in fixing bad rubygem practices. It has a automatic detection for dynamic linking dependencies using `readelf`. Man pages are installed to /usr/share/man and the license file to /usr/share/licenses if the gem provides a custom license.

I would be interested in some feedback and testing. I tested it with ruby 1.9.2 and 1.8.7 and some ruby packages (haml, rack, unicorn). The goal is to get the package quality to an acceptable level (comparable to hand written PKGBUILD). There are nearly no complaints of namcap for the packages I tested.

Download-Links:

New template engine for Ruby: Slim!

If you are developing ruby web applications you have certainly heard of the template language Haml. When I first discovered haml I found it quite convenient compared to the default template language ERB. But still, Haml is ugly, especially the attribute syntax. Besides it wasn’t the fastest template language. But now there is an alternative, inspired by Haml and Jade: The Slim Template Language!

It is available on github http://github.com/stonean/slim and on the homepage http://slim-lang.com/.

Take a look!

doctype html
html
  head
    title Slim Examples
    meta name="keywords" content="template language"

  body
    h1 Markup examples
    #content.example1
      p Nest by indentation
      p
        a href=page_path(@page) Link to page

    = yield

    - unless items.empty?
      table
        - for item in items do
          tr.item
            td = item.name
            td = item.price
    - else
      p No items found

    #footer
      | Copyright © 2010 Andrew Stone

    = render partial: 'tracking_code'

Pretty self-explaining, isn’t it? Especially the attribute syntax is really slick, if you compare:

Slim:

        a href=page_path(@page) Link to page
        a href=page_path(@page) Link to page

Haml:

        %a{:href=>page_path(@page)} Link to page
        %a(href="#{page_path(@page)}") Link to page
        a href=page_path(@page) Link to page

Erb:

        <a href="<%=h page_path(@page) %>">Link to page</a>