Recurring Events with Montrose

Recurring Events with Montrose

Introduction to the Montrose gem for modeling recurring events in Ruby. Learn more: http://bit.ly/1U3RDA7

B0169a78f851962058d63337ad0147d6?s=128

Ross Kaffenberger

February 09, 2016
Tweet

Transcript

  1. RECURRING EVENTS NYC.rb, every month, 2nd Tuesday, at 7pm Ross

    Kaffenberger with Montrose
  2. @rossta 2

  3. 3

  4. WEPLAY 2008

  5. WEPLAY 2008

  6. ESTIMATE 4 days

  7. ACTUAL 4 WEEKS

  8. HARD PROBLEMS

  9. CHALLENGE MODELING RECURRENCE “every Friday 13th, forever” # in Ruby

  10. CHALLENGE MODELING RECURRENCE * ice_cube * recurrence * runt something_better???

  11. # enumerable, e.g. r.each do |time| puts time end WISH

    LIST
  12. # queryable, e.g. r.include?(time) r.events r.until(time) WISH LIST

  13. # serializable, e.g. r.to_json r.to_yml r.to_ical WISH LIST

  14. # easy-to-use # ??? WISH LIST

  15. API-DRIVEN

  16. INSPIRATION rfc5545 - iCAl Spec Every Friday the 13th, forever:

    RRULE:FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13
  17. INSPIRATION DATA STRUCTURE { every: :month, on: { friday: 13

    } }
  18. INSPIRATION HTTP.rb “easy-to-use client library for making requests from Ruby.

    It uses a simple method chaining system…”
  19. INTRODUCING MONTROSE “easy-to-use library for DEFINING RECURRING EVENTS IN Ruby.

    It uses a simple method chaining system…” gem install montrose
  20. Montrose.minutely Montrose.daily Montrose.monthly # etc. MONTROSE EXAMPLES github.com/rossta/montrose

  21. Montrose.weekly(on: :monday, at: "10:30 am") => #<Montrose::Recurrence...> MONTROSE EXAMPLES github.com/rossta/montrose

  22. Montrose.monthly. starting(1.year.from_now). on(friday: 13). repeat(5) MONTROSE CHAINABLE github.com/rossta/montrose

  23. # Every 3 hours Montrose.hourly.interval(3) Montrose.every(3.hours) Montrose.r(every: 3.hours) Montrose.recurrence(every: :hour,

    interval: 3) MONTROSE FLEXIBLE github.com/rossta/montrose
  24. r = Montrose.monthly.repeat(3) r.map(&:to_date) => [Tue, 09 Feb 2016, Wed,

    09 Mar 2016, ...] MONTROSE ENUMERABLE github.com/rossta/montrose
  25. r1 = Montrose.every(:week) r2 = Montrose.on(:tuesday, :thursday) r3 = Montrose.at("12

    pm") r1.merge(r2).merge(r3).take(4).to_a => [2016-02-09 12:00:00 -0500, 2016-02-11 12:00:00 -0500, ...] MONTROSE COMPOSABLE github.com/rossta/montrose
  26. class EventSeries < ActiveRecord::Base serialize :recurrence, Montrose::Recurrence end MONTROSE SERIALIZABLE

    github.com/rossta/montrose
  27. MONTROSE NYC.RB Montrose.monthly. day(tuesday: [2]). at("7pm") github.com/rossta/montrose

  28. NEXT STEPS github.com/rossta/montrose

  29. rossta/montrose @rossta http://empex.co Empire City Elixir Conf rossta.net