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
Introducción a Cuba
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Francesco Rodríguez
November 26, 2013
Programming
0
75
Introducción a Cuba
Workshop given in Ruby Fun Day Argentina 2013
Francesco Rodríguez
November 26, 2013
Tweet
Share
More Decks by Francesco Rodríguez
See All by Francesco Rodríguez
A Minimalistic Ruby Stack
frodsan
1
60
Web Development with Cuba - Ruby Fun Day 2014
frodsan
0
130
Web Security 101 - Ruby Fun Day 2014
frodsan
0
110
Introduction to Cuba
frodsan
1
62
Aprende a Programar
frodsan
0
180
Metaprogramming: From Zero to Hero. (URU meetup)
frodsan
1
130
Other Decks in Programming
See All in Programming
Agent Skills Workshop - AIへの頼み方を仕組み化する
gotalab555
13
7.6k
NOT A HOTEL - 建築や人と融合し、自由を創り出すソフトウェア
not_a_hokuts
2
510
Premier Disciplin for Micro Frontends Multi Version/ Framework Scenarios @OOP 2026, Munic
manfredsteyer
PRO
0
200
要求定義・仕様記述・設計・検証の手引き - 理論から学ぶ明確で統一された成果物定義
orgachem
PRO
1
510
RAGでハマりがちな"Excelの罠"を、データの構造化で突破する
harumiweb
8
2.2k
atmaCup #23でAIコーディングを活用した話
ml_bear
4
720
LangChain4jとは一味違うLangChain4j-CDI
kazumura
1
130
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
420
SourceGeneratorのマーカー属性問題について
htkym
0
110
Claude Codeと2つの巻き戻し戦略 / Two Rewind Strategies with Claude Code
fruitriin
0
200
24時間止められないシステムを守る-医療ITにおけるランサムウェア対策の実際
koukimiura
2
180
CSC307 Lecture 12
javiergs
PRO
0
450
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
46
8.1k
Paper Plane
katiecoart
PRO
0
47k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Test your architecture with Archunit
thirion
1
2.2k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
1
140
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Designing for Performance
lara
611
70k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
380
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
So, you think you're a good person
axbom
PRO
2
1.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Transcript
None
Introducción a Cuba
Francesco Rodríguez @frodsan
None
“¿Qué es Cuba?”
github.com/soveran/cuba (‛ƅ㱼ƅ)‛ <200 LOC
Mapper simple ! require 'cuba' ! Cuba.define do on '/'
do res.write 'ᕦ(ò_óˇ)ᕤ' end end ! run Cuba
Mapper simple ! require 'cuba' ! Cuba.define do on '/'
do res.write 'ᕦ(ò_óˇ)ᕤ' end end ! run Cuba
Mapper simple ! require 'cuba' ! Cuba.define do on '/'
do res.write 'ᕦ(ò_óˇ)ᕤ' end end ! run Cuba
Mapper simple ! require 'cuba' ! Cuba.define do on '/'
do res.write 'ᕦ(ò_óˇ)ᕤ' end end ! run Cuba
Mapper simple ! require 'cuba' ! Cuba.define do on '/'
do res.write 'ᕦ(ò_óˇ)ᕤ' end end ! run Cuba
Mapper simple ! $ rackup config.ru … * Listening on
tcp://0.0.0.0:9292 ! $ curl http://localhost:9292/ ᕦ(ò_óˇ)ᕤ
Routing Basics
Matching Rules ! ! Cuba.define do # PATH == /
on '/' do res.write 'Home' end end
Matching Rules ! ! Cuba.define do on true do #
on default do res.write 'Home' end end
Matching Rules ! ! Cuba.define do on true do #
este bloque se ejecuta. res.write 'Home' end ! on false do # este bloque no se ejecuta. res.write 'Never do this at home' end end
Matching Rules ! ! Cuba.define do on true do #
este bloque se ejecuta. res.write 'Home' end ! on true do # este bloque no se ejecuta. res.write 'Never do this at home' end end
Matching Rules ! ! Cuba.define do on false do #
este bloque no se ejecuta. res.write 'Meh' end ! on true, false do # este bloque tampoco se ejecuta. res.write 'Meh' end ! on true do # este bloque se ejecuta. res.write 'Finalmente' end end
Dynamic Segments ! ! Cuba.define do ! on favorites/:name do
|name| res.write name end ! end
Parameters ! ! Cuba.define do ! on 'login', param(‘user’), param(‘pass')
do |user, pass| ! User.authenticate(user, pass) ! end ! end
HTTP Verbs Constraints ! ! Cuba.define do on get do
end ! on post do end ! on put do end ! on delete do end end
Composition ! ! Cuba.define do on '/gems' do on get,
root do end ! on new' do end ! on 'status/:status' do |status| end end end
Composition ! ! class Gems < Cuba define do on
get, root do end ! on 'new' do end ! on 'status/:status' do |status| end end end
Composition ! ! Cuba.define do on '/gems' do run Gems
end end
Cuba Recipes github.com/frodsan/cuba-recipes
Cuba Example github.com/frodsan/cuba-example
Ejemplos
ready4rails4.net github.com/rubyperu/ready4rails 413 additions and 1,459 deletions.
redis.io github.com/antirez/redis-io
Punchgirls’ Job Board github.com/punchgirls/job_board
Recursos
Comunidad #cuba.rb en IRC
Links frodsan.com/recursos-cuba
Gracias! CubaConfAr <3
Gracias! RubyConfAr <3