hi
Expanding
Our Vision With

MERB
Advanced

MERB
Advanced

MERB
Adventurous

MERB
INTRODUCTION
Matt Todd
mtodd
 http://github.com/mtodd/


     Halcyon
  Highgroove
    Studios
Developer & OSS Architect
  http://highgroove.com
SWEET
NECTAR
OF THE
GODS
EXPECTATIONS
I AM NOT
AN EXPERT
WARNING
 code for:
PROBLEMS
& examples
lack of
imagination
The
Foreground
“forefront, prominent
or important position”
meh
not as interesting
as the background
:o
The
Background
DBs
Caches
Background Processes
Web Services
Embedded Components
Distributed Grid/Mesh Apps
AJAX
Rack
DBs x
Caches x
Background Processes √
Web Services √
Embedded Components √
Distributed Grid/Mesh Apps √
AJAX x
Rack √
Background
 Processes
rake tasks
namespace(:nodes) do

desc quot;Purge inactive nodes.quot;
task :purge => [:merb_env] do
 Node.inactive.purge
end

desc qu...
render_then_call
run_later
render_then_call do
 Node.inactive.purge
end

### OR

run_later do
 Node.scan(Node.first)
end
render
we’ll talk later
Web
Services
“software system designed
  to support interoperable
    machine-to-machine
interaction over a network”
a service
over the web
just for apps
JSON is
REALLY
Awesome
JSON is
FUCKING
Awesome
{“foo”:“bar”}
RESTful
GET      /objects.json     index
PUT      /objects.json     create
GET      /objects/1.json   show
DELETE   /objects/1.jso...
Merb’s Way
provides
render
display
provides
class Posts < Application
1.    provides :json
      def show
       @post = Post.get(params[:id])
       display @post
  ...
NO BITCH!


  GIMME XML!
GET /posts/1.xml
406 Not Acceptable
display
class Posts < Application
1.    provides :json
      def show
       @post = Post.get(params[:id])
2.     display @post
  ...
respond_to do |format|
 format.html { render }
 format.json { @post.to_json }
end
                                 Rails
 ...
even better:
renders XML, JSON, and HTML
  provides :json, :xml
  @post = Post.get(params[:id])
  display @post

 AUTOMATICALLY
       ...
Embedded
Components
<script type=“text/javascript”
src=“/comments.js”></script>
document.write(
 ‘<div id=“comments”></div>’
);

$(function(){
 <% @comments.each do |c|
  c = $(“<p><%=c.body%></p>”);
  ...
github.com/
mtodd/aceldama
glorified JS
  & AJAX
Distributed
Grid/Mesh
   Apps
Centralized
        S

S                S
        M


    S        S
Distributed
        N

N               N


    N       N
{
S

M
    slave
    master
N   node
Foreground


                       `

                            /sites


N
[{id:1,                      [{id:1,
url:“ht...
github.com/
mtodd/conley
Rack
AWESOME
Framework’s
 Framework
Request     Merb

          Middleware

            Rack

                       Response
           Mongrel
mongrel
thin
ebb
webrick
etc
class YourApp
 def call(env)
  [
    200,
    {‘Content-Type’=>‘text/plain’},
    “OK”
  ]
 end
end
Middleware
mini apps
modifies env
avoid passing
through
class RackMiddlewareExample
 def initialize(app)
  @app = app
 end
 def call(env)
  # voodoo
  @app.call(env)
 end
end
gist.github.com/
  16369
Fin.
HAHA
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Adventurous Merb
Upcoming SlideShare
Loading in...5
×

Adventurous Merb

2,446

Published on

My talk at MerbCamp in San Diego. I'll apologize up front. ;)

Published in: Technology
6 Comments
4 Likes
Statistics
Notes
No Downloads
Views
Total Views
2,446
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
53
Comments
6
Likes
4
Embeds 0
No embeds

No notes for slide

Adventurous Merb

  1. 1. hi
  2. 2. Expanding Our Vision With MERB
  3. 3. Advanced MERB
  4. 4. Advanced MERB
  5. 5. Adventurous MERB
  6. 6. INTRODUCTION
  7. 7. Matt Todd
  8. 8. mtodd http://github.com/mtodd/ Halcyon Highgroove Studios Developer & OSS Architect http://highgroove.com
  9. 9. SWEET NECTAR OF THE GODS
  10. 10. EXPECTATIONS
  11. 11. I AM NOT AN EXPERT
  12. 12. WARNING code for: PROBLEMS & examples
  13. 13. lack of imagination
  14. 14. The Foreground
  15. 15. “forefront, prominent or important position”
  16. 16. meh
  17. 17. not as interesting as the background
  18. 18. :o
  19. 19. The Background
  20. 20. DBs Caches Background Processes Web Services Embedded Components Distributed Grid/Mesh Apps AJAX Rack
  21. 21. DBs x Caches x Background Processes √ Web Services √ Embedded Components √ Distributed Grid/Mesh Apps √ AJAX x Rack √
  22. 22. Background Processes
  23. 23. rake tasks
  24. 24. namespace(:nodes) do desc quot;Purge inactive nodes.quot; task :purge => [:merb_env] do Node.inactive.purge end desc quot;Scan for nodesquot; task :scan => [:merb_env] do Node.detach_and_scan(Node.first) end end
  25. 25. render_then_call run_later
  26. 26. render_then_call do Node.inactive.purge end ### OR run_later do Node.scan(Node.first) end render
  27. 27. we’ll talk later
  28. 28. Web Services
  29. 29. “software system designed to support interoperable machine-to-machine interaction over a network”
  30. 30. a service over the web just for apps
  31. 31. JSON is REALLY Awesome
  32. 32. JSON is FUCKING Awesome
  33. 33. {“foo”:“bar”}
  34. 34. RESTful
  35. 35. GET /objects.json index PUT /objects.json create GET /objects/1.json show DELETE /objects/1.json delete POST /objects/1.json update
  36. 36. Merb’s Way
  37. 37. provides render display
  38. 38. provides
  39. 39. class Posts < Application 1. provides :json def show @post = Post.get(params[:id]) display @post end end
  40. 40. NO BITCH! GIMME XML!
  41. 41. GET /posts/1.xml 406 Not Acceptable
  42. 42. display
  43. 43. class Posts < Application 1. provides :json def show @post = Post.get(params[:id]) 2. display @post end end
  44. 44. respond_to do |format| format.html { render } format.json { @post.to_json } end Rails vs case content_type Merb when :html render when :json display @post end
  45. 45. even better:
  46. 46. renders XML, JSON, and HTML provides :json, :xml @post = Post.get(params[:id]) display @post AUTOMATICALLY fuck yeah!
  47. 47. Embedded Components
  48. 48. <script type=“text/javascript” src=“/comments.js”></script>
  49. 49. document.write( ‘<div id=“comments”></div>’ ); $(function(){ <% @comments.each do |c| c = $(“<p><%=c.body%></p>”); c.attr(‘id’,“comment-<%=c.id%>”); c.appendTo(‘#comments’); <% end %> });
  50. 50. github.com/ mtodd/aceldama
  51. 51. glorified JS & AJAX
  52. 52. Distributed Grid/Mesh Apps
  53. 53. Centralized S S S M S S
  54. 54. Distributed N N N N N
  55. 55. { S M slave master N node
  56. 56. Foreground ` /sites N [{id:1, [{id:1, url:“http://github.com/”, rating:1, created_at:...},...] created_at:...},...] /sites.json /sites/n/reports.json Background
  57. 57. github.com/ mtodd/conley
  58. 58. Rack
  59. 59. AWESOME
  60. 60. Framework’s Framework
  61. 61. Request Merb Middleware Rack Response Mongrel
  62. 62. mongrel thin ebb webrick etc
  63. 63. class YourApp def call(env) [ 200, {‘Content-Type’=>‘text/plain’}, “OK” ] end end
  64. 64. Middleware
  65. 65. mini apps modifies env avoid passing through
  66. 66. class RackMiddlewareExample def initialize(app) @app = app end def call(env) # voodoo @app.call(env) end end
  67. 67. gist.github.com/ 16369
  68. 68. Fin.
  69. 69. HAHA
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×