Sha256: 988ee73d708190460adb4d6e7d5ff68ac59f6e1047227fa5e7e23714f335b1c6

Contents?: true

Size: 1009 Bytes

Versions: 8

Compression:

Stored size: 1009 Bytes

Contents

#!/usr/bin/ruby

require 'sup'
require 'stringio'
require 'rmail'
require 'uri'

module Redwood

class DummySource < Source

  attr_accessor :messages

  def initialize uri, last_date=nil, usual=true, archived=false, id=nil, labels=[]
    super uri, usual, archived, id
    @messages = nil
  end

  def start_offset
    0
  end

  def end_offset
    # should contain the number of test messages -1
    return @messages ? @messages.length - 1 : 0
  end

  def load_header offset
    Source.parse_raw_email_header StringIO.new(raw_header(offset))
  end

  def load_message offset
    RMail::Parser.read raw_message(offset)
  end

  def raw_header offset
    ret = ""
    f = StringIO.new(@messages[offset])
    until f.eof? || (l = f.gets) =~ /^$/
      ret += l
    end
    ret
  end

  def raw_message offset
    @messages[offset]
  end

  def each_raw_message_line offset
    ret = ""
    f = StringIO.new(@messages[offset])
    until f.eof?
      yield f.gets
    end
  end
end

end

# vim:noai:ts=2:sw=2:

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sup-1.0 test/dummy_source.rb
sup-0.23 test/dummy_source.rb
sup-0.22.1 test/dummy_source.rb
sup-0.22.0 test/dummy_source.rb
sup-0.21.0 test/dummy_source.rb
sup-0.20.0 test/dummy_source.rb
sup-0.19.0 test/dummy_source.rb
sup-0.18.0 test/dummy_source.rb