SlideShare uma empresa Scribd logo
1 de 25
Baixar para ler offline
Merb
An Introduction
Who am I?
History
Key Focus
Fast
(No code is faster than no code)
Memory Efficient
Modular
(All you need none you don’t)
As Simple As Possible
Features
Plugins as Gems
Rack Integration
File upload example using rack middleware
uploader = Proc.new do |env|
 request = Merb::Request.new(env)
 if request.path =~ //images/upload/
   params = request.params
   FileUtils.mv params[:file][:tempfile].path,
       Merb.root / 'public' / 'uploads' / params[:file][:filename]

  headers = {quot;Content-Typequot;=>quot;text/htmlquot;,
          quot;Locationquot; => quot;/imagesquot;}
  [302, headers, quot;You are being redirectedquot;]
 else
  [404, {}, quot;No Upload here, move alongquot;]
 end
end

merb = Merb::Rack::Application.new

run Rack::Cascade.new([uploader, merb])
Router
Optional Path Segments
Matching
 match(quot;/articles(/:year(/:month(/:day)))/:titlequot;).
 to(:controller => quot;articlesquot;, :action => quot;showquot;).
 name(:article)

Generating
 /articles/Hello => { :title => “Hello” }
 /articles/2008/07/Hello
   => { :year => “2008”, :month => “07”, :title => “Hello” }
Access to Request &
               Params
     match(quot;/secretquot;).defer_to do |request, params|
      if request.session.authenticated?
        params
      end
     end

http://www.slideshare.net/carllerche/merb-pluming-the-router-presentation
Controllers
class Posts < Application
  provides :xml

 def show
  @post = Post.get(params[:id])
  display @post
 end
end
Background Processing
render_then_call do
  send_notification
end

run_later do
  send_notification
end
Exceptions
class Exceptions < Merb::Controller

 # handle NotFound exceptions (404)
 def not_found
  render :format => :html
 end

 # handle NotAcceptable exceptions (406)
 def not_acceptable
  render :format => :html
 end

end
Merb Slice
Application Server
merb -e produciton -d -c 4
Processes
• master
• spawner
• worker
Hot Deploy
kill HUP ‘master process id’
Questions?

Mais conteúdo relacionado

Mais procurados

Introduction to Fuel
Introduction to FuelIntroduction to Fuel
Introduction to Fuel
Phil Sturgeon
 
Introduction to Web Programming with Perl
Introduction to Web Programming with PerlIntroduction to Web Programming with Perl
Introduction to Web Programming with Perl
Dave Cross
 

Mais procurados (20)

Cucumber: How I Slice It
Cucumber: How I Slice ItCucumber: How I Slice It
Cucumber: How I Slice It
 
[WSO2Con EU 2017] An Overview of Ballerina Composer
[WSO2Con EU 2017] An Overview of Ballerina Composer[WSO2Con EU 2017] An Overview of Ballerina Composer
[WSO2Con EU 2017] An Overview of Ballerina Composer
 
BioMake PAG 2017
BioMake PAG 2017 BioMake PAG 2017
BioMake PAG 2017
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API'susing Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
 
Tutorial on joomla transfer moffatmn
Tutorial on joomla transfer moffatmnTutorial on joomla transfer moffatmn
Tutorial on joomla transfer moffatmn
 
Rack Middleware
Rack MiddlewareRack Middleware
Rack Middleware
 
jQuery Intro
jQuery IntrojQuery Intro
jQuery Intro
 
OpenERP and Perl
OpenERP and PerlOpenERP and Perl
OpenERP and Perl
 
Rails Engines as a way to Micro services
Rails Engines as a way to Micro servicesRails Engines as a way to Micro services
Rails Engines as a way to Micro services
 
RoR 101: Session 1
RoR 101: Session 1RoR 101: Session 1
RoR 101: Session 1
 
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job QueueTask Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
Task Scheduling and Asynchronous Processing Evolved. Zend Server Job Queue
 
Rack is Spectacular
Rack is SpectacularRack is Spectacular
Rack is Spectacular
 
Introduction to asp
Introduction to aspIntroduction to asp
Introduction to asp
 
Introduction to Fuel
Introduction to FuelIntroduction to Fuel
Introduction to Fuel
 
Introduction to Web Programming with Perl
Introduction to Web Programming with PerlIntroduction to Web Programming with Perl
Introduction to Web Programming with Perl
 
wp-n00b.php
wp-n00b.phpwp-n00b.php
wp-n00b.php
 
Module design pattern i.e. express js
Module design pattern i.e. express jsModule design pattern i.e. express js
Module design pattern i.e. express js
 
Understanding JSP -Servlets
Understanding JSP -ServletsUnderstanding JSP -Servlets
Understanding JSP -Servlets
 
Rack
RackRack
Rack
 
Ruby on Rails Meets Enterprise Applications
Ruby on Rails Meets Enterprise ApplicationsRuby on Rails Meets Enterprise Applications
Ruby on Rails Meets Enterprise Applications
 

Destaque

Destaque (17)

Action And Linking Verbs
Action And Linking VerbsAction And Linking Verbs
Action And Linking Verbs
 
191319
191319191319
191319
 
Nouns
NounsNouns
Nouns
 
Learning and Research - Junior Camp Internship Programme
Learning and Research - Junior Camp Internship ProgrammeLearning and Research - Junior Camp Internship Programme
Learning and Research - Junior Camp Internship Programme
 
Adjectives Vs
Adjectives VsAdjectives Vs
Adjectives Vs
 
Abortion
AbortionAbortion
Abortion
 
Homonyms
HomonymsHomonyms
Homonyms
 
Adjectives Vs Adverbs
Adjectives Vs AdverbsAdjectives Vs Adverbs
Adjectives Vs Adverbs
 
Linking Verbs
Linking VerbsLinking Verbs
Linking Verbs
 
Internet and Social Media: making the most of the global platform
Internet and Social Media: making the most of the global platformInternet and Social Media: making the most of the global platform
Internet and Social Media: making the most of the global platform
 
Dm Intro
Dm IntroDm Intro
Dm Intro
 
Prepositional Phrases
Prepositional PhrasesPrepositional Phrases
Prepositional Phrases
 
Overview of Woekpor Digital Literacy Initiative
Overview of Woekpor Digital Literacy InitiativeOverview of Woekpor Digital Literacy Initiative
Overview of Woekpor Digital Literacy Initiative
 
Job Applications
Job ApplicationsJob Applications
Job Applications
 
Introduction to Junior Camp Internship Programme
Introduction to Junior Camp Internship ProgrammeIntroduction to Junior Camp Internship Programme
Introduction to Junior Camp Internship Programme
 
Visual Rhetoric
Visual RhetoricVisual Rhetoric
Visual Rhetoric
 
Nouns
NounsNouns
Nouns
 

Semelhante a Merb

Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
funkatron
 
Integrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby AmfIntegrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby Amf
railsconf
 
En story of cakephp2.0
En story of cakephp2.0En story of cakephp2.0
En story of cakephp2.0
Hiroki Shimizu
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
patter
 

Semelhante a Merb (20)

And the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack SupportAnd the Greatest of These Is ... Rack Support
And the Greatest of These Is ... Rack Support
 
Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008
 
All I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web FrameworkAll I Need to Know I Learned by Writing My Own Web Framework
All I Need to Know I Learned by Writing My Own Web Framework
 
Service Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMixService Oriented Integration With ServiceMix
Service Oriented Integration With ServiceMix
 
SproutCore and the Future of Web Apps
SproutCore and the Future of Web AppsSproutCore and the Future of Web Apps
SproutCore and the Future of Web Apps
 
Damage Control
Damage ControlDamage Control
Damage Control
 
More Secrets of JavaScript Libraries
More Secrets of JavaScript LibrariesMore Secrets of JavaScript Libraries
More Secrets of JavaScript Libraries
 
Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!Rapid Prototyping FTW!!!
Rapid Prototyping FTW!!!
 
Intro To Mvc Development In Php
Intro To Mvc Development In PhpIntro To Mvc Development In Php
Intro To Mvc Development In Php
 
Integrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby AmfIntegrating Flex And Rails With Ruby Amf
Integrating Flex And Rails With Ruby Amf
 
Flex With Rubyamf
Flex With RubyamfFlex With Rubyamf
Flex With Rubyamf
 
Sinatra
SinatraSinatra
Sinatra
 
En story of cakephp2.0
En story of cakephp2.0En story of cakephp2.0
En story of cakephp2.0
 
Ruby Isn't Just About Rails
Ruby Isn't Just About RailsRuby Isn't Just About Rails
Ruby Isn't Just About Rails
 
Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!Apache and PHP: Why httpd.conf is your new BFF!
Apache and PHP: Why httpd.conf is your new BFF!
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
Jsf Ajax
Jsf AjaxJsf Ajax
Jsf Ajax
 
symfony on action - WebTech 207
symfony on action - WebTech 207symfony on action - WebTech 207
symfony on action - WebTech 207
 
Zend Con 2008 Slides
Zend Con 2008 SlidesZend Con 2008 Slides
Zend Con 2008 Slides
 
Express Presentation
Express PresentationExpress Presentation
Express Presentation
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 

Merb