• Maveric

Maveric is a MVC overlay for Rack.

The dominant idea behind Maveric is as little magic as possible, being as flexible as possible.

The use of a Maveric is simple.

class MyApp < Maveric

def get
  render {'<p>Hello World!</p>'}
end

end

env # => ‘/’ MyApp.call(env) # => 200

env # => ‘/index’ MyApp.call(env) # => 200

By default the method used to generate a response is the lower case form of the http method. GET requests call #get, POST requests call #post, and so on. A 404 is returned if a the appropriate method is not defined.

– Actions

To override this you may redefine #action= as needed.

class MyApp < Maveric

def action= method
  if method == :get and @request.path_info == '/'
    @action = :index
  else
    super
  end
end
def index
  render {'<p>Hello World!</p>'}
end

end

– The Render Method

Provides a simple way to format data.

class MyApp < Maveric

module Views
  def html data
    '<p>'+data.to_s+'</p>'
  end
end
def get
  render :html { 'Hello World!' }
end

end