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
Francesco Rodríguez
September 04, 2014
Programming
74
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
71
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
tsc.rip を支える技術 / Kyoto.なんか #8
susisu
0
3.9k
TSX の <Hoge<Fuga>> という構文に驚いた話 / tsx-type-argument-syntax
kanaru0928
0
240
T3DD26: From RAGs to Riches
martinhelmich
0
120
Detecting Compromised CI with eBPF and Cilium Tetragon
lizrice
0
270
FastAPI の並行処理モデルを完全に理解する
hoto17296
9
3.2k
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
560
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
400
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
460
Hello, Hiroshima Geospatial Data! — Exploring DoboX with Python
ra0kley
0
120
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
2
400
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
250
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
5
1.8k
Featured
See All Featured
How to build a perfect <img>
jonoalderson
1
5.9k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
300
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.2k
Site-Speed That Sticks
csswizardry
13
1.5k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
710
Paper Plane
katiecoart
PRO
2
53k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
180
How STYLIGHT went responsive
nonsquared
100
6.2k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
290
A Modern Web Designer's Workflow
chriscoyier
698
190k
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