Sha256: 513ded320a168112e9c9bdf756474d0f34656511d9458c9b478187108943cbab

Contents?: true

Size: 934 Bytes

Versions: 4

Compression:

Stored size: 934 Bytes

Contents

module Waddup

  class Source::AppleMail < Waddup::Source
    include Waddup::Extension::AppleScript
    extend Waddup::Extension::AppleScript
    extend Waddup::Extension::FileSystem

    ALIAS = 'mail'
    ICON  = "\xE2\x9C\x89\xEF\xB8\x8F "

    SENT_MAIL_SCRIPT = folder_of(__FILE__) + 'apple_mail/sent_mail.applescript'

    # Aggregates sent mail events
    #
    # Arguments:
    #
    #   :from (datetime)
    #   :to   (datetime)
    #
    def events(from, to)
      results = applescript SENT_MAIL_SCRIPT,
        as_ruby: true,
        args:    [from.strftime('%d/%m/%Y %H:%M'), to.strftime('%d/%m/%Y %H:%M')]

      results.map do |result|
        Waddup::Event.new do |e|
          e.label  = result[:subject]
          e.at     = Time.parse(result[:datetime])
          e.source = self
        end
      end
    end

    # Requires AppleScript to be available
    def self.usable?
      applescript?
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
waddup-0.2.2 lib/waddup/sources/apple_mail.rb
waddup-0.2.1 lib/waddup/sources/apple_mail.rb
waddup-0.2.0 lib/waddup/sources/apple_mail.rb
waddup-0.1.0 lib/waddup/sources/apple_mail.rb