Skip to content

Instantly share code, notes, and snippets.

Questions

1) What inspired you to create your own Ruby framework?

As much as I like Sinatra, there were some limitations I found frustrating and unnecessary when using it in the real-world. These were mainly issues of code management and scalability. You either had to put all your routes for your entire application in a single "controller", in which they shared helpers, filters, configuration, and so on, or otherwise try and break your application out into multiple mini Sinatra applications, and mount them under different mappings using Rack. Neither solution was elegant. I thought Padrino might address a few of those issues, but found it equally if not more frustrating.

Given that I had a pretty good idea of what I wanted and because it was simple enough (maybe not in hindsight), I decided to roll my own, knowing that I'd not only be scratching my itch, but the itches of many other developers who inadvertantly run into issues of practicaility when using Sinatra.

2) How did you come up with the n

class ApiV1 < Scorched::Controller
RedisDB = 15
def redis
@redis ||= Redis.new(RedisDB)
end
end
class Base < Scorched::Controller
include Scorched::Options('settings')
end
Class Test < Base
settings[:some_settings] = 'hello'
end
require 'scorched'
class Base < Scorched::Controller
middleware << proc do
use Rack::Session::Cookie, secret: 'mysecretcookie'
end
end
class Sub < Base
get '/hello' do
@Wardrop
Wardrop / gist:604f5ec38315e510ecff
Last active August 29, 2015 14:13
Transform value while preserving key example
require 'parslet'
class ExampleParser < Parslet::Parser
root(:root)
rule(:root) { width >> str("x") >> height }
rule(:width) { match["0-9"].repeat(1).as(:width) }
rule(:height) { match["0-9"].repeat(1).as(:height) }
end
class ExampleTransform < Parslet::Transform
require 'rubygems'
require 'sinatra'
require 'sinatra/reloader'
before do
headers "Content-Type" => "application/octet-stream"
end
get "/" do
"Hello World!"
# Please ignore this Gist and check out this instead: https://gist.github.com/913370
def precompiled_preamble(locals)
locals.map { |k,v| "#{k} = #{v}" }.join("\n")
end
def precompiled_preamble(locals)
locals.map { |k,v| "#{k} = locals[#{k.inspect}]"}.join("\n")
end
final_width = 400
final_height = 400
for (var i = 0; i < app.documents.length; i++) {
crop_width_by = 0
crop_height_by = 0
doc = app.documents[i]
app.activeDocument = doc
landscape = (doc.height < doc.width)
if (landscape == true) {
@Wardrop
Wardrop / reservation.rb
Created February 11, 2012 06:20
Snippet of controller file
module Tombstone
App.controller :reservation do
get :new do
@root_places = Place.with_child_count.filter(:parent_id => nil).order(:name).naked.all
render 'reservation/new'
end
end
end