A proof of concept of having Sinatra like routes inside your controllers.
Since the router is gone, feel free to remove config/routes.rb.
Then add the file below to lib/action_controller/inline_routes.rb
inside your app.
| #!/bin/bash | |
| set -exo pipefail | |
| BUILD_ENV=$1 | |
| if [ `uname` == 'Darwin' ]; then | |
| OSX=1 | |
| JSCOMPRESSOR="yuicompressor --type js" | |
| else | |
| OSX= |
| require 'rubygems' | |
| require 'benchmark/ips' | |
| class ExampleClass | |
| def foo; 42; end | |
| end | |
| module ExampleMixin | |
| def foo; 43; end | |
| end |
| class Object { | |
| def while: condition do: body else: alternative { | |
| if: (condition call) then: { | |
| body call | |
| while: condition do: body | |
| } else: alternative | |
| } | |
| } | |
| # usage: |
Given: this rspec file is in PROJECT_ROOT/spec
describe 'codebase' do
let(:lines_with_more_than_80_characters) do
Dir.glob( File.expand_path('../../lib/**/*.rb', __FILE__ ) ).map do |path|
File.open( path ) do |file|
idx = 0
file.lines.map do |line|
idx += 1| require "minitest/autorun" | |
| class ZOMGIO < Struct.new(:io) | |
| def puts str = nil | |
| return io.puts str unless str =~ /\[([\/\w.]+):(\d+)\]:\n/ | |
| io.print $` | |
| io.print $& | |
| io.puts "> #{File.readlines($1)[$2.to_i - 1].strip}" | |
| io.puts $' |
| // Generate four random hex digits. | |
| function S4() { | |
| return (((1+Math.random())*0x10000)|0).toString(16).substring(1); | |
| }; | |
| // Generate a pseudo-GUID by concatenating random hexadecimal. | |
| function guid() { | |
| return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4()); | |
| }; |
| # When anything, including nil, is a valid param and you need | |
| # a clear way to know if a param was set or not. | |
| def foo a, b = (b_was_not_passed = true; nil) | |
| result = [a] | |
| result << b unless b_was_not_passed | |
| result | |
| end |
| # When anything, including nil, is a valid param and you need | |
| # a clear way to know if a param was set or not, use `None`. | |
| None = Object.new | |
| def foo(a, b=None) | |
| result = [a] | |
| if b != None | |
| result << b | |
| end |
| ### | |
| Module dependencies | |
| ### | |
| require.paths.unshift "#{__dirname}/lib/support/express-csrf/" | |
| require.paths.unshift "#{__dirname}/lib/support/node_hash/lib/" | |
| express = require 'express' | |
| app = module.exports = express.createServer() | |
| RedisStore = require 'connect-redis' |