-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
37 lines (31 loc) · 1.02 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
POST_PATH = "_posts/"
desc "Create a new post for the first Thursday of next month"
task :post do
t = Time.now
next_event = first_thursday_of_next_month(t)
filename = t.strftime("%Y-%m-%d-") + next_event.strftime("%B") + ".md"
data = ""
data << "---\n"
data << "layout: firehouse\n"
data << "title: " + next_event.strftime("%B %Y") + " Silisec\n"
data << "event-summary: Silisec\n"
data << "event-timezone: America/Los_Angeles\n"
data << "event-start: " + next_event.strftime("%Y%m%d") + "T190000\n"
data << "event-end: " + next_event.strftime("%Y%m%d") + "T230000\n"
data << "event-location: Firehouse Brewing Company\n"
data << "---\n"
data << "\n"
data << "# " + next_event.strftime("%B %-d, %Y")
data << "\n\n"
data << "Silisec will be at Firehouse Brewery and starts at 7pm."
data << "\n"
File.open(POST_PATH + filename, 'w') {|f| f.write(data) }
end
task :default => :post
def first_thursday_of_next_month(t)
if t.day < 8 and t.wday == 4
t
else
first_thursday_of_next_month(t + (60 * 60 * 24))
end
end