sotayamashita/cal_exporter

View on GitHub
lib/cal_exporter.rb

Summary

Maintainability
A
0 mins
Test Coverage
require "cal_exporter/version"
require "icalendar"
require "open-uri"
require "thor"
require "date"


module CalExporter
  class CLI < Thor
    
    desc "calendar CALENDAR_ID FORMAT SAVE_LOCATION", "Export calendar with specified file format"
    def calendar(calendar_id, format, save_location)
      import = Importer.new(calendar_id)
      calendars = import.fetch
      export = Exporter.new(format, save_location)

      calendars.each do |calendar|
        calendar.events.each do |event|
          say export.save_as_jekyll(event)
        end
      end
      say "Successfully created Files under #{save_location}.",  :green
    end
  end

  require 'cal_exporter/importer'
  require 'cal_exporter/exporter'
  
end