Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts

Thursday, March 12, 2015

A little Ruby trick to DRY up your Gemfile

Here's a trick I learned today

The Problem

You've got a Ruby on Rails project with a Gemfile and a .ruby-version file at the root of your project, and, as is quite normal, your Gemfile contains the line ruby '2.1.0'. Now you want to update Ruby to 2.2.0 so you have to remember to change both the .ruby-version and the Gemfile which is a PITA and not especially DRY approach.

The Solution

A Gemfile is just Ruby, so instead of saying ruby '2.2.0' use ruby File.read('.ruby-version').match(/(\d+\.\d+\.\d+)/).to_s instead. This will read the Ruby version info directly from your .ruby-version file and save you some hassle.

Neat huh.

Wednesday, September 08, 2010

Let's be Frank (Sinatra)

I've got some spare time these days and my wife has, graciously, agreed to support me while I learn some new stuff. Namely Objective C and Ruby. More on my Obbjective C and iPhone ambitions later however, for now I want to introduce a little project called Frank.

How awesome is Ruby! And how amazing is the Sinatra web application language built on top of Ruby? It took me two days, starting from hardly ever having coding any Ruby, but I have a working micro-web app framework with user login and some unit tests built on Sinatra and Active Record.

I've opened a project in GitHub called Frank and now aim to round this out to be a well documented canonical example.

Frank is intended to be a very simple but feature complete web-app built on top of Sinatra that provides simple user login, password reminder, and user email verification with support for simple roles. It is intended to be used by other developers as both a well documented example of Sinatra in use, and a starting point for others wishing to implement simple web apps very quickly.

If this sort of thing interests you, and you'd like to contribute to the project at all, please get in touch via GitHub.