RubyRef — easy access to Ruby documentation
I don’t know about you, but I can’t really remember the last time I added a bookmark to my browser (at least not on purpose, -D is right next to -F after all). So when I saw rustref.com, I knew I wanted to build something like this for the Ruby community, which is now available as rubyref.net.
tl;dr
RubyRef defines a list of CNAME records of the form *.rubyref.net which redirect to different Ruby related documentation sites. For example ruby.rubyref.net brings you to the core documentation, whereas api.ruby.net redirects to the C API documentation and awesome.rubyref.net will take you to the awesome-ruby repository on GitHub.
Architecture
Update: It’s now a static site generated with Middleman and hosted on Netlify, but the CloudFlare page rules are still used, as is the Rake task.
Manually defining a bunch of CNAMEs is not what I call a fun afternoon activity, but writing code is. So RubyRef uses a Roda app ) in combination with Cloudflare page rules to achieve its goal. Let’s have a look at the app first (current code / roda branch):
This reads a list of redirects from a file called redirects.json, where the various CNAMEs are mapped to their respective target URLs. The actual redirects happen through requests of the form GET https://rubyref.net/redirect/<CNAME> and the code necessary to achieve this couldn’t be any simpler.
Get Michael Kohl’s stories in your inbox
Join Medium for free to get updates from this writer.
However, in the interest of less typing and faster autocompletes the redirects should be of the form https://<CNAME>.rubyref.net and to achieve that the following Cloudflare page rule is used:
So far so good, there’s however one last problem: Cloudflare does not offer proxying for wildcard CNAMEs in their free tier, so I wrote a little Rake task using the Cloudflare gem to automatically add “dummy” CNAMEs pointing to “rubyref.net” via the Cloudflare API:
With all the CNAMEs defined the page rule now works and the Roda app takes care of the rest 🎉
Contributing
If you want to see new sites added to RubyRef, just open a PR with the extra lines added to redirects.json and I will take care of the rest.






