Class: LighthouseIcal

Inherits:
Object
  • Object
show all
Defined in:
lib/lighthouse-ical.rb

Class Method Summary collapse

Class Method Details

.create_calendar_for_project_id(project_id) ⇒ Object

Returns an ics formatted string of all the milestones in the project



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/lighthouse-ical.rb', line 7

def self.create_calendar_for_project_id(project_id)
  project = Lighthouse::Project.find(project_id)
  calendar = Icalendar::Calendar.new
  milestones = scheduled_milestones_in_project(project_id)
  milestones.each do |ms|
    # Retrieve the due_on value for each milestone & stip the time component
    #Retrieve the title of the milestone & set it to the summary
    #Retrieve the goals of the milestone & set it to the description
    calendar.event do
      dtstart       ms.due_on.to_date
      dtend         ms.due_on.to_date
      summary     ms.title
      description ms.goals
    end
  end
  calendar.publish
  return calendar.to_ical
end

.create_ics_file_for_project_id(filepath, project_id) ⇒ Object

Generates an ics file at the specified filepath of available milestones for the selected project



27
28
29
30
31
# File 'lib/lighthouse-ical.rb', line 27

def self.create_ics_file_for_project_id(filepath,project_id)
  file = File.new(filepath,"w+")
  file.write(self.create_calendar_for_project_id(project_id))
  file.close
end