Musings of a Gotham City Geek

What is the sound of one blog clapping?

 

One of Ruby's strongest traits as a language is its community.

Matthew Jording:

Nick Fitzgerald, posted a nice piece on object oriented code on new years eve 2010. Yes he was blogging about programming on NYE. Whats perhaps more telling is I tweeted and read it as it came out.

One of the reasons I was happy to see a OO post on Ruby is the rarity. In our weekly meetup we don’t cover it enough. I think this is because seasoned Rubyists assume to have a working knowledge of the Ruby’s Object structure and new Rubyists tend to be facilitated by Ruby’s meta-programming side. Ignoring OO discussion can be a huge problem. As Yahuda Katz ( the man who saved Rails ) pointed out in a few rants as he walked through the shadow of active record that

rush

rush is a replacement for the unix shell (bash, zsh, etc) which uses pure Ruby syntax. Grep through files, find and kill processes, copy files - everything you do in the shell, now in Ruby. Previously if you wanted to count the number of classes in your project, you might use a bash command like:

find myproj -name \*.rb | xargs grep '^\s*class' | wc -l

In rush, this is:

myproj['**/*.rb'].search(/^\s*class/).lines.size

Some friends from the NY Ruby meetup picked up this project and plan to revive it, with the goal of building a better deployment solution. If you are a Rubyist and wish you could use Ruby on the command line without any extra switches or pragmas, then you owe it to yourself to try rush. Better yet, if you are looking for a sweet deployment solution—something better than Capistrano, more akin to the magical deployment process of Heroku (where rush originated)—then you need to fork the Git repo and jump on the wagon with us. You’ll be amazed!

Chalk it up to Rails?

Note: I post this because this CMS can be run on the Mono stack on *nix and Mac. Also, it is interesting to note, the combination of embedded code in the html, or vice-versa, while having a flavor of classic ASP, hints at some of the newer features availablr in templating in Ruby on Rails…

Graffiti uses a very simple templating language to render its themes called Chalk (Chalk is the combination of NVelocity and Graffiti goodies).

While we do call this a language, do not let the name full (sic) you. Chalk is much simpler than anything you have used to build web pages in the past. With this system, you can write your HTML/CSS as you would do normally and then decorate it Chalk. When Graffiti renders a view file, it will find all of your Chalk items and replace with your site content.

Here are some of the more common things you will do with Chalk.

Properties - Format $ItemName.PropertyName - properties allow you access to addition information about an item. As an example, to display the title of a post, you would use $post.Title

Methods - Methods are similar to properties except they usually require you supply additional information. As an example, to render a list of comma seperated tags as links for the current post and wanted to avoid writing a lot of Chalk, you could use the TagList method on the macros helper: $macros.TagList($post.TagList). Here we are passing in the $post.TagList property to the macros.TagList method.

Conditions - There are times you will want content shown only if a certain criteria is met, to do so you can use an if/elseif/else. Most conditional operators are supported (==, >, >=, <, <=, !=).