View gist:604f5ec38315e510ecff
1 2 3 4 5 6 7 8 9 10
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
View example.ru
1 2 3 4 5 6 7 8 9 10
require 'scorched'
 
class Base < Scorched::Controller
middleware << proc do
use Rack::Session::Cookie, secret: 'mysecretcookie'
end
end
 
class Sub < Base
get '/hello' do
View gist:9357758
1 2 3 4 5 6 7
class ApiV1 < Scorched::Controller
RedisDB = 15
def redis
@redis ||= Redis.new(RedisDB)
end
end
View settings.rb
1 2 3 4 5 6 7
class Base < Scorched::Controller
include Scorched::Options('settings')
end
 
Class Test < Base
settings[:some_settings] = 'hello'
end
View Darren_Jones_Response.md

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

View centralised.ru
1 2 3 4 5 6 7 8 9 10
require 'scorched'
 
class Base < Scorched::Controller
class << self
def inherited(klass)
klass.route('/*?') do
action = request.breadcrumb[-2].mapping[:conditions][:action]
if action && respond_to?(action)
send(action)
else
View app.js
1 2 3 4 5 6 7 8 9 10
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.create('Ext.data.Store', {
storeId: 'petTypes',
fields: ['name', 'value'],
proxy: {
type: 'rest',
url: '/people/pet_types',
reader: {
View gist:4976817
1 2 3 4 5 6 7 8 9 10
# Doesn't work; needs reference to outer class object.
class SomeClass
class << self
extend Delegate
def hash
@hash ||= {}
end
delegate hash, :[]=, :has_key?, :each
View format_byte_size.rb
1 2 3 4 5 6 7 8 9 10
# Formats the given byte value into a human readable form.
#
# Accepts four optional arguments that control the output format:
# as_bits: If true, converts the given byte value to bits and adjusts the suffix accordingly. Defaults to false.
# binary: If true, calculates order of magnitude as base 2 (binary) instead of base 10 (decimal). Defaults to true.
# full_suffix: If true, uses full suffix names such as "Megabyte", otherwise uses abbreviations like "MB" or "Mib". Defaults to false.
# precision: The number of decimal points to include in the output. Trailing zero's are removed. Defaults to 2.
 
def format_bytes(bytes, as_bits: false, binary: true, full_suffix: false, precision: 2)
suffixes = ['', 'Kilo', 'Mega', 'Giga', 'Tera', 'Peta', 'Exa', 'Zetta', 'Yotta']
Something went wrong with that request. Please try again.