Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Introduction to Cuba
Search
Francesco Rodríguez
September 04, 2014
Programming
82
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Introduction to Cuba
Introduction to Cuba "The Ruby Microframework"
Francesco Rodríguez
September 04, 2014
More Decks by Francesco Rodríguez
See All by Francesco Rodríguez
A Minimalistic Ruby Stack
frodsan
1
77
Web Development with Cuba - Ruby Fun Day 2014
frodsan
0
150
Web Security 101 - Ruby Fun Day 2014
frodsan
0
130
Aprende a Programar
frodsan
0
190
Metaprogramming: From Zero to Hero. (URU meetup)
frodsan
1
150
Introducción a Cuba
frodsan
0
85
Other Decks in Programming
See All in Programming
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
180
Performance Optimization With LLMs
xleitix
0
210
オーケストレーション記述言語 Katari
yukikurage
0
200
GraphQL の onError と Nullability のこれから
quramy
0
180
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
840
3回つくってわかった、 定期実行ジョブ基盤の本質情報
takai
4
3.2k
続・コーディングルールの鮮度を保ちたい / keep-fresh-go-internal-conventions-again
handlename
0
130
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.8k
graphql-ruby を Spinel で速くしようとした話
mtsmfm
0
120
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
240
AmebaブログはKMPから卒業します
kmars0605
0
240
조합이폭발하는디자인시스템이걸눈으로도테스트하라고요
giljongyu
0
590
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
420
The untapped power of vector embeddings
frankvandijk
2
2k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
1.4k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
460
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
880
Statistics for Hackers
jakevdp
799
230k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
20k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Transcript
None
Francesco
[email protected]
Cuba (‛ƅ㱼ƅ)‛ Ruby microframework for web development.
ʕ•ᴥ•ʔ ! • Small. • Focused. • Simple. • Stable.
• Rack. • Fast.
require "cuba"! ! Cuba.define do! on "home" do! res.write("Hello Cuba")!
end! end
Rules
Cuba.define do! on "home" do # PATH == "/home"! !
res.write("Hello Cuba")! end! end
Cuba.define do! on "home" do # PATH == "/home"! !
res.write("Hello Cuba")! end! ! on "about" do # PATH == "/about"! ! res.write("About us”)! end! end
Captures
Cuba.define do! on "hello/:name" do |name|! ! res.write("Hello #{ name
}")! end! end! ! # /hello/frodsan => Hello frodsan
Matchers
Cuba.define do! on /hello\/(^[a-zA-Z]+$)/ do |name|! ! res.write("Hello #{ name
}")! end! end! ! # /hello/frodsan => Hello frodsan! # /hello/123 =>
Cuba.define do! on :name do |name|! ! res.write("Hello #{ name
}")! end! end! ! # /frodsan => Hello frodsan! # /123 => Hello 123
Cuba.define do! # Any expression that! # evaluates to `true`.!
on (*) do! ! res.write("Hello Cuba")! end! end
Cuba.define do! # Any expression that! # evaluates to `true`.!
on true do! ! res.write("Hello Cuba")! end! end
Cuba.define do! on false do! ! res.write("⊙﹏⊙")! end! ! on
true do! ! res.write("the winner")! end! end
Cuba.define do! on authenticated? do! # . . .! end!
! on true do! ! res.status = 401! ! res.write("Not authorized")! end! end
Nested Blocks
Cuba.define do! on "posts" do! # /posts/new! on "new" do!
# . . .! end! ! ! ! # /posts/mypost! on :slug do |slug|! ! # . . .! end! end! end
404 (Else)
Cuba.define do! on "posts" do! on "new" do! ! #
. . .! ! # on true do! on default do! res.status = 404! res.write("Not Found")! end! end! end
Helpers
Cuba.define do! on "posts" do! on get do! # METHOD
== GET! end! ! on post do! on param("post") do |post|! end! end! end! end
Composition
class Users < Cuba define do! on "posts" do! on
"new" do! ! # . . .! end! ! on :slug do |slug|! ! # . . .! end! end! end! end
Cuba.define do! on authenticated? do! run(Users)! end! ! on default
do! ! res.status = 401! ! res.write("Not authorized")! end! end
Stack
ʕ•ᴥ•ʔ ! • hache • mote • mote-render • malone
• ohm • ost • rack-protection • requests • scrivener • shield
! on "signup" do! on post, param("user") do |params|! signup
= Signup.new(params)! ! on signup.valid? do! user = User.create(params)! authenticate(user)! ! res.redirect("/dashboard")! end! ! on default do! end! end! end!
! on "posts" do! on post, param("post") do |params|! end!
! on :id do |id|! post = Post[id]! ! on default do! render("post", post: post)! end! end! ! on default do! render("posts")! end! end!
theguidetocuba.io A Getting Started guide (WIP)
github.com/punchgirls/job_board/ An Open Source application.
cuba.is Cuba’s website.
thx <3