Class: Markdo::IcsCommand
Defined Under Namespace
Classes: Event
Instance Method Summary collapse
Methods inherited from Command
Constructor Details
This class inherits a constructor from Markdo::Command
Instance Method Details
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/markdo/ics_command.rb', line 7 def run events = Dir. glob(markdown_glob). map { |path| File.readlines(path, encoding: 'UTF-8') }. flatten. grep(date_regexp). reject { |line| line.match(/[-*] \[x\]/) }. map { |line| begin raw_due_date = line.match(date_regexp) due_date = Date.parse(raw_due_date[0]) Event.new(due_date, due_date, clean(line)) rescue ArgumentError # invalid date, skip it end }.compact ics = template(events) @stdout.puts(ics) end |