Sam Soffes

How to Build a Ruby Gem

Posted on

This is my first post on the Treehouse Blog. I did an 8 minute video tutorial on how to make a Ruby gem with Bundler. Check it out.

The code from this video can be found here: github.com/soffes/adder. Here is Ruby's module_function documentation.

Hi, I’m Sam Soffes. I’m going to show you how to create and distribute a Ruby Gem. So, let’s say you have some really fancy code that adds 2 numbers together. We’re going to package this up into a Ruby Gem called Adder and you shoot it on Rubygems.org, so anyone can Gem install Adder and use our code. First off, you’ll need Bundler. If you don’t already have Bundler, you can easily install it with Gem install bundler. Now, simply Run, Bundle, Gem, and the name of your Gem. So, in this case, Adder. Great, and you can see here it generated a bunch of files for our Gem so, we’ll open this up in Sublime and try it out. So, most importantly it generated a Gem spec for us. and you can see it has some placeholder values. I’ll go ahead and fill this in. It’s a good idea to add a required Ruby version, that way if you’re using features that aren’t available in 187 or 192 or whatever, Rubygems won’t let you install it on a Ruby that’s not supported. Kind of on a side note, if all you’re using 19 for is the hash syntax, it’s a good idea to go ahead and use the old 187 syntax, so more people can use your code. I really prefer the 19 syntax, but I usually end up switching, just so I can support 187. If that’s the only change, no reason not to.

Continue reading →

Sublime Text 2 Configuration

Posted on

For a long time, I've been symlinking my Sublime Text configuration from Dropbox to where it wants it. Last night, I wiped my computer and remembered how handy this is.

Someone on Twitter suggested that I put it in git instead. Definitely a much better idea. Here's my Sublime Text configuration. It just adds packages I've installed that aren't the default, my theme, and of course all of my preferences.

Hopefully you find it useful.

Continue reading →

New Blog

Posted on

I redo my blog a lot. This time around, it's very different than past iterations. Everything is stored in git and cached in Redis.

After being inspired by Waza this year, I decided to have a more durable way to store my posts. Instead of storing years of work in Postgres, I decided to store them on GitHub. I even took the time to go through Archive.org and try to find as my old posts as I could find.

I'm not worried about Postgres durability. I'm more worried about accidently deleting my database or my dev database getting corrupted. Anyway, having them on my computer, external backups, and on GitHub is a good feeling. Granted I could have done that with Postgres, but managing markdown files on my computer is fun and easy.

Continue reading →