Class: Taskwarrior::Calendar

Inherits:
Object
  • Object
show all
Includes:
Event, Timezone
Defined in:
lib/taskwarrior/calendar.rb,
lib/taskwarrior/calendar/app.rb,
lib/taskwarrior/calendar/event.rb,
lib/taskwarrior/calendar/version.rb,
lib/taskwarrior/calendar/app/base.rb,
lib/taskwarrior/calendar/timezone.rb,
lib/taskwarrior/calendar/app/convert.rb

Overview

Convert taskwarrior tasks to calendar events.

calendar = Taskwarrior::Calendar.new(filter: 'status:pending', alarm: false)
calendar.publish(filename: '~/tasks.ics')

Task due and optional scheduled dates if available are exported as calendar events.

By default tasks are filtered by status:pending and all events are appointed with an alarm 15 minutes before the event date. This can be configured with the filter and alarm options. For further filter details see taskwarrior.org/docs/filter. All events are exported in the timezone of the system. This can be configured with the TZ environment variable.

Defined Under Namespace

Modules: App, Event, Timezone

Constant Summary collapse

VERSION =
'1.0.2'

Instance Method Summary collapse

Methods included from Event

#add_event

Methods included from Timezone

#tz_info, #tz_name

Constructor Details

#initialize(filter: 'status:pending', alarm: true) ⇒ Calendar

Initialize a new taskwarrior calendar object. Tasks are filtered by status:pending and all calendar events are appointed with an alarm. This can be configured with the filter and alarm options.

On failure an error is raised.



38
39
40
41
# File 'lib/taskwarrior/calendar.rb', line 38

def initialize(filter: 'status:pending', alarm: true)
  tasks(filter:)
  calendar(alarm:)
end

Instance Method Details

#publish(filename: 'taskwarrior.ics') ⇒ Object

Publish calendar ICS to a file, default taskwarrior.ics. This can be configured with the filename option.



58
59
60
# File 'lib/taskwarrior/calendar.rb', line 58

def publish(filename: 'taskwarrior.ics')
  File.write(filename, to_ical)
end

#to_icalObject

Return the calendar as ICS string.



51
52
53
# File 'lib/taskwarrior/calendar.rb', line 51

def to_ical
  @calendar.to_ical
end

#to_objectObject

Return the Icalendar::Calendar object.



45
46
47
# File 'lib/taskwarrior/calendar.rb', line 45

def to_object
  @calendar
end