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
1
60
Introduction to Cuba
Introduction to Cuba "The Ruby Microframework"
Francesco Rodríguez
September 04, 2014
Tweet
Share
More Decks by Francesco Rodríguez
See All by Francesco Rodríguez
A Minimalistic Ruby Stack
frodsan
1
59
Web Development with Cuba - Ruby Fun Day 2014
frodsan
0
120
Web Security 101 - Ruby Fun Day 2014
frodsan
0
110
Aprende a Programar
frodsan
0
170
Metaprogramming: From Zero to Hero. (URU meetup)
frodsan
1
130
Introducción a Cuba
frodsan
0
73
Other Decks in Programming
See All in Programming
Spinner 軸ズレ現象を調べたらレンダリング深淵に飲まれた #レバテックMeetup
bengo4com
1
210
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
0
180
LLM Çağında Backend Olmak: 10 Milyon Prompt'u Milisaniyede Sorgulamak
selcukusta
0
140
Giselleで作るAI QAアシスタント 〜 Pull Requestレビューに継続的QAを
codenote
0
330
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
340
C-Shared Buildで突破するAI Agent バックテストの壁
po3rin
0
430
Canon EOS R50 V と R5 Mark II 購入でみえてきた最近のデジイチ VR180 事情、そして VR180 静止画に活路を見出すまで
karad
0
140
実は歴史的なアップデートだと思う AWS Interconnect - multicloud
maroon1st
0
300
Findy AI+の開発、運用におけるMCP活用事例
starfish719
0
2k
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
150
例外処理とどう使い分ける?Result型を使ったエラー設計 #burikaigi
kajitack
12
2.8k
ゲームの物理 剛体編
fadis
0
390
Featured
See All Featured
Information Architects: The Missing Link in Design Systems
soysaucechin
0
730
Darren the Foodie - Storyboard
khoart
PRO
0
2.1k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.2k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
1
340
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.3k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
180
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
27
WENDY [Excerpt]
tessaabrams
9
35k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
6.8k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
100
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
0
220
So, you think you're a good person
axbom
PRO
0
1.9k
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