Atlrug intermodal - sep 2011

635 views

Published on

Presentation at the Atlanta Ruby User's Group, Sep 2011 for the Intermodal Gem (http://github.com/hosh/intermodal)

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
635
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide
  • Working with Rails since 2006Started in the days of Rails 1.0Seen a lot of innovations, out-innovating PHP, .NET and JavaBut now, Rails community stopped innovating.
  • Why did Rails stop innovating?Because we’re not looking outside of Rails.
  • Here’s the biggest change
  • -Big implications. -We’re all getting old-What do you see in your head when you see this word?
  • Monitor- Mouse- Keyboard
  • Macbook Air- Monitor Mouse Keyboard
  • Here’s the biggest change
  • - The kids growing up right now sees this word, they think of--
  • Smartphone
  • Tablet
  • Wallboard
  • - The kids growing up right now sees this word, they think of--
  • Laptop
  • - The kids growing up right now sees this word, they think of--
  • Mobile Web
  • - The kids growing up right now sees this word, they think of--
  • What glues all the clients together?
  • What glues all the clients together?
  • Write the API first.
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • What glues all the clients together?
  • That’s why it is called Open Source.Welcome users or contributors.
  • Working with Rails since 2006Started in the days of Rails 1.0Seen a lot of innovations, out-innovating PHP, .NET and JavaBut now, Rails community stopped innovating.
  • Atlrug intermodal - sep 2011

    1. 1. Intermodal<br />
    2. 2. Ho-Sheng Hsiao<br />Github: github.com/hosh<br />Twitter: hosheng<br />
    3. 3. Rails Stopped Innovating<br />
    4. 4. 500,000 Android Activated<br />per day<br />Source: bit.ly/500k-android-activtions<br />
    5. 5. Computer<br />
    6. 6.
    7. 7.
    8. 8. 500,000 Android Activated<br />per day<br />Source: bit.ly/500k-android-activtions<br />
    9. 9. Computer<br />
    10. 10.
    11. 11.
    12. 12.
    13. 13. Rails Stopped Innovating<br />
    14. 14. Web<br />
    15. 15.
    16. 16. Web<br />
    17. 17.
    18. 18. Platforms<br />iOS<br />Android<br />Blackberry<br />Windows 8<br />HP/Palm WebOS<br />
    19. 19. Cross Platform<br />jQuery Mobile<br />Sencha<br />Backbone.js<br />Spine.js<br />PhoneGap<br />Titanium<br />
    20. 20. Rails?<br />
    21. 21. API<br />
    22. 22. API=Machine Legibility<br />
    23. 23. Write the API First<br />
    24. 24. Write the API First<br />No Server-Side HTML<br />
    25. 25. Write the API First<br />No Templates<br />
    26. 26. Write the API First<br />Just Endpoints<br />
    27. 27. Write the API First<br />REST<br />
    28. 28. RESTful Endpoints<br />RESTful<br />CRUD<br />
    29. 29. RESTful Endpoints<br />Create<br />Read<br />Update<br />Delete<br /><ul><li> POST /posts.json
    30. 30. GET /posts/1.json
    31. 31. PUT /posts/1.json
    32. 32. DELETE /posts/1.json
    33. 33. GET /posts.json</li></li></ul><li>RESTful Endpoints<br />Create<br />Read<br />Update<br />Delete<br /><ul><li> POST /authors.json
    34. 34. GET /authors/1.json
    35. 35. PUT /authors/1.json
    36. 36. DELETE /authors/1.json
    37. 37. GET /authors.json</li></li></ul><li>See the pattern?<br />
    38. 38. resources :postsresources :authors<br />
    39. 39. <ul><li> POST /posts.json
    40. 40. GET /posts/1.json
    41. 41. PUT /posts/1.json
    42. 42. DELETE /posts/1.json
    43. 43. GET /posts.json</li></li></ul><li><ul><li> POST /authors.json
    44. 44. GET /authors/1.json
    45. 45. PUT /authors/1.json
    46. 46. DELETE /authors/1.json
    47. 47. GET /authors.json</li></li></ul><li>Intermodal<br />
    48. 48. Intermodal<br />DSL for API<br />
    49. 49. Intermodal<br />Not Scaffolding<br />
    50. 50. Intermodal<br />Three <br />Common Patterns<br />
    51. 51. Intermodal<br />Resources<br />
    52. 52. resources :posts<br />
    53. 53. <ul><li> POST /posts.json
    54. 54. GET /posts/1.json
    55. 55. PUT /posts/1.json
    56. 56. DELETE /posts/1.json
    57. 57. GET /posts.json</li></li></ul><li>Intermodal<br />Nested Resources<br />
    58. 58. # One-to-Many# Post has_many :comments# Comment belongs_to :postnested_resources:post, :comments<br />
    59. 59. <ul><li> POST /posts/1/comments.json
    60. 60. GET /posts/1/comments/1.json
    61. 61. PUT /posts/1/comments/1.json
    62. 62. DELETE /posts/1/comments/1.json
    63. 63. GET /posts/1/comments.json</li></li></ul><li>Intermodal<br />Linking Resources<br />
    64. 64. # Many-to-Many# Post has_many :authors # :through => :contributions# Author has_many :posts# :through => :contributionslink_resources_from:post, :to =>:authors<br />
    65. 65. <ul><li> POST /posts/1/authors.json
    66. 66. GET /posts/1/authors.json
    67. 67. PUT /posts/1/authors.json
    68. 68. DELETE /posts/1/authors.json</li></li></ul><li>Intermodal<br />Presenters<br />
    69. 69. presentation_for:postsdo presents :id presents :title presents :content presents :authors => ->(p) { p.authors.map(&:id) }end<br />
    70. 70. JSON<br />
    71. 71. { “post”: { “id”: 1, “title”: “Hello World”, “content”: “Best of Times, Worst of Times”, “authors”: [1,2,3] }}<br />
    72. 72. XML<br />
    73. 73. <post> <id>1</id> <title>1</title> <content>Best of Times, Worst of Times</content> <authors> <author>1</author> <author>2</author> <author>3</author> </authors></post><br />
    74. 74. Intermodal<br />Acceptors<br />
    75. 75. acceptance_for:postsdo accepts :title accepts :contentend<br />
    76. 76. acceptance_for:postsdo accepts :title accepts :contentend# Does not accept :id# Does not accept :authors<br />
    77. 77. acceptance_for:postsdo accepts :title accepts :contentend# Passes only :title and :content# from params to#Post#update_attributes<br />
    78. 78. Intermodal<br />Testing<br />
    79. 79. Intermodal<br />Test the API<br />Not the Controller<br />
    80. 80. Intermodal<br />Send <br />Rack Request<br />
    81. 81. <ul><li> POST /posts.json
    82. 82. GET /posts/1.json
    83. 83. PUT /posts/1.json
    84. 84. DELETE /posts/1.json
    85. 85. GET /posts.json</li></li></ul><li>Intermodal<br />ExpectRack Response<br />
    86. 86. <ul><li> POST /posts.json 201 Created
    87. 87. GET /posts/1.json 200 OK
    88. 88. PUT /posts/1.json 200 OK
    89. 89. DELETE /posts/1.json 200 OK
    90. 90. GET /posts.json 200 OK</li></li></ul><li><ul><li> POST /posts.json utf8 json
    91. 91. GET /posts/1.json utf8 json
    92. 92. PUT /posts/1.json utf8 json
    93. 93. DELETE /posts/1.json utf8 json
    94. 94. GET /posts.json utf8 json</li></li></ul><li><ul><li> POST /posts.json Create
    95. 95. GET /posts/1.json Read
    96. 96. PUT /posts/1.json Update
    97. 97. DELETE /posts/1.json Delete
    98. 98. GET /posts.json Index</li></li></ul><li>Intermodal<br />CRUD specs<br />
    99. 99. resources ’posts' dogiven_create_attributes:title => 'New Post', :account_id=> 1 given_update_attributes:name => 'Updated Post’expects_resource_crudend<br />
    100. 100. Intermodal<br />CRUD specs<br />for <br />Nested Resource<br />
    101. 101. resources [:posts, :comments] dogiven_create_attributes:title => 'New Comment', :account_id=> 1 given_update_attributes:name => 'Updated Comment’expects_resource_crudend<br />
    102. 102. Intermodal<br />CRUD specs<br />for <br />Linked Resource<br />
    103. 103. link_resource:post, :to => :authors, :with => Contributiondolet(:model_collection) do contributions post.authors.to_author_idsendlet(:unlinked_targets) { Author.make(3, :account => account) }expects_crud_for_linked_resourceend<br />
    104. 104. Caveats<br />
    105. 105. Extracted from Production<br />
    106. 106. Yes, but …<br />
    107. 107. Caveats<br />Installation sucks<br />No independent specs<br />Non-existent documentation<br />No Rails 3.1 support (yet)<br />No Ruby 1.9.2 support (yet)<br />
    108. 108. Rails Stopped Innovating?<br />
    109. 109. github.com/hosh/intermodal<br />Questions?<br />Ho-Sheng Hsiao<br />

    ×