ramaze - the underrated ruby web framework

Download Ramaze - The Underrated Ruby Web Framework

If you can't read please download the document

Upload: luccastera

Post on 16-Apr-2017

4.670 views

Category:

Technology


1 download

TRANSCRIPT

The Underrated Web Framework

Good afternooon everyone. My name is Luc Castera and I'm going to talk to you about Ramaze today.

underrated:Not given enough recognition for its quality

All jokes aside, I really feel like ramaze is underrated, so I hope that you will enjoy the following introduction to Ramaze and I hope that it helps spread the word a bit about this great framework.

That might have sounded pretty negative towards Rails...

I just want to clarify that this is not my intention... as a matter of fact I love Rails more than any other piece of software I've ever used.

I use it everyday and it pays my bills while making coding fun.

I've noticed there is a lot of critics of Rails now in the Ruby world...

But we can't forget that most of us got to learn Ruby thanks to Rails and some of us are making money thanks to Rails...

Motivation

... and that is really my motivation for this talk.

Of course, when I saw a reddit commenter say the same thing, I knew that I was right...

I mean, someone on reddit said I was right, and no one on reddit is ever wrong.

What's your experience with Ramaze?

a) Never heard of it

b) Noob

c) Expert

Getting Started

Simple
Light
Modular

sudo gem install ramaze

http://github.com/manveru/ramaze

Features

M V C

KISS

Light

You can write an application in one file.

Modular

Only one dependency

ORM-agnostic

Templating Engines:

Ezamar

Erubis

Haml

Liquid

Markaby

Maruku

Nagoro

Redcloth

Sass

Tagz

Tenjin

XSLT

Amrita

Builder

Remarkably

Stable

...started more than 2 years ago.

Well Documented

Beautiful Code

BDD

Ruby 1.9

Most bugs fixed in 48 hours.

IRC Population

Basics

Controllers

MainController maps to '/'

BlueController maps to '/blue'

...unless you use map

_ .

Action methods accept arguments via URL

http://localhost:7000/archive?page=2

request[:page] == '2'

Errors redirect to error action

Routing

(String Routers)

Ramaze::Route[ '/foo' ] = '/bar'

# '/foo' => '/bar'

Routing

(Regex Routers)

Ramaze::Route[%r!^/(\d+)\.txt$!] = "/text/%d"

# '/123.txt' => '/text/123'

Routing

Ramaze::Route[ 'name of route' ] = lambda { |path, request|
'/bar' if path == '/foo' and request[:bar] == '1'
}

(Lambda Routers)

# '/foo' => '/foo'
# '/foo?bar=1' => '/bar'

Testing

Views

Ezamar

Erubis

(bundled)

(default)

(my favorite)

(plenty of other choices)

inline

vs.

external

Run return value of action through templating engineSend to browser

START

ExternalTemplateIs there an external template?NO

YES

Instance variables set in the action can be accessed in template

(just like in Rails)

(convention)

/view

(configuration)

view_root 'my_templates'

Layouts

# apply to all actions except index
layout :layout
deny_layout :index

# apply only to index
layout :layout => [ :index ]

Layouts

Ezamar

Very simple reimplementation of the Templating-engine found in Nitro.

==

#{ rubycode } ==

Ezamar::Element

Ezamar::Element

Models

That's up to you
to figure out...

I'm serious.

I'm not gonna cover models because Ramaze really doesn't have anything built-in for models, it's up to you to use your favorite ORM.

ActiveRecord
DataMapper
Sequel
Og
DBI

Ramaze::Store

Simple Wrapper of the YAML::Store

Helpers

Default Helpers

CGI

File

Link

Redirect

Session/Flash

Optional Helpers

Aspect

Auth

Cache

Identity (OpenID)

Pager

Form

Partial

Captcha

etc...

Custom Helpers

Link Helper

R(AdminController, :index)=> /admin/indexRs(:index)=> /admin/indexRs(:/)=> /

A('text')=> textA('foo/bar')=> foo/barA('Home', :href => Rs(:/))=> Home

Aspect Helper

Allows you to wrap different Actions on your Controller with code.

Extras

Deployment

Adapters exist for:

Thin

Mongrel

Evented Mongrel

Webrick

CGI

FCGI

Deployment

thin start --servers 1 --socket /tmp/thin-socket -R start.ru

Two Things

Options::DSL

Pretty neat DSL to store global options

lib/ramaze/option/dsl.rb

Poor Man's Fibers

Implemented by Aman Gupta

http://gist.github.com/4631

lib/ramaze/snippets/fiber.rb

Live Coding

Small Blog Example:http://pastie.org/319647

Where to learn more

http://www.ramaze.net

IRC: #ramaze

http://dambalah.com

github.com/ramaze

http://blog.purepistos.net

RTFC

Thank you.

Questions?

IRC Population

#rails484

#merb219

#ramaze45

#sinatra25