This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
module Fabulous | |
def name | |
"Fabulous" | |
end | |
end | |
class Migzy | |
def name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merb::Controller.class_eval do | |
session_store = Merb::Config[:session_store].to_s | |
if ["", "false", "none"].include?(session_store) | |
Merb.logger.warn "Not Using Sessions" | |
elsif reg = Merb.registered_session_types[session_store] | |
Merb::BootLoader::MixinSessionContainer.check_for_secret_key if session_store == "cookie" | |
Merb::BootLoader::MixinSessionContainer.check_for_session_id_key | |
require reg[:file] | |
include ::Merb::SessionMixin | |
Merb.logger.warn reg[:description] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from django.conf import settings | |
from django.utils.cache import patch_vary_headers | |
from django.utils.http import cookie_date | |
class SessionMiddleware(object): | |
def process_request(self, request): | |
engine = __import__(settings.SESSION_ENGINE, {}, {}, ['']) | |
session_key = request.COOKIES.get(settings.SESSION_COOKIE_NAME, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# ==== Merb variables | |
# | |
set :merb_adapter, "thin" | |
set :merb_environment, ENV["MERB_ENV"] || "production" | |
set :merb_port, 5000 | |
set :merb_servers, 1 | |
after "deploy:finalize_update", "symlink:database_yml" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it "should match a nested resources show action" do | |
@blue = Blue.new | |
@controller.url(:monkey_blue, @blue).should == "/monkeys/45/blues/13" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set up the default framework | |
# | |
# ==== Returns | |
# nil | |
# | |
#--- | |
# @public | |
def default_framework | |
%w[view model helper controller mailer part].each do |component| | |
Merb.push_path(component.to_sym, Merb.root_path("app/#{component}s")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def inherited(klass) | |
_abstract_subclasses << klass.to_s | |
helper_module_name = klass.to_s =~ /^(#|Merb::)/ ? "#{klass}Helper" : "Merb::#{klass}Helper" | |
Object.make_module helper_module_name | |
klass.class_eval <<-HERE | |
include Object.full_const_get("#{helper_module_name}") rescue nil | |
HERE | |
super | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "digest/sha1" | |
# use PathPrefix Middleware if :path_prefix is set in Merb::Config | |
if prefix = ::Merb::Config[:path_prefix] | |
use Merb::Rack::PathPrefix, prefix | |
end | |
# comment this out if you are running merb behind a load balancer | |
# that serves static files | |
use Merb::Rack::Static, Merb.dir_for(:public) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :symlink do | |
desc "symlinks database.yml" | |
task :database_yml, :roles => :app do | |
run "ln -s #{latest_release}/config/database.server.yml #{latest_release}/config/database.yml" | |
end | |
desc "Symlink uploads directory" | |
task :uploads do | |
run "ln -nfs #{deploy_to}/#{shared_dir}/public/uploads #{release_path}/public/uploads" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Merb.disable(:json) | |
# Run after application classes are loaded and templates are inlined. | |
Merb::BootLoader.after_app_loads do | |
class ActiveRecord::Base | |
def to_json(state, depth) | |
super() | |
end | |
end | |
end |