Open source is weird. It’s weird because it works. The entire internet - ALL of the tubes - is built on free and open projects, built by people who for the most part just want to. It’s a paradox. No where else have we seen a philosophy like this work so well. So that’s cool.

TYLER, is my first open source project. My previous blog post goes in to more detail about my process originally creating it, so check that out if you haven’t already.

As previously mentioned, RubyGems is a package manager. It’s sole purpose is to host gems so we as Rubyists can easily find and install them. The beauty of the system is that, anyone can add their own gem and make it available to download and use. To take it a step further, you can add your gem to Github, so the community can contribute to your project.

TYLER, revisited

Since building the gem, our project structure looks like this:

├── TYLER-0.0.2.gem
├── lib
│   └── tyler.rb
├── license.md
├── readme.md
└── tyler.gemspec

Since building our gem, we now have a .gem file. This is what we’ll actually push to the RubyGems. Before that, though, let’s just test one. last. time. It would be unfortunate if we pushed a broken gem to our millions of loyal fans.

To test the installation, from our project folder:

gem install ./TYLER-0.0.1.gem

Now, open irb and enter

require 'TYLER'

That should return true. Forcing a NameError should give you something like this:

require 'TYLER'
asd
NameError: Wrong! Ha. Ha ha. I'm not laughing at you, I mean, well, yes I am.
  from (irb):2
  from /Users/tylerdavis/.rvm/rubies/ruby-1.9.3-p385/bin/irb:16:in `main'

Deploying TYLER

Now that we’ve successfully tested our gem, we are ready to deploy to RubyGems. The first thing we need to do is authenticate with RubyGems. You can do this with

☺ curl -u tylerdavis https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials
Enter host password for user 'tylerdavis':

This will respond by asking you for your password. Once you’ve put that in, your gem has the credentials necessary to push to your repository up to RubyGems.

Now, push!

☺ gem push TYLER-0.0.1.gem
Pushing gem to RubyGems.org...
Successfully registered gem: TYLER (0.0.1)

Finally, check to make sure the gem been posted.

☺ gem list -r TYLER

*** REMOTE GEMS ***

tyler (0.1.0)
TYLER (0.0.2)
tyler_gem (0.0.0)
tylerrick-bcms_blog (1.0.6)
tylerrick-chef (0.10.9)

☺ gem install TYLER
Successfully installed TYLER-0.0.1
1 gem installed

NOTE: There is only one real TYLER.

Opensourcing TYLER

So now that we have a working gem and it’s available for people to download from RubyGems, we want to intialize a git repository and push it to Github. Nothing special here:

touch readme.md
echo '*.gem' > .gitignore
git init
git add .
git commit -m "Initial commit"
git add remote origin git@github.com:tylerdavis/tyler.git
git push -u origin master

And you’re done! Now, with any luck, you’ll get some interest and start seeing some pull requests!

I wanted to give a special thanks to Steve Klabnik for his contribution to TYLER and awesome lesson in meta-programming with Ruby.

StatusPage is hiring engineers in San Francisco, Denver and Durham. If you'd like to be part of our incredible team, follow the link, or shoot me an email at tyler at statuspage dot io. We'd would love to chat with you.