An open API service indexing awesome lists of open source software.

https://github.com/zh/yarf

Yet Another Rack Framework
https://github.com/zh/yarf

Last synced: about 1 year ago
JSON representation

Yet Another Rack Framework

Awesome Lists containing this project

README

          

# YARF - Yet Another Ruby(Rack) Framework

A minimalist (and relatively useless) Ruby web applications framework.

## Features

* Small (< 100 LOC) and fast
* Powered by [Rack](https://github.com/chneukirchen/rack)
* Templates via [Tilt](https://github.com/rtomayko/tilt)
* Routing via [HTTP-Router](https://github.com/joshbuddy/http_router)
* Routes with parameters - '/show/:id'
* Redirects with status - 301 or 302
* Global and per action layouts
* Partial views
* Nesting routes - with '/admin' do ... end
* Static assets - via *Rack::Static*
* Authentication *via Warden* (see the example application)
* Lots of tests included - using *rspec* and *rack-test*

## Pre-requirements

* rack
* erubis
* tilt
* http_router

## Usage

Install pre-requirements:

gem install bundler --pre # (if not installed)
bundle install

Example application in *myapp.rb*:

require 'yarf'
class MyApp < Yarf
static "/static", Yarf.root("public")
layout :bootstrap
get "/" do
render :index
end
get "/intro" do
redirect_to "/readme"
end
get "/readme" do
render :readme, :engine => :md
end
with "/admin" do
get "/dashboard" do
render :admin, :layout => :admin
end
end
end

Rackup script *config.ru*:

require 'myapp'
run HttpRouter.new {
add('/static').static(Yarf.root("public"))
add('/*').to {|env| MyApp.new.call(env) }
}

Use the Rackup script to launch the application:

thin start -R config.ru -p 8080

or

ruby myapp.rb -p 8080

## YARF in the wild

* [YARF development](https://github.com/zh/yarf)
* [YARF site](http://yarf.herokuapp.com/) itself
* [Travis CI building results](http://travis-ci.org/#!/zh/yarf)

## TODO

* support for helpers
* embedded templates - erb '<%= ... %>'
* more tests