Changeset 1228

Show
Ignore:
Timestamp:
01/09/08 11:45:24 (9 months ago)
Author:
e.@brainspl.at
Message:

checking in server.rb refactor, split into config.rb boot_loader.rb, integrated Merb.root stuff. This will probably break a few small things and maybe some plugins but bear with me as this is a needed change. do not use Merb::Server.config[:foo] anymore, instead use Merb::Config[:foo], do not use MERB_ROOT anymore use Merb.root instead

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/README

    r1224 r1228  
    104104 
    105105To use your choice ORM, install the appropriate gem and uncomment the appropriate +use_orm+ line in 
    106 MERB_ROOT/config/dependencies.rb 
     106Merb.root/config/dependencies.rb 
    107107 
    108108=== Controllers 
    109109 
    110 (MERB_ROOT/app/controllers/*) 
     110(Merb.root/app/controllers/*) 
    111111 
    112112Merb controllers inherit from Merb::Controller and contain built in view/template rendering. 
     
    118118you are going to want to end your functions with a call to +render+.  By default, +render+ will 
    119119render the view template associated with your action (in default merb that would be  
    120 MERB_ROOT/app/views/<controller>/<action>.html.erb - see the View section for more info.) 
    121  
    122 Controllers can be generated by calling MERB_ROOT/script/generate controller ControllerName. 
    123 By default, generated controllers inherit from the Application class (MERB_ROOT/app/controllers/application.rb) 
     120Merb.root/app/views/<controller>/<action>.html.erb - see the View section for more info.) 
     121 
     122Controllers can be generated by calling Merb.root/script/generate controller ControllerName. 
     123By default, generated controllers inherit from the Application class (Merb.root/app/controllers/application.rb) 
    124124which itself inherits from Merb:Controller.  Application is a good place to put code pertinent to all controllers. 
    125125An example would be setting a filter to check if a user is logged in or to preload user data for each controller. 
     
    179179=== Views 
    180180 
    181 (MERB_ROOT/app/views/*) 
     181(Merb.root/app/views/*) 
    182182 
    183183A view can be loosely defined as any data sent back to the client (a "view" of your data.) 
     
    186186By default, a call to +render+ without any options renders the view template associated 
    187187with that controller action.  Using the default ERB templating system, this means that a 
    188 call to +render+ in Posts#index would render the file MERB_ROOT/app/views/posts/index.html.erb 
     188call to +render+ in Posts#index would render the file Merb.root/app/views/posts/index.html.erb 
    189189 
    190190==== Layouts 
    191191 
    192 (MERB_ROOT/app/views/layout/*) 
     192(Merb.root/app/views/layout/*) 
    193193 
    194194Layouts are generic templates in which your specific view templates are rendered.  A sample 
     
    206206 
    207207By default, +render+ will look for a corresponding layout for your controller in the form 
    208 of MERB_ROOT/app/views/layout/<controller>.html.erb .  If no specific layout is present, 
    209 +render+ will attempt to use MERB_ROOT/app/view/layout/application.html.erb 
     208of Merb.root/app/views/layout/<controller>.html.erb .  If no specific layout is present, 
     209+render+ will attempt to use Merb.root/app/view/layout/application.html.erb 
    210210 
    211211<i>See #render for more details/options, as well as how to use different templating systems 
     
    230230=== Helpers 
    231231 
    232 (MERB_ROOT/app/helpers/*) 
     232(Merb.root/app/helpers/*) 
    233233 
    234234app/helpers/global_helper.rb will be available to all of your views. 
     
    242242        def upload 
    243243          puts params[:file].inspect 
    244           FileUtils.mv params[:file][:tempfile].path, MERB_ROOT+"/uploads/#{params[:file][:filename]}" 
     244          FileUtils.mv params[:file][:tempfile].path, Merb.root+"/uploads/#{params[:file][:filename]}" 
    245245          render 
    246246        end 
  • trunk/Rakefile

    r1224 r1228  
    7777desc "Run :package and install the resulting .gem" 
    7878task :install => :package do 
    79   sh %{#{SUDO} gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-update-sources --no-rdoc --no-ri} 
     79  sh %{#{SUDO} gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri} 
    8080end 
    8181 
  • trunk/app_generators/merb/templates/config/dependencies.rb

    r910 r1228  
    11# Make the app's "gems" directory a place where gems are loaded from 
    22Gem.clear_paths 
    3 Gem.path.unshift(MERB_ROOT / "gems") 
     3Gem.path.unshift(Merb.root / "gems") 
    44 
    55# Make the app's "lib" directory a place where ruby files get "require"d from 
    6 $LOAD_PATH.unshift(MERB_ROOT / "lib") 
     6$LOAD_PATH.unshift(Merb.root / "lib") 
    77 
    88### Merb doesn't come with database support by default.  You need 
     
    3535# dependencies "RedCloth" => "> 3.0", "ruby-aes-cext" => "= 1.0" 
    3636 
    37 Merb::Server.after_app_loads do 
     37Merb::BootLoader.after_app_loads do 
    3838  ### Add dependencies here that must load after the application loads: 
    3939 
  • trunk/app_generators/merb/templates/config/merb_init.rb

    r853 r1228  
    55# Your app's dependencies, including your database layer (if any) are defined 
    66# in config/dependencies.rb 
    7 require File.join(MERB_ROOT, 'config', 'dependencies') 
     7require File.join(Merb.root, 'config', 'dependencies') 
    88 
    99# Here's where your controllers, helpers, and models, etc. get loaded.  If you 
     
    1111# around this file. 
    1212puts "Loading Application..." 
    13 Merb::Server.load_application 
     13Merb::BootLoader.load_application 
    1414 
    1515# Load environment-specific configuration 
    16 require File.join(MERB_ROOT, 'config', 'environments', MERB_ENV
     16require File.join(Merb.root, 'config', 'environments', Merb.environment
  • trunk/lib/merb.rb

    r1176 r1228  
    2727 require 'mongrel' 
    2828end 
     29require 'set' 
    2930require 'fileutils' 
    3031require 'merb/erubis_ext' 
    3132require 'merb/logger' 
     33require 'merb/version' 
    3234 
    33 require 'set' 
    3435autoload :MerbUploadHandler, 'merb/upload_handler' 
    3536autoload :MerbHandler, 'merb/mongrel_handler' 
    3637 
    37 require 'merb/version' 
     38module Merb 
     39  autoload :AbstractController,     'merb/abstract_controller' 
     40  autoload :Assets,                 'merb/assets' 
     41  autoload :Authentication,         'merb/mixins/basic_authentication' 
     42  autoload :Caching,                'merb/caching' 
     43  autoload :Const,                  'merb/constants' 
     44  autoload :Controller,             'merb/controller' 
     45  autoload :ControllerExceptions,   'merb/exceptions' 
     46  autoload :ControllerMixin,        'merb/mixins/controller' 
     47  autoload :Dispatcher,             'merb/dispatcher' 
     48  autoload :DrbServiceProvider,     'drb_server' 
     49  autoload :ErubisCaptureMixin,     'merb/mixins/erubis_capture' 
     50  autoload :GeneralControllerMixin, 'merb/mixins/general_controller' 
     51  autoload :InlinePartialMixin,     'merb/mixins/inline_partial' 
     52  autoload :MailController,         'merb/mail_controller' 
     53  autoload :Mailer,                 'merb/mailer' 
     54  autoload :PartController,         'merb/part_controller' 
     55  autoload :Plugins,                'merb/plugins' 
     56  autoload :Rack,                   'merb/rack_adapter' 
     57  autoload :RenderMixin,            'merb/mixins/render' 
     58  autoload :Request,                'merb/request' 
     59  autoload :ResponderMixin,         'merb/mixins/responder' 
     60  autoload :Router,                 'merb/router' 
     61  autoload :Server,                 'merb/server' 
     62  autoload :SessionMixin,           'merb/session' 
     63  autoload :Template,               'merb/template' 
     64  autoload :UploadProgress,         'merb/upload_progress' 
     65  autoload :ViewContext,            'merb/view_context' 
     66  autoload :ViewContextMixin,       'merb/mixins/view_context' 
     67  autoload :WebControllerMixin,     'merb/mixins/web_controller' 
     68   
     69  # This is where Merb-global variables are set and held 
     70  class << self 
     71                def environment 
     72                        @environment 
     73                end 
     74                 
     75                def environment=(value) 
     76                        @environment ||= value 
     77                end 
     78                 
     79                def load_paths 
     80                        [ "/app/models/**/*.rb", 
     81                                "/app/controllers/application.rb", 
     82                                "/app/controllers/**/*.rb", 
     83                                "/app/helpers/**/*.rb", 
     84                                "/app/mailers/**/*.rb", 
     85                                "/app/parts/**/*.rb", 
     86                                "/config/router.rb" 
     87                        ] 
     88                end 
     89                 
     90                # Application paths 
     91                def root 
     92                  @root || Merb::Config[:merb_root] || Dir.pwd 
     93                end 
     94                 
     95                def root_path(*path) 
     96                        File.join(root, *path) 
     97                end 
     98                 
     99                def view_path 
     100                        root_path 'app/views' 
     101                end 
     102                 
     103                def model_path 
     104                        root_path 'app/models' 
     105                end 
     106                 
     107                def application_controller_path 
     108                        root_path 'app/controllers/application.rb' 
     109                end 
     110                 
     111                def controller_path 
     112                        root_path 'app/controllers' 
     113                end 
     114                 
     115                def helper_path 
     116                        root_path 'app/helpers' 
     117                end 
     118                 
     119                def mailer_path 
     120                        root_path 'app/mailers' 
     121                end 
     122                 
     123                def part_path 
     124                  root_path 'app/parts' 
     125                end 
     126                 
     127                def router_path 
     128                        root_path '/config/router.rb' 
     129                end 
     130                 
     131                def root=(value) 
     132                        @root ||= value 
     133                end 
     134                 
     135                 
     136                # Logger settings 
     137                attr :logger, true 
     138                 
     139                def log_path 
     140                  if $TESTING 
     141        "#{Merb.root}/log/merb_test.log" 
     142      elsif !(Merb::Config[:daemonize] || Merb::Config[:cluster] ) 
     143        STDOUT 
     144      else 
     145        "#{Merb.root}/log/merb.#{Merb::Config[:port]}.log" 
     146                  end 
     147                end 
     148                 
     149                # Framework paths 
     150                 
     151                def framework_root 
     152                        @framework_root ||= File.dirname(__FILE__) 
     153                end 
     154                 
     155                def framework_path(path) 
     156                        File.join(framework_root, path) 
     157                end 
     158                 
     159                def lib_path 
     160                        framework_path 'merb' 
     161                end 
     162                 
     163                def skeleton_path 
     164                        framework_path '../app_generators/merb/templates' 
     165                end 
     166  end 
    38167 
    39 module Merb 
    40   autoload :Authentication, 'merb/mixins/basic_authentication' 
    41   autoload :ControllerMixin, 'merb/mixins/controller' 
    42   autoload :ErubisCaptureMixin, 'merb/mixins/erubis_capture' 
    43   autoload :InlinePartialMixin, 'merb/mixins/inline_partial' 
    44   autoload :FormControls, 'merb/mixins/form_control' 
    45   autoload :RenderMixin, 'merb/mixins/render' 
    46   autoload :ResponderMixin, 'merb/mixins/responder' 
    47   autoload :ViewContextMixin, 'merb/mixins/view_context' 
    48   autoload :WebControllerMixin, 'merb/mixins/web_controller' 
    49   autoload :GeneralControllerMixin, 'merb/mixins/general_controller' 
    50   autoload :Caching, 'merb/caching' 
    51   autoload :AbstractController, 'merb/abstract_controller' 
    52   autoload :Const, 'merb/constants' 
    53   autoload :Controller, 'merb/controller' 
    54   autoload :Dispatcher, 'merb/dispatcher' 
    55   autoload :DrbServiceProvider, 'drb_server' 
    56   autoload :ControllerExceptions, 'merb/exceptions' 
    57   autoload :MailController, 'merb/mail_controller' 
    58   autoload :Mailer, 'merb/mailer' 
    59   autoload :PartController, 'merb/part_controller' 
    60   autoload :Request, 'merb/request' 
    61   autoload :Router, 'merb/router' 
    62   autoload :Server, 'merb/server' 
    63   autoload :UploadProgress, 'merb/upload_progress' 
    64   autoload :ViewContext, 'merb/view_context' 
    65   autoload :SessionMixin, 'merb/session' 
    66   autoload :Template, 'merb/template' 
    67   autoload :Plugins, 'merb/plugins' 
    68   autoload :Rack,'merb/rack_adapter' 
    69   autoload :Assets, 'merb/assets' 
    70  
    71   # Set up Merb::Server.config[] as an accessor for @@merb_opts 
    72   class Server 
    73     class << self 
    74       def config() @@merb_opts ||= {} end 
    75     end   
    76   end 
    77    
    78168  # Set up default generator scope 
    79169  GENERATOR_SCOPE = [:merb_default, :merb, :rspec] 
    80170end 
    81171 
    82 def __DIR__; File.dirname(__FILE__); end 
    83 lib = File.join(__DIR__, 'merb') 
    84 require File.join(__DIR__, 'merb/core_ext') 
     172# Load up the core extensions 
     173require Merb.framework_path('merb/core_ext') 
     174require Merb.framework_path('merb/version') 
    85175 
    86 unless Object.const_defined?('MERB_ENV') 
    87   MERB_ENV = Merb::Server.config[:environment].nil? ? ($TESTING ? 'test' : 'development') : Merb::Server.config[:environment] 
    88 end 
     176# Set the environment 
     177Merb.environment =  Merb::Config[:environment] || ($TESTING ? 'test' : 'development') 
    89178 
    90 MERB_FRAMEWORK_ROOT = __DIR__ 
    91 MERB_ROOT = Merb::Server.config[:merb_root] || Dir.pwd 
    92 MERB_VIEW_ROOT = MERB_ROOT / "app/views" 
    93 MERB_SKELETON_DIR = File.join(MERB_FRAMEWORK_ROOT, '../app_generators/merb/templates') 
    94 logpath = if $TESTING 
    95            "#{MERB_ROOT}/log/merb_test.log" 
    96           elsif !(Merb::Server.config[:daemonize] || Merb::Server.config[:cluster] ) 
    97             STDOUT 
    98           else 
    99             "#{MERB_ROOT}/log/merb.#{Merb::Server.config[:port]}.log" 
    100           end 
    101 FileUtils.mkdir_p(File.dirname(logpath)) if logpath.is_a?(String) 
    102 MERB_LOGGER = Merb::Logger.new(logpath) 
    103 MERB_LOGGER.level = Merb::Logger.const_get(Merb::Server.config[:log_level].upcase) rescue Merb::Logger::INFO 
    104 MERB_PATHS = [  
    105   "/app/models/**/*.rb", 
    106   "/app/controllers/application.rb", 
    107   "/app/controllers/**/*.rb", 
    108   "/app/helpers/**/*.rb", 
    109   "/app/mailers/**/*.rb", 
    110   "/app/parts/**/*.rb", 
    111   "/config/router.rb" 
    112   ] 
    113  
    114 if $TESTING 
    115   test_files = File.join(lib, 'test', '*.rb') 
    116   Dir[test_files].each { |file| require file } 
    117 end 
    118  
    119 # If we're in the TEST environment or if running from Rake make sure to load  
    120 # config/merb.yml - which is normally done by Merb::Server.run 
    121 Merb::Server.load_config if $TESTING || $RAKE_ENV 
     179# Create and setup the logger 
     180Merb.logger = Merb::Logger.new(Merb.log_path) 
     181Merb.logger.level = Merb::Logger.const_get(Merb::Config[:log_level].upcase) rescue Merb::Logger::INFO 
    122182 
    123183# If you don't use the JSON gem, disable auto-parsing of json params too 
    124 if Merb::Server.config[:disable_json_gem] 
     184if Merb::Config[:disable_json_gem] 
    125185  Merb::Request::parse_json_params = false 
    126186else 
     
    132192  end 
    133193end 
     194 
     195if $TESTING 
     196  test_files = File.join(Merb.lib_path, 'test', '*.rb') 
     197  Dir[test_files].each { |file| require file } 
     198end 
  • trunk/lib/merb/abstract_controller.rb

    r1156 r1228  
    264264      ) unless [Symbol, String].include? filter.class 
    265265 
    266       MERB_LOGGER.warn("Filter #{filter} was not found in your filter chain." 
     266      Merb::Logger.warn("Filter #{filter} was not found in your filter chain." 
    267267      ) unless filters.reject! {|f| f.first.to_s[filter.to_s] } 
    268268    end 
  • trunk/lib/merb/assets.rb

    r1137 r1228  
    55    # :bundle_assets is explicitly enabled), false if not. 
    66    def self.bundle? 
    7       (Merb::Server.config[:environment] == :production) || 
    8       (!!Merb::Server.config[:bundle_assets]) 
     7      (Merb::Config[:environment] == :production) || 
     8      (!!Merb::Config[:bundle_assets]) 
    99    end 
    1010     
     
    1818       
    1919      # Returns the URI path to a particular asset file. If +local_path+ is 
    20       # true, returns the path relative to the MERB_ROOT, not the public 
     20      # true, returns the path relative to the Merb.root, not the public 
    2121      # directory. Uses the path_prefix, if any is configured. 
    2222      #  
     
    3232          return "public#{filename}" 
    3333        else 
    34           return "#{Merb::Server.config[:path_prefix]}#{filename}" 
     34          return "#{Merb::Config[:path_prefix]}#{filename}" 
    3535        end 
    3636      end 
  • trunk/lib/merb/caching.rb

    r187 r1228  
    1 corelib = __DIR__+'/merb/caching' 
     1corelib = Merb.framework_root + '/merb/caching' 
    22 
    33%w[ action_cache 
  • trunk/lib/merb/caching/action_cache.rb

    r590 r1228  
    6363 
    6464      def _caching_enabled? 
    65         ::Merb::Server.config[:cache_templates] 
     65        ::Merb::Config[:cache_templates] 
    6666      end 
    6767 
  • trunk/lib/merb/caching/fragment_cache.rb

    r590 r1228  
    2626         
    2727        def determine_cache_store 
    28           if ::Merb::Server.config[:cache_store].to_s == "file" 
     28          if ::Merb::Config[:cache_store].to_s == "file" 
    2929            require 'merb/caching/store/file_cache' 
    3030            ::Merb::Caching::Store::FileCache.new 
  • trunk/lib/merb/caching/store/file_cache.rb

    r762 r1228  
    1010             
    1111        def initialize(name = "cache", keepalive = nil) 
    12           @path = File.join(MERB_ROOT, name) 
     12          @path = File.join(Merb.root, name) 
    1313          @keepalive = keepalive   
    1414        end 
  • trunk/lib/merb/controller.rb

    r1159 r1228  
    1919  # === Session Store 
    2020  # 
    21   # The session store is set in MERB_ROOT/config/merb.yml : 
     21  # The session store is set in Merb.root/config/merb.yml : 
    2222  # 
    2323  #   :session_store: your_store 
     
    8484    def set_dispatch_variables(request, response, status, headers) 
    8585      if request.params.key?(_session_id_key) 
    86         if Merb::Server.config[:session_id_cookie_only] 
     86        if Merb::Config[:session_id_cookie_only] 
    8787          # This condition allows for certain controller/action paths to allow 
    8888          # a session ID to be passed in a query string. This is needed for 
     
    9191          # advantage of this in case someone is attempting a session fixation 
    9292          # attack 
    93           if Merb::Server.config[:query_string_whitelist].include?("#{request.controller_name}/#{request.action}") 
     93          if Merb::Config[:query_string_whitelist].include?("#{request.controller_name}/#{request.action}") 
    9494          # FIXME to use routes not controller and action names -----^ 
    9595            request.cookies[_session_id_key] = request.params[_session_id_key] 
     
    116116      end 
    117117      @_benchmarks[:action_time] = Time.now - start 
    118       MERB_LOGGER.info("Time spent in #{self.class}##{action} action: #{@_benchmarks[:action_time]} seconds") 
     118      Merb.logger.info("Time spent in #{self.class}##{action} action: #{@_benchmarks[:action_time]} seconds") 
    119119    end 
    120120       
  • trunk/lib/merb/core_ext/kernel.rb

    r1185 r1228  
    1010    begin 
    1111      # If it's not in ROOT/gems, skip to the next attempt 
    12       raise LoadError unless File.directory?(MERB_ROOT / "gems") 
     12      raise LoadError unless File.directory?(Merb.root / "gems") 
    1313       
    1414      # cache the gem path 
    1515      begin 
    1616        # Clear out the paths and reset them to Merb 
    17         Gem.use_paths(MERB_ROOT / "gems", [MERB_ROOT / "gems"]) 
     17        Gem.use_paths(Merb.root / "gems", [Merb.root / "gems"]) 
    1818         
    1919        # Try activating the gem (Failure will raise a LoadError) 
    2020        Gem.activate(name, true, *ver) 
    21         MERB_LOGGER.info("#{Time.now.httpdate}: loading gem '#{name}' from #{__app_file_trace__.first} ...") 
     21        Merb.logger.info("#{Time.now.httpdate}: loading gem '#{name}' from #{__app_file_trace__.first} ...") 
    2222      ensure 
    2323        # Either way, set the gem path back to normal 
     
    3030        # Try activating again 
    3131        Gem.activate(name, true, *ver) 
    32         MERB_LOGGER.info("#{Time.now.httpdate}: loading gem '#{name}' from #{__app_file_trace__.first} ...") 
     32        Merb.logger.info("#{Time.now.httpdate}: loading gem '#{name}' from #{__app_file_trace__.first} ...") 
    3333      rescue LoadError 
    3434        # Failed requiring as a gem, let's try loading with a normal require. 
     
    6363    message = "#{Time.now.httpdate}: loading library '#{library}' from #{__app_file_trace__.first} ..." 
    6464    puts(message) 
    65     MERB_LOGGER.info(message) 
     65    Merb.logger.info(message) 
    6666  rescue LoadError 
    6767    # TODO: adjust the two messages below to use merb's logger.error/info once logging refactor is complete. 
    6868    message = "#{Time.now.httpdate}: <e> Could not find '#{library}' as either a library or gem, loaded from #{__app_file_trace__.first}.\n" 
    6969    puts(message) 
    70     MERB_LOGGER.error(message) 
     70    Merb.logger.error(message) 
    7171     
    7272    # Print a helpful message 
     
    7575    message << "#{Time.now.httpdate}: <i>   * is included within a gem, be sure that you are specifying the gem as a dependency \n" 
    7676    puts(message) 
    77     MERB_LOGGER.error(message) 
     77    Merb.logger.error(message) 
    7878    exit() # Missing library/gem must be addressed. 
    7979  end 
     
    8888  end 
    8989   
    90   # Used in MERB_ROOT/dependencies.yml 
     90  # Used in Merb.root/dependencies.yml 
    9191  # Tells merb which ORM (Object Relational Mapper) you wish to use. 
    9292  # Currently merb has plugins to support ActiveRecord, DataMapper, and Sequel. 
     
    107107  end 
    108108   
    109   # Used in MERB_ROOT/dependencies.yml 
     109  # Used in Merb.root/dependencies.yml 
    110110  # Tells merb which testing framework to use. 
    111111  # Currently merb supports rspec and test_unit for testing 
     
    129129  def __app_file_trace__ 
    130130    caller.select do |call|  
    131       call.include?(MERB_ROOT) && !call.include?(MERB_ROOT + "/framework") 
     131      call.include?(Merb.root) && !call.include?(Merb.root + "/framework") 
    132132    end.map do |call| 
    133       file, line = call.scan(Regexp.new("#{MERB_ROOT}/(.*):(.*)")).first 
     133      file, line = call.scan(Regexp.new("#{Merb.root}/(.*):(.*)")).first 
    134134      "#{file}:#{line}" 
    135135    end 
     
    193193  # Requires ruby-prof (<tt>sudo gem install ruby-prof</tt>) 
    194194  # Takes a block and profiles the results of running the block 100 times. 
    195   # The resulting profile is written out to MERB_ROOT/log/#{name}.html. 
     195  # The resulting profile is written out to Merb.root/log/#{name}.html. 
    196196  # <tt>min</tt> specifies the minimum percentage of the total time a method must take for it to be included in the result. 
    197197  # 
     
    211211    end 
    212212    printer = RubyProf::GraphHtmlPrinter.new(result) 
    213     path = File.join(MERB_ROOT, 'log', "#{name}.html") 
     213    path = File.join(Merb.root, 'log', "#{name}.html") 
    214214    File.open(path, 'w') do |file| 
    215215     printer.print(file, {:min_percent => min, 
     
    235235    # Drops a not to the logs that Debugger was not available 
    236236    def debugger 
    237        MERB_LOGGER.info "\n***** Debugger requested, but was not " +  
     237       Merb.logger.info "\n***** Debugger requested, but was not " +  
    238238                        "available: Start server with --debugger " + 
    239239                        "to enable *****\n" 
  • trunk/lib/merb/dispatcher.rb

    r1059 r1228  
    33     
    44    DEFAULT_ERROR_TEMPLATE = Erubis::MEruby.new((File.read( 
    5         File.join(MERB_ROOT, 'app/views/exceptions/internal_server_error.html.erb')) rescue "Internal Server Error!")) 
     5        File.join(Merb.root, 'app/views/exceptions/internal_server_error.html.erb')) rescue "Internal Server Error!")) 
    66         
    77    class << self 
     
    1212       
    1313      @@mutex = Mutex.new 
    14       @@use_mutex = ::Merb::Server.config[:use_mutex] 
     14      @@use_mutex = ::Merb::Config[:use_mutex] 
    1515      # This is where we grab the incoming request REQUEST_URI and use that in 
    1616      # the merb RouteMatcher to determine which controller and method to run. 
     
    2222        start   = Time.now 
    2323        request = Merb::Request.new(http_request) 
    24         MERB_LOGGER.info("Params: #{request.params.inspect}") 
    25         MERB_LOGGER.info("Cookies: #{request.cookies.inspect}") 
     24        Merb.logger.info("Params: #{request.params.inspect}") 
     25        Merb.logger.info("Cookies: #{request.cookies.inspect}") 
    2626        # user friendly error messages 
    2727        if request.route_params.empty? 
     
    3030          raise ControllerExceptions::BadRequest, "Route matched, but route did not specify a controller"  
    3131        end 
    32         MERB_LOGGER.debug("Routed to: #{request.route_params.inspect}") 
     32        Merb.logger. debug("Routed to: #{request.route_params.inspect}") 
    3333        # set controller class and the action to call 
    3434        klass = request.controller_class 
    3535        dispatch_action(klass, request.action, request, response) 
    3636      rescue => exception 
    37         MERB_LOGGER.error(Merb.exception(exception)) 
     37        Merb.logger.error(Merb.exception(exception)) 
    3838        exception = controller_exception(exception) 
    3939        dispatch_exception(request, response, exception) 
  • trunk/lib/merb/logger.rb

    r1092 r1228  
    2929        @log.write("# Logfile created on %s\n" % [Time.now.to_s]) 
    3030      end 
    31       if !MERB_ENV.match(/development|test/) &&  
     31      if !Merb.environment.match(/development|test/) &&  
    3232         !RUBY_PLATFORM.match(/java|mswin/) && 
    3333         !(@log == STDOUT) && 
  • trunk/lib/merb/mail_controller.rb

    r1120 r1228  
    184184          # An error should be logged if no template is found instead of an error raised 
    185185          if @_missing_templates 
    186             MERB_LOGGER.error(e) 
     186            Merb.logger.error(e) 
    187187          else 
    188188            @_missing_templates = true 
     
    238238      if !@mail.html.blank? || !@mail.text.blank?  
    239239        @mailer.deliver! 
    240         MERB_LOGGER.info "#{method} sent to #{@mail.to} about #{@mail.subject}" 
     240        Merb.logger.info "#{method} sent to #{@mail.to} about #{@mail.subject}" 
    241241      else 
    242         MERB_LOGGER.info "#{method} was not sent because nothing was rendered for it" 
     242        Merb.logger.info "#{method} was not sent because nothing was rendered for it" 
    243243      end 
    244244    end 
  • trunk/lib/merb/mailer.rb

    r1173 r1228  
    44rescue LoadError 
    55  puts "You need to install the mailfactory gem to use Merb::Mailer" 
    6   MERB_LOGGER.warn "You need to install the mailfactory gem to use Merb::Mailer" 
     6  Merb::Logger.warn "You need to install the mailfactory gem to use Merb::Mailer" 
    77end   
    88 
  • trunk/lib/merb/mixins/basic_authentication.rb

    r820 r1228  
    1414    def authenticated? 
    1515      username, password = *credentials 
    16       username == Merb::Server.config[:basic_auth][:username] and password == Merb::Server.config[:basic_auth][:password] 
     16      username == Merb::Config[:basic_auth][:username] and password == Merb::Config[:basic_auth][:password] 
    1717    end 
    1818     
     
    2727      headers['Content-type'] = 'text/plain' 
    2828      headers['Status'] = 'Unauthorized' 
    29       headers['WWW-Authenticate'] = "Basic realm=\"#{Merb::Server.config[:basic_auth][:domain]}\"" 
     29      headers['WWW-Authenticate'] = "Basic realm=\"#{Merb::Config[:basic_auth][:domain]}\"" 
    3030      return 'Unauthorized' 
    3131    end   
  • trunk/lib/merb/mixins/controller.rb

    r1080 r1228  
    6767    # 
    6868    def redirect(url) 
    69       MERB_LOGGER.info("Redirecting to: #{url}") 
     69      Merb.logger.info("Redirecting to: #{url}") 
    7070      set_status(302) 
    7171      headers['Location'] = url 
  • trunk/lib/merb/mixins/general_controller.rb

    r1188 r1228  
    8787          raise "URL not generated: #{route_name.inspect}, #{new_params.inspect}" 
    8888        end 
    89       url = Merb::Server.config[:path_prefix] + url if Merb::Server.config[:path_prefix] 
     89      url = Merb::Config[:path_prefix] + url if Merb::Config[:path_prefix] 
    9090      url 
    9191    end 
     
    193193    # 
    194194    def format_extension(new_params={}) 
    195       use_format = Merb::Server.config[:use_format_in_urls] 
     195      use_format = Merb::Config[:use_format_in_urls] 
    196196      if use_format.nil? 
    197197        prms = params.merge(new_params) 
  • trunk/lib/merb/mixins/render.rb

    r1226 r1228  
    1313                                     
    1414        self._layout = :application 
    15         self._template_root = File.expand_path(MERB_VIEW_ROOT
     15        self._template_root = File.expand_path(Merb. view_path
    1616        self._templates = {} 
    1717        self._cached_partials = {} 
  • trunk/lib/merb/mixins/view_context.rb

    r1139 r1228  
    5656          '' 
    5757        else 
    58           if Merb::Server.config[:path_prefix] 
    59             Merb::Server.config[:path_prefix] + '/images/' 
     58          if Merb::Config[:path_prefix] 
     59            Merb::Config[:path_prefix] + '/images/' 
    6060          else 
    6161            '/images/' 
  • trunk/lib/merb/mongrel_handler.rb

    r1039 r1228  
    5050    benchmarks = {} 
    5151     
    52     MERB_LOGGER.info("\nRequest: REQUEST_URI: #{ 
     52    Merb.logger.info("\nRequest: REQUEST_URI: #{ 
    5353      request.params[Mongrel::Const::REQUEST_URI]}  (#{Time.now.strftime("%Y-%m-%d %H:%M:%S")})") 
    5454     
     
    5757    if @@path_prefix 
    5858      if request.params[Mongrel::Const::PATH_INFO] =~ @@path_prefix 
    59         MERB_LOGGER.info("Path prefix #{@@path_prefix.inspect} removed from PATH_INFO and REQUEST_URI.") 
     59        Merb.logger.info("Path prefix #{@@path_prefix.inspect} removed from PATH_INFO and REQUEST_URI.") 
    6060        request.params[Mongrel::Const::PATH_INFO].sub!(@@path_prefix, '') 
    6161        request.params[Mongrel::Const::REQUEST_URI].sub!(@@path_prefix, '') 
     
    7676    if get_or_head && @files.can_serve(path_info) 
    7777      # File exists as-is so serve it up 
    78       MERB_LOGGER.info("Serving static file: #{path_info}") 
     78      Merb.logger.info("Serving static file: #{path_info}") 
    7979      @files.process(request,response) 
    8080    elsif get_or_head && @files.can_serve(page_cached) 
    8181      # Possible cached page, serve it up 
    82       MERB_LOGGER.info("Serving static file: #{page_cached}") 
     82      Merb.logger.info("Serving static file: #{page_cached}") 
    8383      request.params[Mongrel::Const::PATH_INFO] = page_cached 
    8484      @files.process(request,response) 
     
    9090      benchmarks[:action]     = action 
    9191 
    92       MERB_LOGGER.info("Routing to controller: #{controller.class} action: #{action}\nRoute Recognition & Parsing HTTP Input took: #{benchmarks[:setup_time]} seconds") 
     92      Merb.logger.info("Routing to controller: #{controller.class} action: #{action}\nRoute Recognition & Parsing HTTP Input took: #{benchmarks[:setup_time]} seconds") 
    9393       
    9494      sendfile, clength = nil 
     
    112112          # we want to emulate X-Sendfile header internally in mongrel 
    113113          benchmarks[:sendfile_time] = Time.now - start         
    114           MERB_LOGGER.info("X-SENDFILE: #{sendfile}\nComplete Request took: #{ 
     114          Merb.logger.info("X-SENDFILE: #{sendfile}\nComplete Request took: #{ 
    115115            benchmarks[:sendfile_time]} seconds") 
    116116          file_status     = File.stat(sendfile) 
     
    153153      benchmarks[:total_request_time] = total_request_time 
    154154         
    155       MERB_LOGGER.info("Request Times: #{benchmarks.inspect}\nResponse status: #{response.status}\nComplete Request took: #{total_request_time} seconds, #{1.0/total_request_time} Requests/Second\n\n") 
     155      Merb.logger.info("Request Times: #{benchmarks.inspect}\nResponse status: #{response.status}\nComplete Request took: #{total_request_time} seconds, #{1.0/total_request_time} Requests/Second\n\n") 
    156156    end 
    157157  rescue Object => e 
     
    162162    response.send_header 
    163163    response.write("500 Internal Server Error") 
    164     MERB_LOGGER.error(Merb.exception(e)) 
     164    Merb.logger.error(Merb.exception(e)) 
    165165  ensure 
    166     MERB_LOGGER.flush 
     166    Merb.logger.flush 
    167167  end 
    168168end 
  • trunk/lib/merb/plugins.rb

    r708 r1228  
    22  module Plugins 
    33    def self.config 
    4       @config ||= File.exists?(MERB_ROOT / "config" / "plugins.yml") ? YAML.load(File.read(MERB_ROOT / "config" / "plugins.yml")) || {} : {} 
     4      @config ||= File.exists?(Merb.root / "config" / "plugins.yml") ? YAML.load(File.read(Merb.root / "config" / "plugins.yml")) || {} : {} 
    55    end 
    66