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
Francesco Rodríguez
November 26, 2013
Programming
0
72
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
55
Web Development with Cuba - Ruby Fun Day 2014
frodsan
0
110
Web Security 101 - Ruby Fun Day 2014
frodsan
0
110
Introduction to Cuba
frodsan
1
54
Aprende a Programar
frodsan
0
170
Metaprogramming: From Zero to Hero. (URU meetup)
frodsan
1
120
Other Decks in Programming
See All in Programming
インターフェース設計のコツとツボ
togishima
2
490
ソフトウェア品質特性、意識してますか?AIの真の力を引き出す活用事例 / ai-and-software-quality
minodriven
19
6.7k
SpringBootにおけるオブザーバビリティのなにか
irof
1
890
TypeScript だけを書いて Tauri でデスクトップアプリを作ろう / Tauri with only TypeScript
tris5572
2
540
型付け力を強化するための Hoogle のすゝめ / Boosting Your Type Mastery with Hoogle
guvalif
1
240
Babylon.js 8.0のアプデ情報を 軽率にキャッチアップ / catch-up-babylonjs-8
drumath2237
0
110
AI Coding Agent Enablement in TypeScript
yukukotani
17
7.2k
コードに語らせよう――自己ドキュメント化が内包する楽しさについて / Let the Code Speak
nrslib
5
1.1k
TypeScriptのmoduleオプションを改めて整理する
bicstone
4
430
ts-morph実践:型を利用するcodemodのテクニック
ypresto
1
540
Parallel::Pipesの紹介
skaji
2
870
Javaに鉄道指向プログラミング (Railway Oriented Pro gramming) のエッセンスを取り入れる/Bringing the Essence of Railway-Oriented Programming to Java
cocet33000
1
190
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
269
20k
Build The Right Thing And Hit Your Dates
maggiecrowley
35
2.7k
Facilitating Awesome Meetings
lara
54
6.4k
How to Think Like a Performance Engineer
csswizardry
23
1.6k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2.1k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.8k
Making Projects Easy
brettharned
116
6.2k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
The Straight Up "How To Draw Better" Workshop
denniskardys
233
140k
How GitHub (no longer) Works
holman
314
140k
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