eddanger (owner)

Revisions

gist: 66203 Download_button fork
public
Description:
Rackup file to load either merb or sinatra (run "rackup config.ru")
Public Clone URL: git://gist.github.com/66203.git
Embed All Files: show embed
config.ru #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'rubygems'
require 'sinatraapp'
 
require 'merb-core'
 
Merb::Config.setup(:merb_root => File.expand_path(File.dirname('merbapp')),
                   :environment => ENV['RACK_ENV'])
Merb.environment = Merb::Config[:environment]
Merb.root = Merb::Config[:merb_root]
#Merb::BootLoader.run
 
builder = Rack::Builder.new do
  use Rack::CommonLogger
 
  map '/sinatra' do
    run Sinatra::Application
  end
 
  map '/merb' do
    run Merb::Rack::Application.new
  end
 
  map '/' do
    menu = '<a href="/merb">Merb</a> | <a href="/sinatra">Sinatra</a>'
    run Proc.new {|env| [200, {"Content-Type" => "text/html"}, menu + "<hr>" + env.inspect] }
  end
end
 
Rack::Handler::Mongrel.run builder, :Port => 4242
 
 
merbapp.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# run very flat apps with merb -I <app file>.
 
# Uncomment for DataMapper ORM
# use_orm :datamapper
 
# Uncomment for ActiveRecord ORM
# use_orm :activerecord
 
# Uncomment for Sequel ORM
# use_orm :sequel
 
 
#
# ==== Pick what you test with
#
 
# This defines which test framework the generators will use.
# RSpec is turned on by default.
#
# To use Test::Unit, you need to install the merb_test_unit gem.
# To use RSpec, you don't have to install any additional gems, since
# merb-core provides support for RSpec.
#
# use_test :test_unit
use_test :rspec
 
#
# ==== Choose which template engine to use by default
#
 
# Merb can generate views for different template engines, choose your favourite as the default.
 
use_template_engine :erb
# use_template_engine :haml
 
Merb::Config.use { |c|
  c[:framework] = { :public => [Merb.root / "public", nil] }
  c[:session_store] = 'none'
  c[:exception_details] = true
c[:log_level] = :debug # or error, warn, info or fatal
  c[:log_stream] = STDOUT
  # or use file for loggine:
  # c[:log_file] = Merb.root / "log" / "merb.log"
 
c[:reload_classes] = true
c[:reload_templates] = true
}
 
 
 
Merb::Router.prepare do
  match('/').to(:controller => 'merbapp', :action =>'index')
end
 
class Merbapp < Merb::Controller
  def index
    "Hi, I am 'very flat' Merb application. I have everything in one single file and well suited for dynamic stub pages."
  end
end
sinatraapp.rb #
1
2
3
4
5
6
require "rubygems"
require "sinatra"
 
get "/?" do
  "Hello Sinatra"
end