Twitter Gem Gets STDIN

Jeremy, from my local ruby group, had a sweet idea. He was piping crontab commands into mail and thought “why not use twitter?” He hacked around a bit and sent me some code. I tweaked a couple things and now, as of version 0.2.6, the twitter gem can take stdin when posting from the command line. Below are a few examples from the changelog.

$ twitter post 'test without stdin' 
# => twitters: "test without stdin"

$ echo 'test with stdin' | twitter post 'and an argv[1]' 
# => twitters: "test with stdin and an argv[1]"

$ echo 'test with stdin without any argv[1]' | twitter post
# => twitters: "test with stdin without any argv[1]"

If you are curious about the implementation, see the bottom of the bin/twitter file.

A Recent Cool Use of the Twitter Gem


Also, while on the topic of twitter, some pals of mine are repurposing the twitter gem to do reviews (and they were even so kind as to update the gem and send a pull request). If you are a twitterer, check out

1 Comment

  1. Nice! :)

Sorry, comments are closed for this article to ease the burden of pruning spam.


Authored by John Nunemaker (Noo-neh-maker), a programmer who has fallen deeply in love with Ruby. Learn More.


Release your software more often with fewer problems.
Flip your features.