Skip to content

Instantly share code, notes, and snippets.

@jewel12
Created December 4, 2012 17:07
Show Gist options
  • Save jewel12/4206305 to your computer and use it in GitHub Desktop.
Save jewel12/4206305 to your computer and use it in GitHub Desktop.
Thingsのプロジェクト期限をGoogleカレンダーに登録する
# -*- coding: utf-8 -*-
require "gcalapi"
require "appscript"
include Appscript
class ThingsApp
def initialize
@things = app("Things")
end
def get_projects
return @things.projects.get.map {|p| Project.new(p) }
end
end
class Project
def initialize(project)
@project = project
end
def method_missing(action)
@project.send(action).get
end
end
class Calendar
def initialize(account_name, pass)
srv = GoogleCalendar::Service.new(account_name, pass)
@calendar = GoogleCalendar::Calendar.new(srv)
end
def create_event(event)
return if @calendar.events.any? {|ev| ev.title == event.name }
return if event.due_date == :missing_value
ev = @calendar.create_event
ev.title = event.name
ev.st = event.due_date
ev.en = event.due_date
ev.allday = true
ev.save!
end
end
# めいん〜〜〜〜〜〜〜
things = ThingsApp.new
cal = Calendar.new("__ACCOUNT_NAME__", "__PASSWORD__")
things.get_projects.each do |project|
cal.create_event(project)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment