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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Francesco Rodríguez
September 04, 2014
Programming
72
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
68
Web Development with Cuba - Ruby Fun Day 2014
frodsan
0
140
Web Security 101 - Ruby Fun Day 2014
frodsan
0
120
Aprende a Programar
frodsan
0
190
Metaprogramming: From Zero to Hero. (URU meetup)
frodsan
1
140
Introducción a Cuba
frodsan
0
82
Other Decks in Programming
See All in Programming
1B+ /day規模のログを管理する技術
broadleaf
0
130
エージェンティックRAGにAWSで入門しよう!
har1101
9
1.9k
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
3
840
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
460
SREの積み重ねがAI駆動開発のガードレールになった ― 7つの実践/SRE Guardrails The 7
tomoyakitaura
7
3.5k
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
190
PHPだって関数型したい 〜できること、できないこと〜 / fp-in-php
jsoizo
0
170
関数型プログラミングのメリットって何だろう?
wanko_it
0
150
Hatena Engineer Seminar #37「言語モデルの活用に関する研究」
slashnephy
0
500
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
220
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
7
1.8k
20260623_Loop Engineeringで自分の分身の問い合わせBotを作る
ryugen04
0
190
Featured
See All Featured
Building an army of robots
kneath
306
46k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
190
4 Signs Your Business is Dying
shpigford
187
22k
Balancing Empowerment & Direction
lara
6
1.2k
Automating Front-end Workflow
addyosmani
1370
210k
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
0
440
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Thoughts on Productivity
jonyablonski
76
5.2k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
390
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
390
Information Architects: The Missing Link in Design Systems
soysaucechin
0
1k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
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