If you're running Xcode 5.1, the command line tools don't work for nokogiri 1.6.1. You'll need to download the Late october 2013 tools from Apple. Once you do that run
$ sudo xcode-select -s /Library/Developer/CommandLineTools/
to set up your machine to use the Xcode 5.0.X command line tools, then run
$ gem install nokogiri
If you want to reset your command line tools to the Xcode.app version afterward run
$ sudo xcode-select -r