<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>LICENSE</filename>
    </added>
    <added>
      <filename>TODO</filename>
    </added>
    <added>
      <filename>lib/merb_core/config.rb</filename>
    </added>
    <added>
      <filename>lib/merb_core/rack.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -63,7 +63,7 @@ spec = Gem::Specification.new do |s|
   s.add_dependency &quot;ruby2ruby&quot;
   s.add_dependency &quot;json_pure&quot;
   s.add_dependency &quot;assistance&quot;
-  
+  s.add_dependency &quot;rspec&quot;  
   # Requirements
   s.requirements &lt;&lt; &quot;install the json gem to get faster json parsing&quot;
   s.required_ruby_version = &quot;&gt;= 1.8.4&quot;</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 #!/usr/bin/env ruby
 require 'rubygems'
 require 'merb'
-Merb::Rack::Adapter.new
+
+Merb.start</diff>
      <filename>bin/merb</filename>
    </modified>
    <modified>
      <diff>@@ -4,27 +4,52 @@
 require 'rubygems'
 require 'set'
 require 'fileutils'
+require &quot;assistance&quot;
 
 $LOAD_PATH.push File.dirname(__FILE__) unless 
   $LOAD_PATH.include?(File.dirname(__FILE__)) || 
   $LOAD_PATH.include?(File.expand_path(File.dirname(__FILE__)))
 
+require 'merb_core/autoload'
+require 'merb_core/core_ext'
 require 'merb_core/gem_ext/erubis'
 require 'merb_core/logger'
 require 'merb_core/version'
-require 'merb_core/core_ext'
 
-gem &quot;assistance&quot;
-require &quot;assistance&quot;
 
 module Merb
   class &lt;&lt; self
     
+    def start(argv=ARGV)
+      Merb::Config.parse_args(argv)
+      BootLoader.run
+      case Merb::Config[:adapter]
+      when nil
+        # Guess.
+        if ENV.include?(&quot;PHP_FCGI_CHILDREN&quot;)
+          adapter = Merb::Rack::FastCGI
+        else
+          begin
+            adapter = Merb::Rack::Mongrel
+          rescue LoadError =&gt; e
+            adapter = Merb::Rack::WEBrick
+          end
+        end
+      when &quot;mongrel&quot;
+        adapter = Merb::Rack::Mongrel
+      when &quot;webrick&quot;
+        adapter = Merb::Rack::WEBrick
+      when &quot;fastcgi&quot;
+        adapter = Merb::Rack::FastCGI
+      else
+        adapter = Merb::Rack.const_get(server.capitalize)
+      end    
+      adapter.start_server(Merb::Config[:host], Merb::Config[:port])
+    end
+    
     attr_accessor :environment, :load_paths
     Merb.load_paths = Hash.new
 		
-		require 'merb_core/autoload'
-		
 		# This is the core mechanism for setting up your application layout
 		# merb-core won't set a default application layout, but merb-more will
 		# use the app/:type layout that is in use in Merb 0.5</diff>
      <filename>lib/merb.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,14 @@
 module Merb
   autoload :AbstractController,   &quot;merb_core/controller/abstract_controller&quot;
   autoload :BootLoader,           &quot;merb_core/boot/bootloader&quot;
+  autoload :Config,               &quot;merb_core/config&quot;
   autoload :Const,                &quot;merb_core/constants&quot;
   autoload :Controller,           &quot;merb_core/controller/merb_controller&quot;
   autoload :ControllerExceptions, &quot;merb_core/controller/exceptions&quot;
   autoload :Dispatcher,           &quot;merb_core/dispatch/dispatcher&quot;
   autoload :ErubisCaptureMixin,   &quot;merb_core/controller/mixins/erubis_capture&quot;
   autoload :Plugins,              &quot;merb_core/plugins&quot;
+  autoload :Rack,                 &quot;merb_core/rack&quot;
   autoload :RenderMixin,          &quot;merb_core/controller/mixins/render&quot;
   autoload :Request,              &quot;merb_core/dispatch/request&quot;
   autoload :Responder,            &quot;merb_core/controller/mixins/responder&quot;</diff>
      <filename>lib/merb_core/autoload.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,5 @@
 module Merb
   
-  def self.start
-    BootLoader.run
-  end
-  
   class BootLoader
     
     cattr_accessor :subclasses
@@ -52,8 +48,8 @@ class Merb::BootLoader::BuildFramework &lt; Merb::BootLoader
     %[view model controller helper mailer part].each do |component|
       Merb.push_path(component.to_sym, Merb.root_path(&quot;app/#{component}s&quot;))
     end
-    Merb.push_path(:app_controller, Merb.root_path(&quot;app/controllers&quot;, &quot;application_controller.rb&quot;))
-    Merb.push_path(:config,         Merb.root_path(&quot;config&quot;, &quot;router.rb&quot;))
+    Merb.push_path(:app_controller, Merb.root_path(&quot;app/controllers/application.rb&quot;))
+    Merb.push_path(:config,         Merb.root_path(&quot;config/router.rb&quot;))
     Merb.push_path(:lib,            Merb.root_path(&quot;lib&quot;))    
   end
 end
@@ -133,7 +129,7 @@ class Merb::BootLoader::Templates &lt; Merb::BootLoader
 end
 
 class Merb::BootLoader::Libraries &lt; Merb::BootLoader
-  @@libraries = {:disable_json_gem =&gt; %[json/ext json/pure]}
+  @@libraries = {:disable_json_gem =&gt; %w[json/ext json/pure]}
 
   # Add other libraries to load in early in the boot process
   # 
@@ -157,6 +153,7 @@ class Merb::BootLoader::Libraries &lt; Merb::BootLoader
   end
   
   def require_first_working(first, *rest)
+    p first, rest
     require first
   rescue LoadError
     raise LoadError if rest.empty?</diff>
      <filename>lib/merb_core/boot/bootloader.rb</filename>
    </modified>
    <modified>
      <diff>@@ -67,7 +67,7 @@ module Merb::Template
     # ]}}
     #---
     # @public
-    def register_extensions(engine, extensions) enforce!(engine =&gt; Class, extensions =&gt; Array)
+    def register_extensions(engine, extensions) 
       raise ArgumentError, &quot;The class you are registering does not have a compile_template method&quot; unless
         engine.respond_to?(:compile_template)
       extensions.each{|ext| EXTENSIONS[ext] = engine }</diff>
      <filename>lib/merb_core/controller/template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,3 @@
 corelib = File.join(File.dirname(__FILE__), &quot;core_ext&quot;)
 
-Dir.glob(&quot;#{corelib}/*&quot;).each {|fn| require(File.join(fn))}
\ No newline at end of file
+Dir.glob(&quot;#{corelib}/*&quot;).each {|fn| require fn}
\ No newline at end of file</diff>
      <filename>lib/merb_core/core_ext.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,89 +1,51 @@
 # for OSX compatibility
 Socket.do_not_reverse_lookup = true
+
 module Merb
   module Rack
-    class RequestWrapper
-      def initialize(env)
-        @env = env
+
+    class Adapter
+      def initialize(options={})
+        @static_server = ::Rack::File.new(::File.join(Merb.root, &quot;public&quot;))
       end
       
-      def params
-        @env
-      end
       
-      def body
-        @env['rack.input']
-      end
-    end
-    
-    class &lt;&lt; self
+      def call(env)
+        path        = env['PATH_INFO'].chomp('/')
+        cached_path = (path.empty? ? 'index' : path) + '.html'
         
-      def start(host, ports)
-        ports.each do |port|
-          start_server(host, port)
-          trap(&quot;INT&quot;){ Merb.stop }
-        end  
+        if file_exist?(path)              # Serve the file if it's there
+          serve_staic(env)
+        elsif file_exist?(cached_path)    # Serve the page cache if it's there
+          env['PATH_INFO'] = cached_path
+          serve_staic(env)
+        else                              # No static file, let Merb handle it
+          serve_dynamic(env)
+        end
       end
       
-      def stop  
+      # TODO refactor this in File#can_serve?(path) ??
+      def file_exist?(path)
+        full_path = ::File.join(@static_server.root, ::Rack::Utils.unescape(path))
+        ::File.file?(full_path) &amp;&amp; ::File.readable?(full_path)
       end
       
-    end # class &lt;&lt; self
-    
-  end # Rack
-end # Merb
-
-
-
-
-class Adapter
-  def initialize(options={})
-    @root = options[:root]         || Dir.pwd
-    @env  = options[:environment]  || 'development'
-    
-    load_application
-    
-    @static_server = Rack::File.new(::File.join(Merb.root, &quot;public&quot;))
-  end
-  
-  def load_application
-    ENV['RAILS_ENV'] = @env
+      def serve_staic(env)
+        @static_server.call(env)
+      end
+      
+      def serve_dynamic(env)
+        request = RequestWrapper.new(env)
+        response = StringIO.new
+        begin
+          controller, action = ::Merb::Dispatcher.handle(request, response)
+        rescue Object =&gt; e
+          return [500, {&quot;Content-Type&quot;=&gt;&quot;text/html&quot;}, &quot;Internal Server Error&quot;]
+        end
+        [controller.status, controller.headers, controller.body]
+      end
 
-    require &quot;#{@root}/config/environment&quot;
-    require 'dispatcher'
-  end
-  
-  # TODO refactor this in File#can_serve?(path) ??
-  def file_exist?(path)
-    full_path = ::File.join(@static_server.root, Utils.unescape(path))
-    ::File.file?(full_path) &amp;&amp; ::File.readable?(full_path)
-  end
-  
-  def serve_staic(env)
-    @static_server.call(env)
-  end
-  
-  def serve_dynamic(env)
-    request = RequestWrapper.new(env)
-    response = StringIO.new
-    begin
-      controller, action = ::Merb::Dispatcher.handle(request, response)
-    rescue Object =&gt; e
-      return [500, {&quot;Content-Type&quot;=&gt;&quot;text/html&quot;}, &quot;Internal Server Error&quot;]
-    end
-    [controller.status, controller.headers, controller.body]
-  end
-  
-  def call(env)
-    path        = env['PATH_INFO'].chomp('/')
-    cached_path = (path.empty? ? 'index' : path) + 'html'
-    
-    if file_exist?(path)              # Serve the file if it's there
-      serve_staic(env)
-    elsif file_exist?(cached_path)    # Serve the page cache if it's there
-      env['PATH_INFO'] = cached_path
-      serve_staic(env)
-    else                              # No static file, let Merb handle it
-      serve_dynamic(env)
+      
     end
-  end
\ No newline at end of file
+  end  
+end    
\ No newline at end of file</diff>
      <filename>lib/merb_core/rack/adapter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,10 +1,9 @@
 module Merb
   module Rack
     class FastCGI &lt; Adapter
-      class &lt;&lt; self
-        def start_server(host=nil, port=nil)
-          Rack::Handler::FastCGI.run(self)
-        end
+      def self.start_server(host=nil, port=nil)
+        app = new
+        Rack::Handler::FastCGI.run(app)
       end
     end
   end</diff>
      <filename>lib/merb_core/rack/adapter/fcgi.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,13 +4,12 @@ require 'rack/handler/mongrel'
 module Merb
   module Rack
     class Mongrel &lt; Adapter
-      class &lt;&lt; self
-        # start server on given host and port.
-        def start_server(host, port)
-          server = ::Mongrel::HttpServer.new(host, port)
-          server.register('/', ::Rack::Handler::Mongrel.new(self))
-          server.run.join
-        end
+      # start server on given host and port.
+      def self.start_server(host, port)
+        app = new
+        server = ::Mongrel::HttpServer.new(host, port)
+        server.register('/', ::Rack::Handler::Mongrel.new(app))
+        server.run.join
       end
     end
   end</diff>
      <filename>lib/merb_core/rack/adapter/mongrel.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,14 +3,13 @@ require 'thin'
 module Merb
   module Rack
     class Mongrel &lt; Adapter
-      class &lt;&lt; self
-        # start server on given host and port.
-        def start_server(host, port)
-          server = ::Thin::Server.new(host, port, self)
-          server.silent = true
-          server.timeout = 3
-          server.start!
-        end
+      # start a Thin server on given host and port.
+      def self.start_server(host, port)
+        app = new
+        server = ::Thin::Server.new(host, port, app)
+        server.silent = true
+        server.timeout = 3
+        server.start!
       end
     end
   end</diff>
      <filename>lib/merb_core/rack/adapter/thin.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,24 +4,22 @@ require 'rack/handler/webrick'
 module Merb
   module Rack
     class WEBrick &lt; Adapter
-      class &lt;&lt; self
-        # start server on given host and port.
-        def start_server(host, port)
-          options = {
-            :Port        =&gt; port,
-            :BindAddress =&gt; host,
-            :Logger      =&gt; Merb.logger,
-            :AccessLog   =&gt; [
-              [Merb.logger, ::WEBrick::AccessLog::COMMON_LOG_FORMAT],
-              [Merb.logger, ::WEBrick::AccessLog::REFERER_LOG_FORMAT]
-            ]
-          }.merge(options)
-
-
-          server = ::WEBrick::HTTPServer.new(options)
-          server.mount(&quot;/&quot;, ::Rack::Handler::WEBrick, self)
-          server.start
-        end
+      # start WEBrick server on given host and port.
+      def self.start_server(host, port)
+        app = new
+        options = {
+          :Port        =&gt; port,
+          :BindAddress =&gt; host,
+          :Logger      =&gt; Merb.logger,
+          :AccessLog   =&gt; [
+            [Merb.logger, ::WEBrick::AccessLog::COMMON_LOG_FORMAT],
+            [Merb.logger, ::WEBrick::AccessLog::REFERER_LOG_FORMAT]
+          ]
+        }
+     
+        server = ::WEBrick::HTTPServer.new(options)
+        server.mount(&quot;/&quot;, ::Rack::Handler::WEBrick, app)
+        server.start
       end
     end
   end</diff>
      <filename>lib/merb_core/rack/adapter/webrick.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>86eef63c291eb02a236ee9f966aee55c0b0c21b0</id>
    </parent>
  </parents>
  <author>
    <name>Ezra Zygmuntowicz</name>
    <email>ez@engineyard.com</email>
  </author>
  <url>http://github.com/wycats/merb-core/commit/7dffeb416ffd4f55763551387cabf6c7aff441c4</url>
  <id>7dffeb416ffd4f55763551387cabf6c7aff441c4</id>
  <committed-date>2008-01-13T17:50:05-08:00</committed-date>
  <authored-date>2008-01-13T17:50:05-08:00</authored-date>
  <message>Updated rack adapters, added Merb::Config and made a merb binary that works</message>
  <tree>94306e7ee23b53d4a690f6c06a9823173b151c61</tree>
  <committer>
    <name>Ezra Zygmuntowicz</name>
    <email>ez@engineyard.com</email>
  </committer>
</commit>
