Sha256: 75b04cb8a1cfbb57d58db13a8bb3166a5afdc546f8a3e112de51724155a3369f

Contents?: true

Size: 602 Bytes

Versions: 2

Compression:

Stored size: 602 Bytes

Contents

require 'appscript'
require 'mail'
require 'osax'

module ThingsFetcher
  class MailHandler
    def initialize(config)
      super
      @config = config
    end
    
    def receive(data)
      msg = Mail.read_from_string(data)
      make_todo msg.subject
    end
  
    private
      include Appscript
      include OSAX
      
      attr_accessor :config
  
      def make_todo(name)
        things = app("Things")
        todo = things.make(:new => :to_do, :at => things.lists[config[:list]], :with_properties => { :name => name })
        todo.tag_names.set config[:tag_names]
      end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
things-fetcher-0.1.1 lib/things_fetcher/mail_handler.rb
things-fetcher-0.1.0 lib/things_fetcher/mail_handler.rb