Indy.rb November 2012 Intro (using termnote)
---
type: chapter
title: Indy.rb November 2012
subtitle: Microframework Hack Night
---
type: text
title: Sponsored by...
content: |
Thanks iGoDigital!
# Switched from old 'list' type
---
type: text
title: iGoDigital Jobs
content: |
- Senior Ruby Developer
- Senior System Administrator
- Interaction Developer
- Ruby Backend Developer
- Web Application Developer
---
type: text
title: Introductions
content: |
Who are you? What do you do? What brings you here tonight?
---
type: chapter
title: "Tonight's Agenda"
---
type: chapter
title: "What Are We Building?"
subtitle: Reddit Clones!
# Switched from old 'list' type
---
type: text
title: Features
content: |
- "A user can post an article"
- "A user can up- or down- vote an article"
- "A user can comment on an article"
# Switched from old 'list' type
---
type: text
title: The (micro) Frameworks
content: |
- Camping
- Cramp
- Cuba
- Espresso
- Grape
- Nancy
- Ramaze
- Raptor
---
type: chapter
title: Camping
subtitle: "A little white blood cell in the vein of Rails"
---
type: code
title: Camping
language: ruby
source: |
Camping.goes :Blog
module Blog::Models
class Post < Base; end
end
module Blog::Controllers
class Index
def get
@posts = Post.all
render :index
end
end
end
module Blog::Views
def index
@posts.each do |post|
h1 post.title
div.content! { post.body }
end
end
end
---
type: chapter
title: Cramp
subtitle: "Fully asynchronous real-time web application framework"
---
type: code
title: Cramp
language: ruby
source: |
require "rubygems"
require 'cramp'
class HomeAction < Cramp::Action
def start
render "Hello World"
finish
end
end
run HomeAction
---
type: chapter
title: Cuba
subtitle: "Rum-based microframework for web development"
---
type: code
title: Cuba
language: ruby
source: |
require "cuba"
require "rack/protection"
require "securerandom"
Cuba.use Rack::Session::Cookie, :secret => SecureRandom.hex(64)
Cuba.use Rack::Protection
Cuba.define do
on get do
on "hello" do
res.write "Hello world!"
end
on root do
res.redirect "/hello"
end
end
end
---
type: chapter
title: Espresso
subtitle: "Scalable Web Framework aimed at Speed and Simplicity"
---
type: code
title: Espresso
language: ruby
source: |
require 'e'
class App < E
map '/'
def index
# ...
end
end
App.run
---
type: chapter
title: Grape
subtitle: "An opinionated micro-framework for creating REST-like APIs in Ruby"
---
type: code
title: Grape
language: ruby
source: |
class Twitter::API < Grape::API
version 'v1', :using => :header, :vendor => 'twitter'
format :json
resource :statuses do
desc "Returns a public timeline."
get :public_timeline do
Tweet.limit(20)
end
desc "Creates a tweet."
params do
requires :status, :type => String, :desc => "Your status."
end
post :update do
Tweet.create(
:user => current_user,
:text => params[:status]
)
end
end
end
---
type: chapter
title: Nancy
subtitle: "Sinatra's little daughter"
---
type: code
title: Nancy
language: ruby
source: |
require "nancy"
class Hello < Nancy::Base
use Rack::Session::Cookie # for sessions
include Nancy::Render # for templates
get "/" do
"Hello World"
end
get "/hello" do
redirect "/"
end
get "/hello/:name" do
"Hello #{params['name']}"
end
end
---
type: chapter
title: Ramaze
subtitle: "Simple, light and modular open-source web application framework written in Ruby"
---
type: code
title: Ramaze
language: ruby
source: |
require 'ramaze'
class MyController < Ramaze::Controller
map '/'
def index
return "Hello, Ramaze!"
end
end
Ramaze.start
---
type: chapter
title: Raptor
subtitle: "An experimental web framework."
---
type: code
title: Raptor
language: ruby
source: |
module MyApp
App = Raptor::App.new(self) do
path "article" do
show
index
update :if => :admin, :redirect => :index
end
end
module Records
class Article < YourFavoriteORM::Record
# Do as you please
end
end
# ...
---
type: code
title: Raptor
language: ruby
source: |
# ...
module Constraints
class Admin
def match?(params)
Records::User.find_by_id(params[:user_id]).admin?
end
end
end
module Presenters
class Article
def initialize(subject); @subject = subject; end
def slug; @subject.title.to_slug; end
end
end
end