There are more smart people building software now than there have been at any point in the past, which means that it's more important than ever to stay on top of new developments, libraries, frameworks, and everything else. To really take advantage of this wealth of innovation, however, you've got to look beyond your normal community -- what's going on in Python? And how can we use that to make our Ruby lives easier? In this session, we'll explore that question. We'll look at actual examples of code and concepts borrowed and reimplemented to form a better idea of when it's appropriate and when it'll fall flat.
29. Sinatra
require 'rubygems'
require 'sinatra'
get '/' do
erb :homepage
end
get '/names/:name' do
"Hello, #{params[:name]}"
end
post '/login' do
# data is in request.body
# validate login
end
https://github.com/bmizerany/sinatra
30. Express.js
var express = require('express');
var app = express.createServer();
app.configure(function(){
app.use(express.bodyParser());
});
app.get('/', function(request, response) {
response.render('homepage.ejs');
});
app.get('/names/:name', function(request, response) {
response.send('Hello, ' + request.param('name'));
});
app.post('/login', function(request, response) {
// data is in request.body
// validate login
});
https://github.com/visionmedia/express
31. Ratpack
get("/") {
render "homepage.html"
}
get("/names/:name") {
"Hello, ${urlparams.name}"
}
post("/login") {
// data is in params.field
// validate login
}
https://github.com/bleedingwolf/Ratpack
32. Slim
<?php
require 'Slim/Slim.php';
Slim::init();
Slim::get('/', function () {
Slim::render('homepage.php');
});
Slim::get('/names/:name', function ($name) {
echo "Hello, $name";
});
Slim::post('/login', function () {
# data is in Slim::request()->post('field')
# validate login
});
Slim::run();
?>
https://github.com/codeguy/Slim
33. Nancy
public class Sample : NancyModule
{
public Module()
{
Get["/"] = params => {
return View.Spark("homepage.spark", params);
};
Get["/names/{name}"] = params => {
return string.Concat("Hello, ", params.name);
};
Post["/login"] = params => {
/// data is in params.field
/// validate login
};
}
}
https://github.com/thecodejunkie/Nancy
34. Sammy.js
(function($) {
var app = $.sammy('#main', function() {
this.get('#/', function() {
this.partial('files/homepage.html');
});
this.post('#/login', function() {
// data is in params.field
// validate login
});
});
$(function() { app.run('#/'); });
})(jQuery);
https://github.com/quirkey/sammy