title: Merb - All You Need, None You Don't gradient: top-bottom black grey h1. Merb - All You Need, None You Don't (Adapted S9 Version from "Original PDF Slide Deck":http://brainspl.at/articles/2008/03/29/mountain-west-rubyconf-merb-slides by Ezra Zygmuntowicz, Engine Yard @ Mountain West RubyConf 2008) h1. Guiding Principles of Merb Development * Prefer simplicity over magic as much as possible * This is framework code, no @&:foo@ or returning allowed! * When in doubt... benchmark and profile * Know your runtime and how it acts h1. Merb’s Motto No code is faster than no code. h1. Why? Why Not? * Developer time is expensive... * Servers are cheap... h1. Who Cares About Efficiency Just throw more servers at the problem! Throwing more servers at the problem only goes so far ... Of course I’m happy to sell you more servers ;) h1. Who Cares About Efficiency Continued Premature Optimization is the root of blah blah blah... *Postmature Optimization* is the root of all hosting bills ;) h1. What’s New? * merb-core ** Rack Webserver Abstraction Layer ** Powerful Router ** Provides API * merb-more * merb-plugins h1. merb-core - Rack Webserver Abstraction Layer * Ebb * Evented Mongrel * FastCGI * Mongrel * Thin * Webrick @config/rack.rb@: {{{ class ApiHandler def initialize(app) @app = app end def call(env) request = Merb::Request.new(env) if request.path =~ %r{/api/(.*)} [200, {"Content-Type" => "text/json"}, Api.get_json($1)] else @app.call(env) end end end use ApiHandler run Merb::Rack::Application.new }}} h1. merb-core - Powerful Router {{{ Merb::Router.prepare do |r| r.resources :posts do |post| post.resources :comments end end }}} Named Routes: |Name|Route| |delete_post_comment| /posts/:post_id/comments/:id/delete | |post_comments | /posts/:post_id/comments | |new_post | /posts/new | |posts | /posts | |post_comments | /posts/:post_id/comments/:id | |edit_post | /posts/:id/edit | |post | /posts/:id | |new_post_comment | /posts/:post_id/comments/new | |delete_post | /posts/:id/delete | |edit_post_comment | /posts/:post_id/comments/:id/edit | h1. merb-core - Powerful Router Continued {{{ Merb::Router.prepare do |r| r.match(%r[^/foo/(.+)], :user_agent => /(MSIE|Gecko)/). to(:controller => 'foo', :title => '[1]', :action => 'show', :agent => ':user_agent[1]') r.match('/bar/:baz').defer_to do |request, params| if bar = Bar.find_by_baz params[:baz] {:controller => bar.controller, :action => bar.action, :bar => bar.to_param} end end end }}} h1. merb-core - Provides API {{{ Merb.add_mime_type(:yaml, :to_yaml, %w[application/x-yaml text/yaml]) Merb.add_mime_type(:html, :to_html, %w[text/html application/xhtml+xml application/html]) Merb.add_mime_type(:xml, :to_xml, %w[application/xml text/xml application/x-xml], :Encoding => 'UTF-8') Merb.add_mime_type(:json, :to_json, %w[application/json text/x-json]) }}} {{{ class Posts < Application provides :json, :yaml, :xml def show(id) @post = Post.find id display @post end end }}} h1. merb-more - What’s New? * Code Generators * Asset Bundling * Mailers and Parts * Haml and other templating support * Action Args * Caching * Other essentials h1. merb-plugins - What’s New? * merb_datamapper * merb_activerecord * merb_sequel * merb_helpers * merb_param_protection * many more to come h1. Contribute! * "github.com/wycats/merb-core/tree/master":http://github.com/wycats/merb-core/tree/master * "merb.lighthouseapp.com":http://merb.lighthouseapp.com * #merb irc.freenode.net * "groups.google.com/group/merb":http://groups.google.com/group/merb