James Wilding | Ruby on Rails Developer

  • My Projects
  • Hire Me
  • Archive
  • RSS

Hyper: A Framework For Ruby Websites

Hyper

I could have called this gem Yawf: Yet Another Website Framework. Do we really need one? I think we — or at least I — do, so I built it.

Hyper is a micro-framework that supports small, static HTML sites with some Ruby magic thrown in. Its focus is on building and launching a site fast: there’s zero configuration, no route definitions, and definitely no databases.

Why Build Hyper?

I could have used Sinatra or Rails for my personal projects, but I wanted something lighter. I wanted a framework that could take me from a standing start to a functioning website without any configuration (I’m impatient: even Sinatra’s get '/url' route definitions felt like they were holding me back).

Most importantly, I wanted the experience that comes from building something for myself.

Quick Start

$ gem install hyper
$ hyper new cool_site
$ cd cool_site
$ bundle install
$ bundle exec rackup

Your new site is now live at http://0.0.0.0:9292/.

Magic

I want Hyper to hit the sweet spot between plain HTML (no Ruby) and dynamic frameworks like Rails. Routes are automatic:

/        # maps to templates/views/index.html.erb
/about   # maps to templates/views/about.html.erb
/contact # maps to templates/views/contact.html.erb

Because Hyper does this automagically, I can just drop my content into the correct file and move on. Every URL is handled in this way, and there are no exceptions: this behaviour covers 99% of my needs, and if I want something more dynamic I can use a different framework.

Helpers

Because this is a Ruby framework, you get a helper module: 

# in lib/helper.rb
module Hyper::Helper
  def say_hello
    "Hello world"
  end
end

# in templates/views/hello.html.erb
<p><%= say_hello -%></p>

And because it makes sense to split HTML into layout and views, Hyper does just that: shared HTML lives in templates/layout.html.erb, and page-specific content lives in templates/views.

Fast Deployment With Heroku

Right now, Ruby developers have an amazing hosting service in Heroku: prices start at free and the platform supports any web app that’s based on Rack. Can you guess what Hyper is based on?

$ cd cool_website
$ heroku create
$ git push heroku master
-----> Heroku receiving push
-----> Rack app detected

Boom: your website is now on the web.

Share And Enjoy

Hyper is available on Github and via Rubygems: right now it’s is working great for me; I hope it works for you too.

Photo by phunk on Flickr

  • 10 months ago
  • Permalink
  • Share
    Tweet
← Previous • Next →

About

Avatar I'm a startup consultant and software developer based in southern England. Hire me for Ruby on Rails or iOS development work and advice on building a smart business.

  • RSS
  • Random
  • Archive
  • Mobile

Copyright James Wilding. Systems Intelligence Ltd. Registered in England number 07843037. Registered office 29 Silver Street, Colerne, Chippenham, SN14 8DY. Effector Theme by Carlo Franco.

Powered by Tumblr