Itch Scratching
 the ActionMailer
        API
A brief foray into the mind of a masochist!
whoami?
whoami?
Working in Rails & Ruby for 4+ Years
whoami?
Working in Rails & Ruby for 4+ Years

Maintainer of TMail & Author of Mail
whoami?
Working in Rails & Ruby for 4+ Years

Maintainer of TMail & Author of Mail

    DBA and Internet Plumber
whoami?
Working in Rails & Ruby for 4+ Years

Maintainer of TMail & Author of Mail

    DBA and Internet Plumber

        ...
whoami?
Working in Rails & Ruby for 4+ Years

Maintainer of TMail & Author of Mail

    DBA and Internet Plumber

        ...
y?
y?
Mail Application
y?
Mail Application

   Challenge
y?
Mail Application

   Challenge

     TMail
OMGLOLSPAM
OMGLOLSPAM
“TMail was a great SPAM checker...
if it crashed while parsing an email
  then you knew it was SPAM.”
         ...
Why not just fix TMail?
Why not just fix TMail?
 Released 10 patch and minor versions
Why not just fix TMail?
 Released 10 patch and minor versions

    I wrote over 600 lines of Docs
Why not just fix TMail?
 Released 10 patch and minor versions

    I wrote over 600 lines of Docs

      Built on a Strateg...
Why not just fix TMail?
 Released 10 patch and minor versions

    I wrote over 600 lines of Docs

      Built on a Strateg...
Why not just fix TMail?
 Released 10 patch and minor versions

    I wrote over 600 lines of Docs

      Built on a Strateg...
Why not just fix TMail?
Why not just fix TMail?
TMail was not very modular and hard to maintain
Why not just fix TMail?
TMail was not very modular and hard to maintain

        Wanted to write a major library
Why not just fix TMail?
TMail was not very modular and hard to maintain

        Wanted to write a major library

         ...
Why not just fix TMail?
TMail was not very modular and hard to maintain

        Wanted to write a major library

         ...
Why not just fix TMail?
TMail was not very modular and hard to maintain

        Wanted to write a major library

         ...
Mail’s DSL is Simple
Mail’s DSL is Simple
Mail’s DSL is Simple
Mail’s DSL is Simple
Mail’s DSL is Simple
Mail’s DSL is Simple
Mail’s DSL is Simple
Mail’s DSL is Simple
How Hard Could It Be?
How Hard Could It Be?
        Read RFCs
How Hard Could It Be?
        Read RFCs

      Read more RFCs
How Hard Could It Be?
         Read RFCs

      Read more RFCs

     Keep reading RFCs...
How Hard Could It Be?
                 Read RFCs

              Read more RFCs

            Keep reading RFCs...

“email i...
RFCs
RFCs
RSpec FTW!
RSpec FTW!
I use RSpec because I am lazy
RSpec FTW!
I use RSpec because I am lazy

EVERYTHING in Mail is BDD
RSpec FTW!
I use RSpec because I am lazy

EVERYTHING in Mail is BDD

    Regressions Caught
RSpec FTW!
I use RSpec because I am lazy

EVERYTHING in Mail is BDD

    Regressions Caught

          Seriously
Spec’ing for Libraries
Spec’ing for Libraries
       Start Simple
Spec’ing for Libraries
           Start Simple

  Comments in Spec Files are OK
Spec’ing for Libraries
           Start Simple

  Comments in Spec Files are OK

      Use Custom Matchers
Spec’ing for Libraries
           Start Simple

  Comments in Spec Files are OK

      Use Custom Matchers

   Break Down ...
Spec’ing for Libraries
           Start Simple

  Comments in Spec Files are OK

      Use Custom Matchers

   Break Down ...
Start Somewhere
Start Somewhere
Start Somewhere
Start Somewhere
Comments are OK
Comments are OK
Use Custom Matchers
       when appropriate
Use Custom Matchers
       when appropriate
Use Custom Matchers
       when appropriate
Use Custom Matchers
       when appropriate
Custom Matchers
Custom Matchers
Break Down Spec Files
Break Down Spec Files
Break Down Spec Files
          26 Sub Directories
Break Down Spec Files
          26 Sub Directories

          79 Ruby Spec Files
Break Down Spec Files
          26 Sub Directories

          79 Ruby Spec Files

          73 Edge Case Emails
Break Down Spec Files
          26 Sub Directories

          79 Ruby Spec Files

          73 Edge Case Emails

         ...
Break Down Spec Files
          26 Sub Directories

          79 Ruby Spec Files

          73 Edge Case Emails

         ...
Break Down Spec Files
          26 Sub Directories

          79 Ruby Spec Files

          73 Edge Case Emails

         ...
Spec in Multiple Rubies
Spec in Multiple Rubies
   Have to be a good Ruby Citizen
Spec in Multiple Rubies
   Have to be a good Ruby Citizen

               JRuby
Spec in Multiple Rubies
   Have to be a good Ruby Citizen

               JRuby

                REE
Spec in Multiple Rubies
   Have to be a good Ruby Citizen

               JRuby

                REE

              Rubini...
Spec in Multiple Rubies
   Have to be a good Ruby Citizen

                JRuby

                 REE

               Rub...
But What About Real Life?
But What About Real Life?
  Mail parses the Enron and Trec Data Sets
But What About Real Life?
  Mail parses the Enron and Trec Data Sets
              mikel@baci ~/Code
               $ du -...
But What About Real Life?
  Mail parses the Enron and Trec Data Sets
               mikel@baci ~/Code
                $ du...
show me the model!
show me the model!
Mail
show me the model!
Mail   Message
show me the model!
Mail   Message   Header
show me the model!
Mail   Message   Header




                 Body
show me the model!
show me the model!
Message   Body
show me the model!
Message            Body




          Header
show me the model!
Message            Body




          Header          FieldList
show me the model!
Message            Body




          Header          FieldList   Fields
show me the model!
Message            Body




          Header          FieldList                          Fields




   ...
show me the model!
Message            Body




          Header          FieldList                          Fields




   ...
show me the model!
show me the model!
Message   Header
show me the model!
Message          Header




          Body
show me the model!
Message          Header



                          Preamble



          Body
show me the model!
Message          Header



                          Preamble


                           One or
     ...
show me the model!
Message          Header



                          Preamble


                           One or
     ...
show me the model!
Message          Header



                          Preamble


                           One or
     ...
show me the model!
show me the model!
      And Thats It!
show me the model!
      And Thats It!

      Simple Hey?
show me the model!
   Header Errors                             Legacy Emails
      Parsers     rfc822      Delivery Agent...
OK, ActionMailer?
OK, ActionMailer?
   Much Easier to Use
OK, ActionMailer?
    Much Easier to Use

  Nicer Defaults & Config
OK, ActionMailer?
          Much Easier to Use

        Nicer Defaults & Config

ActionMailer Methods Return Mail Object
OK, ActionMailer?
          Much Easier to Use

        Nicer Defaults & Config

ActionMailer Methods Return Mail Object

 ...
OK, ActionMailer?
          Much Easier to Use

        Nicer Defaults & Config

ActionMailer Methods Return Mail Object

 ...
Much Easier to Use
Much Easier to Use
   New Mailer Directory
Much Easier to Use
        New Mailer Directory

Can Call “mail” method and pass a hash
Nicer Defaults
Nicer Defaults
Nicer Config
Nicer Config
AM Returns Mail
AM Returns Mail
AM Returns Mail
Mail Call Back Hooks
Mail Call Back Hooks
Mail Call Back Hooks
Mail Call Back Hooks
Mail Call Back Hooks
Mail Call Back Hooks
Deprecated API
   Decapitation Free Zone
Deprecated API
      Decapitation Free Zone



 Did not nuke the old API
Deprecated API
             Decapitation Free Zone



       Did not nuke the old API

New API triggers ONLY if you call “...
Deprecated API
             Decapitation Free Zone



       Did not nuke the old API

New API triggers ONLY if you call “...
Deprecated API
             Decapitation Free Zone



       Did not nuke the old API

New API triggers ONLY if you call “...
Deprecated API
   Decapitation Free Zone
Deprecated API
   Decapitation Free Zone
Deprecated API
   Decapitation Free Zone
HELP!!!
HELP!!!
Replace treetop with Ragel or RACC
HELP!!!
 Replace treetop with Ragel or RACC

Implement full POP3 and IMAP Support
HELP!!!
 Replace treetop with Ragel or RACC

Implement full POP3 and IMAP Support

     Domain Key Implementation
HELP!!!
 Replace treetop with Ragel or RACC

Implement full POP3 and IMAP Support

     Domain Key Implementation

       ...
HELP!!!
 Replace treetop with Ragel or RACC

Implement full POP3 and IMAP Support

     Domain Key Implementation

       ...
Tutorials
Tutorials
 lindsaar.net
Tutorials
     lindsaar.net

www.RailsDispatch.com
Tutorials
     lindsaar.net

www.RailsDispatch.com

 www.RailsCasts.com
KTHXBAI
  Questions?

   @raasdnil

mikel@rubyx.com

   lindsaar.net
Itch Scratching
Itch Scratching
Itch Scratching
Upcoming SlideShare
Loading in...5
×

Itch Scratching

1,435

Published on

Itch Scratching is the basis of all Open Source development. But how do you start? What is the process to get from having done NOTHING to releasing a massive and complete library?

This talk goes through the steps that I went through to develop the Ruby Mail Gem

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,435
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
17
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

  • No CS Experience

  • No CS Experience

  • No CS Experience

  • No CS Experience

  • No CS Experience








  • Read design patterns in Ruby

  • Read design patterns in Ruby

  • Read design patterns in Ruby

  • Read design patterns in Ruby

  • Read design patterns in Ruby





































































































































































  • Itch Scratching

    1. 1. Itch Scratching the ActionMailer API A brief foray into the mind of a masochist!
    2. 2. whoami?
    3. 3. whoami? Working in Rails & Ruby for 4+ Years
    4. 4. whoami? Working in Rails & Ruby for 4+ Years Maintainer of TMail & Author of Mail
    5. 5. whoami? Working in Rails & Ruby for 4+ Years Maintainer of TMail & Author of Mail DBA and Internet Plumber
    6. 6. whoami? Working in Rails & Ruby for 4+ Years Maintainer of TMail & Author of Mail DBA and Internet Plumber Rails Contributor
    7. 7. whoami? Working in Rails & Ruby for 4+ Years Maintainer of TMail & Author of Mail DBA and Internet Plumber Rails Contributor Entrepreneur
    8. 8. y?
    9. 9. y? Mail Application
    10. 10. y? Mail Application Challenge
    11. 11. y? Mail Application Challenge TMail
    12. 12. OMGLOLSPAM
    13. 13. OMGLOLSPAM “TMail was a great SPAM checker... if it crashed while parsing an email then you knew it was SPAM.” - Koz
    14. 14. Why not just fix TMail?
    15. 15. Why not just fix TMail? Released 10 patch and minor versions
    16. 16. Why not just fix TMail? Released 10 patch and minor versions I wrote over 600 lines of Docs
    17. 17. Why not just fix TMail? Released 10 patch and minor versions I wrote over 600 lines of Docs Built on a Strategy Pattern
    18. 18. Why not just fix TMail? Released 10 patch and minor versions I wrote over 600 lines of Docs Built on a Strategy Pattern Parser Written in C
    19. 19. Why not just fix TMail? Released 10 patch and minor versions I wrote over 600 lines of Docs Built on a Strategy Pattern Parser Written in C HARD TO FOLLOW
    20. 20. Why not just fix TMail?
    21. 21. Why not just fix TMail? TMail was not very modular and hard to maintain
    22. 22. Why not just fix TMail? TMail was not very modular and hard to maintain Wanted to write a major library
    23. 23. Why not just fix TMail? TMail was not very modular and hard to maintain Wanted to write a major library How hard could email be?
    24. 24. Why not just fix TMail? TMail was not very modular and hard to maintain Wanted to write a major library How hard could email be? I wanted a nice DSL
    25. 25. Why not just fix TMail? TMail was not very modular and hard to maintain Wanted to write a major library How hard could email be? I wanted a nice DSL Not as fun
    26. 26. Mail’s DSL is Simple
    27. 27. Mail’s DSL is Simple
    28. 28. Mail’s DSL is Simple
    29. 29. Mail’s DSL is Simple
    30. 30. Mail’s DSL is Simple
    31. 31. Mail’s DSL is Simple
    32. 32. Mail’s DSL is Simple
    33. 33. Mail’s DSL is Simple
    34. 34. How Hard Could It Be?
    35. 35. How Hard Could It Be? Read RFCs
    36. 36. How Hard Could It Be? Read RFCs Read more RFCs
    37. 37. How Hard Could It Be? Read RFCs Read more RFCs Keep reading RFCs...
    38. 38. How Hard Could It Be? Read RFCs Read more RFCs Keep reading RFCs... “email is defined in RFCs, so should be easy...”
    39. 39. RFCs
    40. 40. RFCs
    41. 41. RSpec FTW!
    42. 42. RSpec FTW! I use RSpec because I am lazy
    43. 43. RSpec FTW! I use RSpec because I am lazy EVERYTHING in Mail is BDD
    44. 44. RSpec FTW! I use RSpec because I am lazy EVERYTHING in Mail is BDD Regressions Caught
    45. 45. RSpec FTW! I use RSpec because I am lazy EVERYTHING in Mail is BDD Regressions Caught Seriously
    46. 46. Spec’ing for Libraries
    47. 47. Spec’ing for Libraries Start Simple
    48. 48. Spec’ing for Libraries Start Simple Comments in Spec Files are OK
    49. 49. Spec’ing for Libraries Start Simple Comments in Spec Files are OK Use Custom Matchers
    50. 50. Spec’ing for Libraries Start Simple Comments in Spec Files are OK Use Custom Matchers Break Down Your Spec Files
    51. 51. Spec’ing for Libraries Start Simple Comments in Spec Files are OK Use Custom Matchers Break Down Your Spec Files Spec in Multiple Rubies
    52. 52. Start Somewhere
    53. 53. Start Somewhere
    54. 54. Start Somewhere
    55. 55. Start Somewhere
    56. 56. Comments are OK
    57. 57. Comments are OK
    58. 58. Use Custom Matchers when appropriate
    59. 59. Use Custom Matchers when appropriate
    60. 60. Use Custom Matchers when appropriate
    61. 61. Use Custom Matchers when appropriate
    62. 62. Custom Matchers
    63. 63. Custom Matchers
    64. 64. Break Down Spec Files
    65. 65. Break Down Spec Files
    66. 66. Break Down Spec Files 26 Sub Directories
    67. 67. Break Down Spec Files 26 Sub Directories 79 Ruby Spec Files
    68. 68. Break Down Spec Files 26 Sub Directories 79 Ruby Spec Files 73 Edge Case Emails
    69. 69. Break Down Spec Files 26 Sub Directories 79 Ruby Spec Files 73 Edge Case Emails Many Many Lines of Specs
    70. 70. Break Down Spec Files 26 Sub Directories 79 Ruby Spec Files 73 Edge Case Emails Many Many Lines of Specs 1161 examples
    71. 71. Break Down Spec Files 26 Sub Directories 79 Ruby Spec Files 73 Edge Case Emails Many Many Lines of Specs 1161 examples No Failures :)
    72. 72. Spec in Multiple Rubies
    73. 73. Spec in Multiple Rubies Have to be a good Ruby Citizen
    74. 74. Spec in Multiple Rubies Have to be a good Ruby Citizen JRuby
    75. 75. Spec in Multiple Rubies Have to be a good Ruby Citizen JRuby REE
    76. 76. Spec in Multiple Rubies Have to be a good Ruby Citizen JRuby REE Rubinius (almost)
    77. 77. Spec in Multiple Rubies Have to be a good Ruby Citizen JRuby REE Rubinius (almost) MRI - 1.8.6, 1.8.7, 1.9.1, 1.9.2
    78. 78. But What About Real Life?
    79. 79. But What About Real Life? Mail parses the Enron and Trec Data Sets
    80. 80. But What About Real Life? Mail parses the Enron and Trec Data Sets mikel@baci ~/Code $ du -hs corpus/ 2.4G of Emails
    81. 81. But What About Real Life? Mail parses the Enron and Trec Data Sets mikel@baci ~/Code $ du -hs corpus/ 2.4G of Emails mikel@baci ~/Code $ find corpus -name "*" -print | wc -l 328,248 Emails
    82. 82. show me the model!
    83. 83. show me the model! Mail
    84. 84. show me the model! Mail Message
    85. 85. show me the model! Mail Message Header
    86. 86. show me the model! Mail Message Header Body
    87. 87. show me the model!
    88. 88. show me the model! Message Body
    89. 89. show me the model! Message Body Header
    90. 90. show me the model! Message Body Header FieldList
    91. 91. show me the model! Message Body Header FieldList Fields
    92. 92. show me the model! Message Body Header FieldList Fields StructuredField Content-Type Content-Transfer-Encoding To, From, Cc, Bcc, Reply-To
    93. 93. show me the model! Message Body Header FieldList Fields StructuredField UnstructuredField Content-Type Subject Content-Transfer-Encoding X-Headers et al To, From, Cc, Bcc, Reply-To Any other unparsable field
    94. 94. show me the model!
    95. 95. show me the model! Message Header
    96. 96. show me the model! Message Header Body
    97. 97. show me the model! Message Header Preamble Body
    98. 98. show me the model! Message Header Preamble One or Body Many Parts
    99. 99. show me the model! Message Header Preamble One or Body Many Parts Epilogue
    100. 100. show me the model! Message Header Preamble One or Body Message Many Parts Ohhh... O.O. Recursive Epilogue Type Stuff
    101. 101. show me the model!
    102. 102. show me the model! And Thats It!
    103. 103. show me the model! And Thats It! Simple Hey?
    104. 104. show me the model! Header Errors Legacy Emails Parsers rfc822 Delivery Agents And Thats It! SMTP Body Decoding SPAM PGP Signing POP3 File Types Mbox Simple Hey? Network IMAP Language Support Sendmail Delivery Bad Emails Encoding Edge Cases Pattern Matching OMGMIME! Decoding Attachments Interceptors File IO Domain Key Emails Observers Status Reports Inline Attachments
    105. 105. OK, ActionMailer?
    106. 106. OK, ActionMailer? Much Easier to Use
    107. 107. OK, ActionMailer? Much Easier to Use Nicer Defaults & Config
    108. 108. OK, ActionMailer? Much Easier to Use Nicer Defaults & Config ActionMailer Methods Return Mail Object
    109. 109. OK, ActionMailer? Much Easier to Use Nicer Defaults & Config ActionMailer Methods Return Mail Object Deprecated (not Decapitated) API
    110. 110. OK, ActionMailer? Much Easier to Use Nicer Defaults & Config ActionMailer Methods Return Mail Object Deprecated (not Decapitated) API Tutorials
    111. 111. Much Easier to Use
    112. 112. Much Easier to Use New Mailer Directory
    113. 113. Much Easier to Use New Mailer Directory Can Call “mail” method and pass a hash
    114. 114. Nicer Defaults
    115. 115. Nicer Defaults
    116. 116. Nicer Config
    117. 117. Nicer Config
    118. 118. AM Returns Mail
    119. 119. AM Returns Mail
    120. 120. AM Returns Mail
    121. 121. Mail Call Back Hooks
    122. 122. Mail Call Back Hooks
    123. 123. Mail Call Back Hooks
    124. 124. Mail Call Back Hooks
    125. 125. Mail Call Back Hooks
    126. 126. Mail Call Back Hooks
    127. 127. Deprecated API Decapitation Free Zone
    128. 128. Deprecated API Decapitation Free Zone Did not nuke the old API
    129. 129. Deprecated API Decapitation Free Zone Did not nuke the old API New API triggers ONLY if you call “mail”
    130. 130. Deprecated API Decapitation Free Zone Did not nuke the old API New API triggers ONLY if you call “mail” Old API in place if no “mail” call
    131. 131. Deprecated API Decapitation Free Zone Did not nuke the old API New API triggers ONLY if you call “mail” Old API in place if no “mail” call Will be Removed in 3.1
    132. 132. Deprecated API Decapitation Free Zone
    133. 133. Deprecated API Decapitation Free Zone
    134. 134. Deprecated API Decapitation Free Zone
    135. 135. HELP!!!
    136. 136. HELP!!! Replace treetop with Ragel or RACC
    137. 137. HELP!!! Replace treetop with Ragel or RACC Implement full POP3 and IMAP Support
    138. 138. HELP!!! Replace treetop with Ragel or RACC Implement full POP3 and IMAP Support Domain Key Implementation
    139. 139. HELP!!! Replace treetop with Ragel or RACC Implement full POP3 and IMAP Support Domain Key Implementation PGP Signing
    140. 140. HELP!!! Replace treetop with Ragel or RACC Implement full POP3 and IMAP Support Domain Key Implementation PGP Signing More Documentation
    141. 141. Tutorials
    142. 142. Tutorials lindsaar.net
    143. 143. Tutorials lindsaar.net www.RailsDispatch.com
    144. 144. Tutorials lindsaar.net www.RailsDispatch.com www.RailsCasts.com
    145. 145. KTHXBAI Questions? @raasdnil mikel@rubyx.com lindsaar.net
    1. A particular slide catching your eye?

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

    ×