Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved contact string generation into events.

  • Loading branch information...
commit ce5edb5a3064e808e3222493ad3e2f57266755ff 1 parent 6f880ea
Huw Giddens authored
View
11 src/support_calendar/events.clj
@@ -1,4 +1,5 @@
-(ns support-calendar.events)
+(ns support-calendar.events
+ (:use [clojure.string :only [join]]))
(defn merge-events [[last-event & rest :as all] event]
(if (= (:start event) (:end last-event))
@@ -12,3 +13,11 @@
(mapcat (fn [[_ grouped-events]]
(reverse (reduce merge-events (take 1 grouped-events) (rest grouped-events))))
grouped)))
+
+(defn contact-details-string [event]
+ (let [{:keys [extension phone]} (:person event)]
+ (with-out-str
+ (when extension
+ (println "Extension:" extension))
+ (when phone
+ (println "Phone:" (join ", " phone))))))
View
10 src/support_calendar/generator.clj
@@ -3,7 +3,7 @@
[net.fortuna.ical4j.model.component VEvent]
[net.fortuna.ical4j.model.property CalScale Description ProdId Version]
[net.fortuna.ical4j.util UidGenerator])
- (use [clojure.string :only [join]]))
+ (require [support-calendar.events :as ev]))
(defn to-date [calendar]
(new Date (.getTime calendar)))
@@ -15,14 +15,10 @@
(.add (new ProdId "-//NZRB//support-calendar//EN"))
(.add Version/VERSION_2_0)
(.add CalScale/GREGORIAN))
- (doseq [{:keys [person system start end]} events]
+ (doseq [{:keys [person system start end] :as event-map} events]
(let [event (new VEvent (to-date start) (to-date end) (str system " support: " (:name person)))]
(doto (.getProperties event)
(.add (.generateUid generator))
- (.add (new Description (with-out-str
- (when-let [extension (:extension person)]
- (println "Extension:" extension))
- (when-let [phones (:phone person)]
- (println "Phone:" (join ", " phones)))))))
+ (.add (new Description (ev/contact-details-string event-map))))
(.add (.getComponents calendar) event)))
calendar))
Please sign in to comment.
Something went wrong with that request. Please try again.