Class: XmlConv::Util::PopMission
- Defined in:
- lib/xmlconv/util/polling_manager.rb
Instance Attribute Summary collapse
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#host ⇒ Object
Returns the value of attribute host.
-
#pass ⇒ Object
Returns the value of attribute pass.
-
#port ⇒ Object
Returns the value of attribute port.
-
#user ⇒ Object
Returns the value of attribute user.
Attributes inherited from Mission
#arguments, #backup_dir, #debug_recipients, #destination, #error_recipients, #filter, #partner, #postprocs, #reader, #tmp_destination, #writer
Instance Method Summary collapse
Methods inherited from Mission
#create_transaction, #filtered_transaction
Instance Attribute Details
#content_type ⇒ Object
Returns the value of attribute content_type.
67 68 69 |
# File 'lib/xmlconv/util/polling_manager.rb', line 67 def content_type @content_type end |
#host ⇒ Object
Returns the value of attribute host.
67 68 69 |
# File 'lib/xmlconv/util/polling_manager.rb', line 67 def host @host end |
#pass ⇒ Object
Returns the value of attribute pass.
67 68 69 |
# File 'lib/xmlconv/util/polling_manager.rb', line 67 def pass @pass end |
#port ⇒ Object
Returns the value of attribute port.
67 68 69 |
# File 'lib/xmlconv/util/polling_manager.rb', line 67 def port @port end |
#user ⇒ Object
Returns the value of attribute user.
67 68 69 |
# File 'lib/xmlconv/util/polling_manager.rb', line 67 def user @user end |
Instance Method Details
#poll(&block) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/xmlconv/util/polling_manager.rb', line 68 def poll(&block) Net::POP3.start(@host, @port || 110, @user, @pass) { |pop| pop.each_mail { |mail| source = mail.pop begin ## work around a bug in RMail::Parser that cannot deal with ## RFC-2822-compliant CRLF.. source.gsub!(/\r\n/, "\n") (RMail::Parser.read(source), &block) ensure time = Time.now name = sprintf("%s.%s.%s", @user, time.strftime("%Y%m%d%H%M%S"), time.usec) FileUtils.mkdir_p(@backup_dir) path = File.join(@backup_dir, name) File.open(path, 'w') { |fh| fh.puts(source) } mail.delete end } } end |
#poll_message(message, &block) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/xmlconv/util/polling_manager.rb', line 89 def (, &block) if(.multipart?) .each_part { |part| (part, &block) } elsif(@content_type.match(.header.content_type('text/plain'))) src = .decode filtered_transaction(src, sprintf('pop3:%s@%s:%s', @user, @host, @port), &block) end end |