Changeset 366

Show
Ignore:
Timestamp:
08/01/07 00:04:00 (1 year ago)
Author:
jon.egil.stra..@gmail.com
Message:

Prettier docs, closes #104

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/examples/skeleton/dist/conf/merb.yml

    r323 r366  
    11--- 
    2 # hostname or IP to bind to.  
     2# Hostname or IP address to bind to.  
    33:host: 127.0.0.1 
    44 
    5 # port merb runs on or starting port for merb cluster. 
     5# Port merb runs on or starting port for merb cluster. 
    66:port: "4000" 
    77 
    8 # in development mode your controler classes get reloaded every request 
    9 # and templates are parsed each time and not cached 
    10 # in production mode templates are cached, as well as all your classes 
     8# In development mode your controller classes get reloaded on every request, 
     9# and templates are parsed each time and not cached. In production mode 
     10# templates are cached, as well as all your classes 
    1111:environment: development 
    1212 
    13 # uncomment for memory sessions. This only works when 
    14 # you are running 1 merb at a time. ANd sessions do not persist  
    15 # between restarts. 
     13# Uncomment for memory sessions. This only works when you are running 1 merb 
     14# at a time. And sessions do not persist between restarts. 
    1615# :memory_session: true 
    1716 
     
    2221# :mem_cache_session: true 
    2322 
    24 # This turns on the ActiveRecord sessions with rails parasite 
    25 # mode if active_support gem is installed. Skeleton app comes with a 
    26 # migration to create the sessions table. Or you can point merb to  
    27 # the same sessions table that your rails app uses to share sessions  
    28 # between merb and rails. 
     23# This turns on the ActiveRecord sessions with rails parasite mode if 
     24# active_support gem is installed. Skeleton app comes with a migration to 
     25# create the sessions table. Or you can point merb to  the same sessions 
     26# table that your rails app uses to share sessions between merb and rails. 
    2927:sql_session: true 
    3028:log_level: debug 
    31 # uncomment to use the merb upload progress 
     29 
     30# Uncomment to use the merb upload progress 
    3231#:config: dist/conf/upload.conf 
    3332 
    34 # uncomment to cache templates in dev mode. 
    35 # templates are cached automatically in production mode. 
     33# Uncomment to cache templates in dev mode. Templates are cached 
     34# automatically in production mode. 
    3635#:cache_templates: true 
    3736 
    38 # uncomment and set this is you want to run a drb 
    39 # server for upload progress or other drb services. 
     37# Uncomment and set this if you want to run a drb server for upload progress 
     38# or other drb services. 
    4039#:drb_server_port: 32323 
    4140 
    42 # If you want to protect some or all of your app with  
    43 # HTTP basic auth then uncomment the folowing and fill 
    44 # in your credentials you want it to use. Then you need 
    45 # to set a before filter in a controller: 
    46 # before :basic_authentication 
     41# If you want to protect some or all of your app with  HTTP basic auth then 
     42# uncomment the following and fill in your credentials you want it to use. 
     43# You will then need to set a 'before' filter in a controller.  For example: 
     44#   before :basic_authentication 
    4745#:basic_auth:  
    4846#  :username: ezra 
     
    5048#  :domain: localhost 
    5149 
    52 # uncomment this if you want merb to daemonize when you start it 
    53 # you can also just use merb -d for the same effect. Don't uncomment 
    54 # this if you use the cluster option 
     50# Uncomment this if you want merb to daemonize when you start it. You can also 
     51# just use merb -d for the same effect. Don't uncomment this if you use the 
     52# cluster option. 
    5553#:daemonize: true 
    5654 
    57 # uncomment this to set the number of members in your merb cluster 
    58 # don't set this and :daemonize: at the same time. 
     55# Uncomment this to set the number of members in your merb cluster. Don't set 
     56# this and :daemonize: at the same time. 
    5957#:cluster: 3 
  • trunk/examples/skeleton/dist/conf/router.rb

    r258 r366  
    11# Merb::RouteMatcher is the request routing mapper for the merb framework. 
    2 # You can define placeholder parts of the url with the :smbol notation. 
    3 # so r.add '/foo/:bar/baz/:id', :class => 'Bar', :method => 'foo' 
    4 # will match against a request to /foo/123/baz/456. It will then 
    5 # use the class Bar as your merb controller and call the foo method on it.  
    6 # the foo method will recieve a hash with {:bar => '123', :id => '456'} 
    7 # as the content. So the :placeholders sections of your routes become 
    8 # a hash of arguments to your controller methods. 
    9 # The default route is installed  
    10  
     2# You can define placeholder parts of the url with the :symbol notation. For 
     3# example: 
     4# 
     5#   r.add '/admin/:email/users/:id', :controller => 'admin_users', :action => 'foo' 
     6# 
     7# will match against a request to /admin/me@gmail.com/users/456. It will then 
     8# use the class AdminUsers as your merb controller and call the 'foo' method 
     9# on it. The 'foo' method will be able to access the :email and :id values via 
     10# the 'params' hash, e.g. 'params[:email]' will return 'me@gmail.com'. 
    1111 
    1212puts "Compiling routes.." 
  • trunk/examples/skeleton/dist/schema/migrations/001_add_sessions_table.rb

    r258 r366  
    22  def self.up 
    33    create_table :sessions, :force => true do |t| 
    4         t.column :session_id,      :string,  :limit => 32 
    5         t.column :created_at, :datetime 
     4        t.column :session_id, :string,  :limit => 32 
     5        t.column :created_at, :datetime 
    66        t.column :data,       :text 
    77    end 
  • trunk/lib/merb/merb_abstract_controller.rb

    r348 r366  
    9191     
    9292     
    93     # #before is a class method that allows you to specify before 
    94     # filters in your controllers. Filters can either be a symbol 
    95     # or string that corresponds to a method name to call, or a  
    96     # proc object. if it is a method name that method will be  
    97     # called and if it is a proc it will be called with an argument 
    98     # of self where self is the current controller object. When  
    99     # you use a proc as a filter it needs to take one parameter. 
     93    # #before is a class method that allows you to specify before filters in 
     94    # your controllers. Filters can either be a symbol or string that 
     95    # corresponds to a method name to call, or a proc object. if it is a method 
     96    # name that method will be called and if it is a proc it will be called 
     97    # with an argument of self where self is the current controller object. 
     98    # When you use a proc as a filter it needs to take one parameter. 
    10099    #  
    101100    # examples: 
    102     # before :some_filter 
    103     # before :authenticate, :exclude => [:login, :signup] 
    104     # before Proc.new {|c| c.some_method }, :only => :foo 
     101    #   before :some_filter 
     102    #   before :authenticate, :exclude => [:login, :signup] 
     103    #   before Proc.new {|c| c.some_method }, :only => :foo 
    105104    # 
    106105    # You can use either :only => :actionname or :exclude => [:this, :that] 
     
    108107    # and :exclude will run for every action that is not listed. 
    109108    # 
    110     # Merb's before filter chain is very flixible. To halt the  
    111     # filter chain you use throw :halt . If throw is called with 
    112     # only one argument of :halt the return of the method filters_halted  
    113     # will be what is rendered to the view. You can overide filters_halted 
    114     # in your own controllers to control what it outputs. But the throw 
    115     # construct is much more powerful then just that. throw :halt can 
    116     # also take a second argument. Here is what that second arg can be  
    117     # and the behavior each type can have: 
     109    # Merb's before filter chain is very flexible. To halt the filter chain you 
     110    # use throw :halt. If throw is called with only one argument of :halt the 
     111    # return of the method filters_halted will be what is rendered to the view. 
     112    # You can overide filters_halted in your own controllers to control what it 
     113    # outputs. But the throw construct is much more powerful then just that. 
     114    # throw :halt can also take a second argument. Here is what that second arg 
     115    # can be and the behavior each type can have: 
    118116    # 
    119     # when the second arg is a string then that string will be what 
    120     # is rendered to the browser. Since merb's render method returns 
    121     # a string you can render a template or just use a plain string: 
     117    # * String: 
     118    #   when the second arg is a string then that string will be what 
     119    #   is rendered to the browser. Since merb's render method returns 
     120    #   a string you can render a template or just use a plain string: 
    122121    # 
    123     # String: 
    124     # throw :halt, "You don't have permissions to do that!" 
    125     # throw :halt, render(:action => :access_denied) 
     122    #     throw :halt, "You don't have permissions to do that!" 
     123    #     throw :halt, render(:action => :access_denied) 
    126124    # 
    127     # if the second arg is a symbol then the method named after that 
    128     # symbol will be called 
    129     # Symbol:  
    130     # throw :halt, :must_click_disclaimer 
     125    # * Symbol: 
     126    #   If the second arg is a symbol then the method named after that 
     127    #   symbol will be called 
    131128    # 
    132     # If the second arg is a Proc, it will be called and its return 
    133     # value will be what is rendered to the browser: 
    134     # Proc: 
    135     # throw :halt, Proc.new {|c| c.access_denied } 
    136     # throw :halt, Proc.new {|c| Tidy.new(c.index) } 
     129    #   throw :halt, :must_click_disclaimer 
     130    # 
     131    # * Proc: 
     132    # 
     133    #   If the second arg is a Proc, it will be called and its return 
     134    #   value will be what is rendered to the browser: 
     135    # 
     136    #     throw :halt, Proc.new {|c| c.access_denied } 
     137    #     throw :halt, Proc.new {|c| Tidy.new(c.index) } 
    137138    #  
    138139    def self.before(filter, opts={}) 
     
    154155    end 
    155156     
    156     # #after is a class method that allows you to specify after 
    157     # filters in your controllers. Filters can either be a symbol 
    158     # or string that corresponds to a method name or a proc object. 
    159     # if it is a method name that method will be called and if it 
    160     # is a proc it will be called with an argument of self. When  
    161     # you use a proc as a filter it needs to take one parameter. 
    162     # you can gain access to the response body like so: 
    163     # after Proc.new {|c| Tidy.new(c.body) }, :only => :index 
    164     #  
     157    # #after is a class method that allows you to specify after filters in your 
     158    # controllers. Filters can either be a symbol or string that corresponds to 
     159    # a method name or a proc object. If it is a method name that method will 
     160    # be called and if it is a proc it will be called with an argument of self. 
     161    # When you use a proc as a filter it needs to take one parameter. You can 
     162    # gain access to the response body like so: after Proc.new {|c| 
     163    # Tidy.new(c.body) }, :only => :index 
    165164    def self.after(filter, opts={}) 
    166165      raise(ArgumentError, 
  • trunk/lib/merb/merb_controller.rb

    r348 r366  
    4444    end 
    4545 
    46     # parses the http request into params, headers and cookies 
    47     # that you can use in your controller classes. Also handles 
    48     # file uploads by writing a tempfile and passing a reference  
    49     # in params. 
     46    # Parses the http request into params, headers and cookies that you can use 
     47    # in your controller classes. Also handles file uploads by writing a 
     48    # tempfile and passing a reference in params. 
    5049    def parse_request(req, env, args, resp) 
    5150      env = env.to_hash 
     
    7473        @_cookies[_session_id_key] = @_params[_session_id_key] 
    7574      elsif @_params.key?(_session_id_key) && Merb::Server.config[:session_id_cookie_only] 
    76         #This conditions allows for certain controller/action paths to allow a session ID to be passed in a 
    77         #query string.  This is needed for Flash Uploads to work since flash will not pass a Session Cookie 
    78         #Recommend running session.regenerate after any controller taking advantage of this in case someone 
    79         #is attempting a session fixation attack 
     75        # This condition allows for certain controller/action paths to allow a 
     76        # session ID to be passed in a query string. This is needed for Flash 
     77        # Uploads to work since flash will not pass a Session Cookie Recommend 
     78        # running session.regenerate after any controller taking advantage of 
     79        # this in case someone is attempting a session fixation attack 
    8080        @_cookies[_session_id_key] = @_params[_session_id_key] if Merb::Server.config[:query_string_whitelist].include?("#{params[:controller]}/#{params[:action]}") 
    8181      end   
    8282       
    83       # Handle alternate HTTP method passed as _method parameter. 
    84       # Doesn't allow method to be overridden for :get 
    85       # unless Merb is in development mode. 
    86       # 
    87       # i.e. You can pass _method=put on the querystring if you are in 
     83      # Handle alternate HTTP method passed as _method parameter. Doesn't allow 
     84      # method to be overridden for :get unless Merb is in development mode. 
     85      #  
     86      #  i.e. You can pass _method=put on the querystring if you are in 
    8887      # development mode. 
    8988      allow = [:post, :put, :delete] 
     
    113112    end 
    114113       
    115     # accessor for @_body. Please use status and  
    116     # never @status directly. 
     114    # Accessor for @_body. Please use status and never @status directly. 
    117115    def body 
    118116       @_body   
    119117    end 
    120118     
    121     # accessor for @_status. Please use status and  
    122     # never @_status directly. 
     119    # Accessor for @_status. Please use status and never @_status directly. 
    123120    def status 
    124        @_status   
     121       @_status 
    125122    end 
    126            
    127     # accessor for @_request. Please use request and  
    128     # never @_request directly. 
     123     
     124    # Accessor for @_request. Please use request and never @_request directly. 
    129125    def request 
    130        @_request   
     126       @_request 
    131127    end 
    132              
    133     # accessor for @_params. Please use params and  
    134     # never @_params directly. 
     128     
     129    # Accessor for @_params. Please use params and never @_params directly. 
    135130    def params 
    136131      @_params 
    137     end   
     132    end 
    138133     
    139     # accessor for @_cookies. Please use cookies and  
    140     # never @_cookies directly.     
     134    # Accessor for @_cookies. Please use cookies and never @_cookies directly. 
    141135    def cookies 
    142136      @_cookies 
    143     end   
    144  
    145     # accessor for @_headers. Please use headers and  
    146     # never @_headers directly. 
     137    end 
     138     
     139    # Accessor for @_headers. Please use headers and never @_headers directly. 
    147140    def headers 
    148141      @_headers 
    149142    end 
    150143     
    151     # accessor for @_session. Please use session and  
    152     # never @_session directly.     
     144    # Accessor for @_session. Please use session and never @_session directly.     
    153145    def session 
    154146      @_session 
    155147    end 
    156148     
    157     # accessor for @_response. Please use response and  
    158     # never @_response directly. 
     149    # Accessor for @_response. Please use response and never @_response directly. 
    159150    def response 
    160151      @_response 
     
    162153     
    163154    # Sends a mail from a MailController 
    164     # 
    165     #  send_mail FooMailer, :bar, :from => "foo@bar.com", :to => "baz@bat.com" 
     155    #  
     156    #  send_mail FooMailer, :bar, :from => "foo@bar.com", :to => "baz@bat.com" 
    166157    #  
    167158    # would send an email via the FooMailer's bar method. 
    168     # 
    169     # mail_params, a hash, would be sent to the mailer, and includes items like from, to 
    170     # subject, and cc. See Merb::MailController#dispatch_and_deliver for more details. 
    171     # 
    172     # send_params, a hash, would be sent to the MailController, and is available to methods 
    173     # in the MailController as <tt>params</tt>. If you do not send any send_params, this 
    174     # controller's params will be available to the MailController as <tt>params</tt> 
     159    #  
     160    # The mail_params hash would be sent to the mailer, and includes items 
     161    # like from, to subject, and cc. See 
     162    # Merb::MailController#dispatch_and_deliver for more details. 
     163    #  
     164    # The send_params hash would be sent to the MailController, and is 
     165    # available to methods in the MailController as <tt>params</tt>. If you do 
     166    # not send any send_params, this controller's params will be available to 
     167    # the MailController as <tt>params</tt> 
    175168    def send_mail(klass, method, mail_params, send_params = nil) 
    176169      klass.new(send_params || params, self).dispatch_and_deliver(method, mail_params) 
     
    190183    # 
    191184    # class Foo < Application 
    192     #   def someaction 
     185    #   def some_action 
    193186    #     wrap_layout(part(TodoPart => :new) + part(TodoPart => :list)) 
    194187    #   end 
  • trunk/lib/merb/merb_dispatcher.rb

    r355 r366  
    1212      @@mutex = Mutex.new 
    1313      @@use_mutex = ::Merb::Server.use_mutex 
    14       # This is where we grab the incoming request REQUEST_URI 
    15       # and use that in the merb routematcher to determine 
    16       # which controller and method to run.  
    17       # returns a 2 element tuple of: 
    18       # [controller, action] 
     14      # This is where we grab the incoming request REQUEST_URI and use that in 
     15      # the merb RouteMatcher to determine which controller and method to run. 
     16      # Returns a 2 element tuple of: [controller, action] 
    1917      def handle(request, response) 
    2018        start = Time.now 
     
    5755      end 
    5856       
    59       # take a controller class name string and reload or require 
    60       # the right controller file then CamelCase it and return the 
    61       # class object 
     57      # Take a controller class name string and reload or require the right 
     58      # controller file then CamelCase it and return the class object. 
    6259      def resolve_controller(controller_name) 
    6360        segments = controller_name.split('/').map{|s| s.snake_case} 
  • trunk/lib/merb/merb_drb_server.rb

    r150 r366  
    1515    end 
    1616     
    17   end     
     17  end 
    1818   
    19    
    20 end   
     19end 
  • trunk/lib/merb/merb_exceptions.rb

    r309 r366  
    1515     
    1616  end 
    17   # format exception message for browser display   
     17   
     18  # Format exception message for browser display. 
    1819  def self.html_exception(e) 
    1920    if ::Merb::Server.show_error 
     
    6061    end 
    6162     
    62     # this method offers highlighting for the sourcecode-chunks from the 
    63     # traceback, just gem install coderay 
     63    # This method offers highlighting for the sourcecode-chunks from the 
     64    # traceback. Just 'gem install coderay'. 
    6465    def error_page(colors, title, *backtrace) 
    6566      @backtrace = backtrace 
  • trunk/lib/merb/merb_handler.rb

    r325 r366  
    1313  @@file_only_methods = ["GET","HEAD"] 
    1414   
    15   # take the name of a directory and use that as the doc root or public 
     15  # Take the name of a directory and use that as the doc root or public 
    1616  # directory of your site. This is set to the root of your merb app + '/public' 
    1717  # by default. 
     
    2121   
    2222  # process incoming http requests and do a number of things 
    23   # 1. check for rails style cached pages. add .html to the 
    24   # url and see if there is a static file in public that matches. 
    25   # serve that file directly without invoking Merb and be done with it. 
    26   # 2. Serve static asset and html files directly from public/ if 
    27   # they exist. 
    28   # 3. If none of the above apply, we take apart the request url 
    29   # and feed it into Merb::RouteMatcher to let it decide which  
    30   # controller and method will serve the request. 
    31   # 4. after the controller has done its thing, we check for the 
    32   # X-SENDFILE header. if you set this header to the path to a file 
    33   # in your controller then mongrel will serve the file directly 
    34   # and your controller can go on processing other requests. 
     23  # 1. Check for rails style cached pages. add .html to the url and see if 
     24  # there is a static file in public that matches. serve that file directly 
     25  # without invoking Merb and be done with it. 
     26  # 2. Serve static asset and html files directly from public/ if they exist. 
     27  # 3. If none of the above apply, we take apart the request url and feed it 
     28  # into Merb::RouteMatcher to let it decide which controller and method will 
     29  # serve the request. 
     30  # 4. After the controller has done its thing, we check for the X-SENDFILE 
     31  # header. if you set this header to the path to a file in your controller 
     32  # then mongrel will serve the file directly and your controller can go on 
     33  # processing other requests. 
    3534  def process(request, response) 
    3635     
     
    4443    MERB_LOGGER.info("\nRequest: REQUEST_URI: #{request.params[Mongrel::Const::REQUEST_URI]}  (#{Time.now.strftime("%Y-%m-%d %H:%M:%S")})") 
    4544     
    46     # Rails style page caching. Check the public dir first for 
    47     # .html pages and serve directly. Otherwise fall back to Merb  
    48     # routing and request dispatching.  
     45    # Rails style page caching. Check the public dir first for .html pages and 
     46    # serve directly. Otherwise fall back to Merb routing and request 
     47    # dispatching. 
    4948    path_info = request.params[Mongrel::Const::PATH_INFO] 
    5049    page_cached = path_info + ".html" 
     
    8281      sendfile, clength = nil 
    8382      response.status = controller.status 
    84       # check for the X-SENDFILE header from your Merb::Controller 
    85       # and serve the file directly instead of buffering. 
     83      # Check for the X-SENDFILE header from your Merb::Controller and serve 
     84      # the file directly instead of buffering. 
    8685      controller.headers.each do |k, v| 
    8786        if k =~ /^X-SENDFILE$/i 
     
    105104        # Calculated the same as apache, not sure how well the works on win32 
    106105        response.header[Mongrel::Const::ETAG] = Mongrel::Const::ETAG_FORMAT % [file_status.mtime.to_i, file_status.size, file_status.ino] 
    107         # send a status with out content length 
     106        # Send a status with out content length 
    108107        response.send_status(file_status.size) 
    109108        response.send_header 
     
    121120        controller.body.call 
    122121      else 
    123         # render response from successful controller 
     122        # Render response from successful controller 
    124123        body = (controller.body.to_s rescue '')  
    125124        response.send_status(body.length) 
  • trunk/lib/merb/merb_mail_controller.rb

    r289 r366  
    1111    attr_reader   :session, :base_controller 
    1212     
    13     # You can initialize a MailController with a series of parameters that can be used 
    14     # by methods in the class. You can also pass in a controller object, which will be 
    15     # available to the MailController methods as base_controller. 
     13    # You can initialize a MailController with a series of parameters that can 
     14    # be used by methods in the class. You can also pass in a controller 
     15    # object, which will be available to the MailController methods as 
     16    # base_controller. 
    1617    def initialize(params = {}, controller = nil) 
    1718      @params = params 
     
    2324    end 
    2425     
    25     # Allows you to render various types of things into the text and HTML parts of an email 
    26     # If you include just text, the email will be sent as plain-text. If you include HTML, 
    27     # the email will be sent as a multi-part email. 
    28     # 
    29     # There are a lot of ways to use render_mail, but it works similarly to the default 
    30     # Merb render method. 
    31     # 
    32     # First of all, you'll need to store email files in your dist/app/mailers/views directory. 
    33     # They should be under a directory that matches the name of your mailer (e.g. TestMailer's 
    34     # views would be stored under test_mailer). 
    35     # 
    36     # The files themselves should be named action_name.mime_type.extension. For example, a 
    37     # herb template that should be the HTML part of the email, and rendered from the "foo" 
    38     # action would be named foo.html.herb. 
    39     # 
    40     # The only mime-types currently supported are "html" and "text", which correspond to 
    41     # text/html and text/plain respectively. All template systems supported by your app are 
    42     # available to MailController, and the extensions are the same as they are throughout the 
    43     # rest of Merb. 
     26    # Allows you to render various types of things into the text and HTML parts 
     27    # of an email If you include just text, the email will be sent as 
     28    # plain-text. If you include HTML, the email will be sent as a multi-part 
     29    # email. 
     30    # 
     31    # There are a lot of ways to use render_mail, but it works similarly to the 
     32    # default Merb render method. 
     33    # 
     34    # First of all, you'll need to store email files in your 
     35    # dist/app/mailers/views directory. They should be under a directory that 
     36    # matches the name of your mailer (e.g. TestMailer's views would be stored 
     37    # under test_mailer). 
     38    # 
     39    # The files themselves should be named action_name.mime_type.extension. For 
     40    # example, a herb template that should be the HTML part of the email, and 
     41    # rendered from the "foo" action would be named foo.html.herb. 
     42    # 
     43    # The only mime-types currently supported are "html" and "text", which 
     44    # correspond to text/html and text/plain respectively. All template systems 
     45    # supported by your app are available to MailController, and the extensions 
     46    # are the same as they are throughout the rest of Merb. 
    4447    # 
    4548    # render_mail can take any of the following option patterns: 
     
    4750    #   render_mail 
    4851    # 
    49     # will attempt to render the current action. If the current action is "foo", this 
    50     # is identical to render_mail :foo 
     52    # will attempt to render the current action. If the current action is 
     53    # "foo", this is identical to render_mail :foo. 
    5154    # 
    5255    #   render_mail :foo 
     
    5659    #   render_mail :action => {:html => :foo, :text => :bar} 
    5760    # 
    58     # checks for foo.html.ext and bar.text.ext in the view directory of the current  
    59     # controller and adds them to the mail object if found 
     61    # checks for foo.html.ext and bar.text.ext in the view directory of the 
     62    # current controller and adds them to the mail object if found 
    6063    # 
    6164    #   render_mail :template => {:html => "foo/bar", :text => "foo/baz"} 
    6265    # 
    63     # checks for bar.html.ext and baz.text.ext in the foo directory and adds them 
    64     # to the mail object if found. 
     66    # checks for bar.html.ext and baz.text.ext in the foo directory and adds 
     67    # them to the mail object if found. 
    6568    # 
    6669    #   render_mail :html => :foo, :text => :bar 
     
    7073    #   render_mail :html => "FOO", :text => "BAR" 
    7174    # 
    72     # adds the text "FOO" as the html part of the email and the text "BAR" as the 
    73     # text part of the email. The difference between the last two examples is that 
    74     # symbols represent actions to render, while string represent the literal text 
    75     # to render. Note that you can use regular render methods instead 
    76     # of literal strings here, like: 
     75    # adds the text "FOO" as the html part of the email and the text "BAR" as 
     76    # the text part of the email. The difference between the last two examples 
     77    # is that symbols represent actions to render, while string represent the 
     78    # literal text to render. Note that you can use regular render methods 
     79    # instead of literal strings here, like: 
    7780    # 
    7881    #   render_mail :html => render(:action => :foo) 
    7982    # 
    80     # but you're probably better off just using render_mail :action at that point. 
     83    # but you're probably better off just using render_mail :action at that 
     84    # point. 
    8185    # 
    8286    # You can also mix and match: 
     
    121125    end 
    122126     
    123     # Attaches a file or multiple files to an email. You call this from a method in your MailController 
    124     # (including a before filter). 
    125     # 
     127    # Attaches a file or multiple files to an email. You call this from a 
     128    # method in your MailController (including a before filter). 
     129    #  
    126130    #   attach File.open("foo") 
    127131    #   attach [File.open("foo"), File.open("bar")] 
    128     # 
    129     # You can also include the filename, mime-type, or headers in the subsequent parameters. 
    130     # 
    131     # If you are passing an array of files, you should use an array of the allowed parameters: 
    132     # 
    133     #   attach [[File.open("foo"), "bar", "text/html"], [File.open("baz"), "bat", "text/css"] 
    134     # 
    135     # which would attach two files ("foo" and "baz" in the filesystem) as "bar" and "bat" respectively. 
    136     # It would also set the mime-type as "text/html" and "text/css" respectively. 
     132    #  
     133    # You can also include the filename, mime-type, or headers in the 
     134    # subsequent parameters. 
     135    #  
     136    # If you are passing an array of files, you should use an array of the 
     137    # allowed parameters: 
     138    #  
     139    #   attach [[File.open("foo"), "bar", "text/html"], [File.open("baz"), 
     140    # "bat", "text/css"] 
     141    #  
     142    #  which would attach two files ("foo" and "baz" in the filesystem) as 
     143    # "bar" and "bat" respectively. It would also set the mime-type as 
     144    # "text/html" and "text/css" respectively. 
    137145    def attach( file_or_files, filename = file_or_files.is_a?(File) ? File.basename(file_or_files.path) : nil,  
    138146      type = nil, headers = nil) 
     
    148156    #   subject 
    149157    #   body 
    150     #   replyto 
    151158    #   cc 
    152159    # 
    153     # other parameters passed in will be interpreted as email headers, with _'s converted 
     160    # Other parameters passed in will be interpreted as email headers, with _'s converted 
    154161    # to -'s. 
    155162    def dispatch_and_deliver(method, mail_params) 
  • trunk/lib/merb/merb_plugins.rb

    r286 r366  
    276276 
    277277module Gem 
    278   # Fixes a bug in RubyGems where the SilentProgressReporter class 
    279   # is inaccurately named SilentReporte
    280   # Maybe one day we'll monkeypatch this for our own purposes. 
     278  # Fixes a bug in RubyGems where the SilentProgressReporter class is 
     279  # inaccurately named SilentReporter. Maybe one day we'll monkeypatch this fo
     280  # our own purposes. 
    281281  class SilentProgressReporter 
    282282    attr_reader :count 
  • trunk/lib/merb/merb_router.rb

    r286 r366  
    8888      end 
    8989 
    90       # the final compiled lambda that gets used 
    91       # as the body of the route_request method. 
     90      # The final compiled lambda that gets used as the body of the 
     91      # route_request method. 
    9292      def compiled_statement 
    9393        @compiled_statement 
     
    9898      end 
    9999 
    100       # add a route to be compiled 
     100      # Add a route to be compiled. 
    101101      def add(*route) 
    102102        @routes << [route[0], (route[1] || {})] 
    103103      end 
    104104       
    105       # build up a string that defines a lambda 
    106       # that does a case statement on the PATH_INFO 
    107       # against each of the compiled routes in turn. 
    108       # first route that matches wins. 
     105      # Build up a string that defines a lambda that does a case statement on 
     106      # the PATH_INFO against each of the compiled routes in turn. First route 
     107      # that matches wins. 
    109108      def compile_router 
    110109        router_lambda = @routes.inject("lambda{|path| \n  sections={}\n  case path\n") { |m,r| 
     
    115114      end   
    116115       
    117       # compile each individual route into a when /.../ 
    118       # component of the case statement. Takes /:sections 
    119       # of the route def that start with : and turns them 
    120       # into placeholders for whatever urls match against 
    121       # the route in question. 
     116      # Compile each individual route into a when /.../ component of the case 
     117      # statement. Takes /:sections of the route def that start with : and 
     118      # turns them into placeholders for whatever urls match against the route 
     119      # in question. 
    122120      def compile(route) 
    123121        raise ArgumentError unless String === route[0] 
  • trunk/lib/merb/merb_server.rb

    r353 r366  
    3939        opts = OptionParser.new do |opts| 
    4040          opts.banner = "Usage: merb [fdcepghmisluMG] [argument]" 
    41           opts.define_head "Merb Mongrel+ Erb. Lightweight replacement for ActionPack
     41          opts.define_head "Merb Mongrel+ Erb. Lightweight replacement for ActionPack.
    4242          opts.separator '*'*80 
    43           opts.separator 'If no flags are given, Merb starts in the foreground on port 4000
     43          opts.separator 'If no flags are given, Merb starts in the foreground on port 4000.
    4444          opts.separator '*'*80 
    4545 
     
    5252          end 
    5353                     
    54           opts.on("-f", "--config-file FILENAME", "This flag is for adding extra config files for things like the upload progress module") do |config| 
     54          opts.on("-f", "--config-file FILENAME", "This flag is for adding extra config files for things like the upload progress module.") do |config| 
    5555            options[:config] = config 
    5656          end 
    5757           
    58           opts.on("-d", "--daemonize", "This will run a single merb in the background") do |config| 
     58          opts.on("-d", "--daemonize", "This will run a single merb in the background.") do |config| 
    5959            options[:daemonize] = true 
    6060          end 
    6161           
    62           opts.on("-c", "--cluster-nodes NUM_MERBS", "Number of merb daemons to run") do |nodes| 
     62          opts.on("-c", "--cluster-nodes NUM_MERBS", "Number of merb daemons to run.") do |nodes| 
    6363            options[:cluster] = nodes 
    6464          end 
    6565       
    66           opts.on("-p", "--port PORTNUM", "Port to run merb on, defaults to 4000") do |port| 
     66          opts.on("-p", "--port PORTNUM", "Port to run merb on, defaults to 4000.") do |port| 
    6767            options[:port] = port 
    6868          end 
    6969       
    70           opts.on("-h", "--host HOSTNAME", "Host to bind to(default is all IP's)") do |host| 
     70          opts.on("-h", "--host HOSTNAME", "Host to bind to (default is all IP's).") do |host| 
    7171            options[:host] = host 
    7272          end 
    7373       
    74           opts.on("-m", "--merb-root MERB_ROOT", "the path to the MERB_ROOT for the app you want to run") do |merb_root| 
     74          opts.on("-m", "--merb-root MERB_ROOT", "The path to the MERB_ROOT for the app you want to run (default is current working dir).") do |merb_root| 
    7575            options[:merb_root] = File.expand_path(merb_root) 
    7676          end 
     
    8080          end 
    8181           
    82           opts.on("-s", "--start-drb PORTNUM", "This is the port number to run the drb daemon on for sessions and uplod progress monitoring.") do |drb_port| 
     82          opts.on("-s", "--start-drb PORTNUM", "This is the port number to run the drb daemon on for sessions and upload progress monitoring.") do |drb_port| 
    8383            options[:start_drb] = true 
    8484            options[:only_drb] = true 
     
    9494          end 
    9595           
    96           opts.on("-r", "--script-runner ['RUBY CODE'| FULL_SCRIPT_PATH]", "Command-line option to run scripts and/or code in the merb app") do |stuff_to_run| 
     96          opts.on("-r", "--script-runner ['RUBY CODE'| FULL_SCRIPT_PATH]", "Command-line option to run scripts and/or code in the merb app.") do |stuff_to_run| 
    9797            options[:runner] = stuff_to_run 
    9898          end 
    9999           
    100           opts.on("-g", "--generate-app PATH", "Generate a fresh merb app at PATH") do |path| 
     100          opts.on("-g", "--generate-app PATH", "Generate a fresh merb app at PATH.") do |path| 
    101101            options[:generate] = path || Dir.pwd 
    102102          end 
    103103           
    104           opts.on("-P", "--plugin ACTION NAME", "Do ACTION with a plugin called NAME") do |action| 
     104          opts.on("-P", "--plugin ACTION NAME", "Do ACTION with a plugin called NAME.") do |action| 
    105105            options[:plugin] = [action, ARGV] || nil 
    106106          end 
    107107           
    108           opts.on("-k", "--kill PORT or all", "Kill one merb proceses by port number. use merb -k all to kill all merbs") do |ports| 
     108          opts.on("-k", "--kill PORT or all", "Kill one merb proceses by port number. use merb -k all to kill all merbs.") do |ports| 
    109109            options[:kill] = ports 
    110110          end 
    111111           
    112           opts.on("-M", "--merb-config FILENAME", "This flag is for explicitly declaring the merb app's config file") do |config| 
     112          opts.on("-M", "--merb-config FILENAME", "This flag is for explicitly declaring the merb app's config file.") do |config| 
    113113            options[:merb_config] = config 
    114114          end 
  • trunk/lib/merb/merb_view_context.rb

    r299 r366  
    2020  module GlobalHelper 
    2121  end     
    22   # the ViewContext is really 
    23   # just an empty container for us to fill with instance  
    24   # variables from the controller, include helpers into 
    25   # and then use as the context object passed to Erubis 
    26   # when evaluating the templates. 
     22  # The ViewContext is really just an empty container for us to fill with 
     23  # instance variables from the controller, include helpers into and then use as 
     24  # the context object passed to Erubis when evaluating the templates. 
    2725  class ViewContext 
    2826    include Merb::ViewContextMixin