Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Introduction to Cuba
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Francesco Rodríguez
September 04, 2014
Programming
69
1
Share
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
64
Web Development with Cuba - Ruby Fun Day 2014
frodsan
0
130
Web Security 101 - Ruby Fun Day 2014
frodsan
0
110
Aprende a Programar
frodsan
0
180
Metaprogramming: From Zero to Hero. (URU meetup)
frodsan
1
130
Introducción a Cuba
frodsan
0
79
Other Decks in Programming
See All in Programming
10 Tips of AWS ~Gen AI on AWS~
licux
5
540
リセットCSSを1行消したらアクセシビリティが向上した話
pvcresin
4
460
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
240
なぜあなたのコードには「コシ」がないのか?〜AI時代に問う、最後まで美味しい設計と戦略〜 #phpconkagawa / phpconkagawa2026
shogogg
0
130
Spec-Driven Development with AI Agents (Workshop, May 2026)
antonarhipov
2
300
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
290
Claude CodeでETLジョブ実行テストを自動化してみた
yoshikikasama
0
1.1k
Claude Code × Gemini × Ebitengine ゲーム制作素人WebエンジニアがGoでゲームを作った話
webzawa
0
220
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
1
440
第3木曜LT会 #28
tinykitten
PRO
0
120
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
21
10k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
480
Featured
See All Featured
Balancing Empowerment & Direction
lara
6
1.1k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
1.9k
Embracing the Ebb and Flow
colly
88
5k
YesSQL, Process and Tooling at Scale
rocio
174
15k
Into the Great Unknown - MozCon
thekraken
41
2.4k
Typedesign – Prime Four
hannesfritz
42
3k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
The agentic SEO stack - context over prompts
schlessera
0
770
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
110
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.4k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
160
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