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.
This is an example of using RVM's Project .rvmrc file | |
to have it automatically bootstrap your environment, including bundler. | |
This could be further expanded to do anything you require :) | |
The important thing to remember is that the purpose of these files is | |
to allow you to very easily have your 'project context' (aka 'environment') | |
loaded automatically for you when you enter the project in the shell (cd). | |
You can generate the .rvmrc file below by running: |
Warden::Manager.serialize_into_session{|user| user.id } | |
Warden::Manager.serialize_from_session{|id| User.get(id) } | |
Warden::Manager.before_failure do |env,opts| | |
# Sinatra is very sensitive to the request method | |
# since authentication could fail on any type of method, we need | |
# to set it for the failure app so it is routed to the correct block | |
env['REQUEST_METHOD'] = "POST" | |
end | |
/path/to/unicorn/log/unicorn.stderr.log | |
/path/to/production/log/production.log | |
{ | |
daily | |
missingok | |
rotate 180 | |
compress | |
dateext | |
# this is important if using "compress" since we need to call |
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb | |
# and made a lot more robust by me | |
# this implementation uses erb by default. if you want to use any other template mechanism | |
# then replace `erb` on line 13 and line 17 with `haml` or whatever | |
module Sinatra::Partials | |
def partial(template, *args) | |
template_array = template.to_s.split('/') | |
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}" | |
options = args.last.is_a?(Hash) ? args.pop : {} | |
options.merge!(:layout => false) |
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |
source :rubygems | |
# We are not loading Active Record, nor Active Resources etc. | |
# We can do this in any app by simply replacing the rails gem | |
# by the parts we want to use. | |
gem "actionpack", "~> 3.2" | |
gem "railties", "~> 3.2" | |
gem "tzinfo" | |
# Let's use thin |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<title>Jasmine Spec Runner</title> | |
<link rel="shortcut icon" type="image/png" href="spec/jasmine/jasmine_favicon.png"> | |
<link rel="stylesheet" type="text/css" href="spec/jasmine/jasmine.css"> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<script src="spec/jasmine/jasmine.js"></script> | |
<script src="spec/jasmine/jasmine-html.js"></script> |
// installed Clojure packages: | |
// | |
// * BracketHighlighter | |
// * lispindent | |
// * SublimeREPL | |
// * sublime-paredit | |
{ | |
"word_separators": "/\\()\"',;!@$%^&|+=[]{}`~?", | |
"paredit_enabled": true, |