Working with Ruby
Hi, I am Jan. This is my old Ruby blog. I still post about Ruby, but I now do it on idiosyncratic-ruby.com. You should also install Irbtools to improve your IRB.

value_struct: Read-only structs in Ruby

Ruby’s structs are one of my favorite data types in Ruby. They help you to keep some defined structure in the dynamic world of Ruby. Often, it makes sense to use them instead of hashes or arrays. Read-only structs take the idea a level further.

…read

Things I learned while implementing version 1.0 of pws

After releasing version 0.9 of my cli password manager, I received friendly feedback and suggestions, which encouraged me to further improve it. Here are some of my experiences implementing pws 1.0:

…read

pws: The ruby-powered command-line password manager

  • stores your passwords in a file on your disk
  • encrypts the file with a master password
  • is designed for every-day-use
  • is written in 234 lines of understandable Ruby code… Read it!
  • is tested with 222 Cucumber steps

Pass multiple blocks to methods using named procs

My codebrawl entry (gist) got the 5th place (out of 20). Want to use it in real life :)

…read

Three little tips for slimmer Rails migrations

Rails migrations are easy to understand and easy to write. However, you can save some unnecessary key strokes by applying these three tips :)

…read

Small Ruby CLI Improvements (Part 3): Hirb vs. Unicode

Hirb: “A mini view framework for console/irb that’s easy to use, even while under its influence. Console goodies include a no-wrap table, auto-pager, tree and menu.” now supports unicode in two ways:

┌───────────────────────────────────────────┬───────────────────────────────────────────────┐ │ Support for unicode full-width characters │ Unicode table characters instead of +/- chars │ └───────────────────────────────────────────┴───────────────────────────────────────────────┘

…read

Small Ruby CLI Improvements (Part 2): Wirb!

Many people use irb with wirble. I also did.

I’ve been quite happy with it, but sometimes I noted that some symbols were displayed as : without the symbol name (e.g. in method name arrays) and that the representation of regexes looked quite strange.

This is why I’ve looked at the wirble tokenizer, fixed some bugs, liked it, extended it and created Wirb. These are the improvements:

…read

ripl: Why should you use an irb alternative?

What does it mean when the guy who blogged about irb’s details and wrote most of the successful irb gems (hirb, bond, boson) decides to implement his own irb alternative? There must be something wrong with irb!

…read

Use fresh Ruby as your shell!

We love Ruby. And we love the command line. So… the shell needs to be rubyfied ;).

Fresh is a new gem, trying to achieve this.

Updated for fresh version 0.2.0.

…read

IRB rockets and colors

Introducing the fancy_irb gem:

  • Use fancy colors! You can colorize the prompts, irb errors, stderr and stdout
  • Output results as Ruby comments
  • Enhance your output value using procs

Tutorial: Build your own password safe with Ruby!

There are many implementations of password managers/safes out there. But lots of them are black boxes, either because they are not open source, or because they have to much features and it gets complicated to understand the source (which is most likely not written in a happy programming language). You don’t know, what really happens with your passwords. So…

Do it yourself!
Do it with Ruby!
Do it in less than 250 lines ;)

…read

irbtools / Release the power of irb!

Equipped with some tools discussed at the germany.rb 2010 user group meetup, I’ve played around with my ~/.irbrc and put together a little meta gem for some useful irb tools (github)

…read

Gem: clipboard

The clipboard gem allows you to access the clipboard on Liunx, MacOS and Windows.

…read

Requirements: A Mini RubyGems plugin

The .gemspec file of a gem allows to specify requirements for that gem – but usually you do not get to see them. These five lines patch RubyGems, so that gem displays the requirements of a gem after it has been installed:

…read

How to properly check for your Ruby interpreter, version and OS

Zucker 4 adds accessors to some environment information:

  • OS: returns the current operating system
  • RubyEngine: returns the current Ruby implementation
  • RubyVersion: returns the current Ruby version

And here is how it works.

…read

New features of Ruby Zucker version 2 and 3

The Zucker gem has gotten some new features. Installation is as easy as
 gem install zucker
and
 require 'zucker/all'

…read

Introducing Ruby Zucker - a new syntactical sugar gem

Zucker is a collection of lightweight scripts (cubes) that make Ruby even more beautiful: rubyzucker.info

…read

The has_many_booleans Rails plugin

has_many_booleans is an ActiveRecord plugin which creates virtual boolean attributes for a model. When the object gets saved, the plugin transforms all attributes into a single integer, using a bitset. So you can easily add new attributes without changing the database structure.

…read

Troubleshooting an aegis-permission problem

In my current Rails project, I use the aegis gem for rights management. And I almost got mad, wondering, why it wouldn’t work..

…read