Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove fetcher plugin, not deed now.

  • Loading branch information...
commit 217b9c5abf8e0c906484ec493db9afc88cab474b 1 parent bdfa17b
@huacnlee authored
Showing with 0 additions and 747 deletions.
  1. +0 −20 vendor/plugins/fetcher/MIT-LICENSE
  2. +0 −101 vendor/plugins/fetcher/README.rdoc
  3. +0 −22 vendor/plugins/fetcher/Rakefile
  4. +0 −10 vendor/plugins/fetcher/generators/fetcher_daemon/USAGE
  5. +0 −9 vendor/plugins/fetcher/generators/fetcher_daemon/fetcher_daemon_generator.rb
  6. +0 −23 vendor/plugins/fetcher/generators/fetcher_daemon/templates/config.yml
  7. +0 −27 vendor/plugins/fetcher/generators/fetcher_daemon/templates/daemon
  8. +0 −74 vendor/plugins/fetcher/generators/fetcher_daemon/templates/daemon.rb
  9. 0  vendor/plugins/fetcher/init.rb
  10. +0 −1  vendor/plugins/fetcher/install.rb
  11. +0 −22 vendor/plugins/fetcher/lib/fetcher.rb
  12. +0 −63 vendor/plugins/fetcher/lib/fetcher/base.rb
  13. +0 −88 vendor/plugins/fetcher/lib/fetcher/imap.rb
  14. +0 −50 vendor/plugins/fetcher/lib/fetcher/pop.rb
  15. +0 −12 vendor/plugins/fetcher/lib/generators/fetcher_daemon/fetcher_daemon_generator.rb
  16. +0 −21 vendor/plugins/fetcher/lib/vendor/plain_imap.rb
  17. +0 −125 vendor/plugins/fetcher/lib/vendor/secure_pop.rb
  18. +0 −4 vendor/plugins/fetcher/tasks/fetcher_tasks.rake
  19. +0 −74 vendor/plugins/fetcher/test/fetcher_test.rb
  20. +0 −1  vendor/plugins/fetcher/uninstall.rb
View
20 vendor/plugins/fetcher/MIT-LICENSE
@@ -1,20 +0,0 @@
-Copyright (c) 2007 Dan Weinand and Slantwise Design, LLC
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
101 vendor/plugins/fetcher/README.rdoc
@@ -1,101 +0,0 @@
-= Fetcher
-
-Fetcher is a simple message fetcher perfect for using in a daemon or via cron.
-
-It implements the following common pattern:
-
-1. Connect to a server
-2. Download available messages
-3. Send each message to another object for further processing
-4. Remove downloaded messages from the remote server
-
-Install using:
-
- script/plugin install git://github.com/look/fetcher.git
-
-== Dependencies
-
-If you are using a 1.8 series Ruby, this plugin depends on the SystemTimer gem to work reliably.
-Do not forget to add it to your Gemfile or environment.rb. As Ruby 1.9 onwards use native threads
-SystemTimer gem becomes redundant, and timeout.rb is used instead.
-
-== Usage
-
-Create a new fetcher object like the following:
-
- @fetcher = Fetcher.create({:type => :pop,
- :receiver => IncomingMailHandler,
- :server => 'mail.example.com',
- :username => 'jim',
- :password => 'test'})
-
-The receiver object is expected to have a receive method that takes a message as its only argument
-(e.g., the way <tt>ActionMailer::Base.recieve</tt> works; but you don't <em>have</em> to use ActionMailer.).
-
-Call <tt>fetch</tt> to download messages and process them.
-
- @fetcher.fetch
-
-== Configuration
-
-The following options can be passed to the <tt>Fetcher.create</tt> factory method:
-
-[<tt>type</tt>] POP or IMAP
-[<tt>server</tt>] The IP address or domain name of the server
-[<tt>port</tt>] The port to connect to (defaults to the standard port for the type of server)
-[<tt>ssl</tt>] Set to any value to use SSL encryption
-[<tt>username</tt>] The username used to connect to the server
-[<tt>password</tt>] The password used to connect to the server
-[<tt>authentication</tt>] The authentication scheme to use (IMAP only). Supports LOGIN, CRAM-MD5, and PASSWORD (defaults to PLAIN)
-[<tt>use_login</tt>] Set to any value to use the LOGIN command instead of AUTHENTICATE. Some servers, like GMail, do not support AUTHENTICATE (IMAP only).
-[<tt>sleep_time</tt>] The number of seconds to sleep between fetches (defaults to 60 seconds; valid only for the generated daemon)
-[<tt>in_folder</tt>] The name of the folder from which to read incoming mail (IMAP only). Defaults to +INBOX+.
-[<tt>processed_folder</tt>] The name of a folder to move mail to after it has been processed (IMAP only). <b>NOTE:</b> If not specified, mail is deleted.
-[<tt>error_folder</tt>] The name a folder to move mail that causes an error during processing (IMAP only). Defaults to +bogus+.
-
-== Daemon generator
-
-The Fetcher plugin comes with a generator to create a daemon:
-
- script/generate fetcher_daemon MailerDaemon
-
-You should monitor the daemon using monit or god to ensure it does not crash.
-
-== Running via cron
-
-You can also run the Fetcher periodically via cron. It is important to ensure that only one
-instance is running at one time, and for that the {Lockfile gem}[http://codeforpeople.com/lib/ruby/lockfile/] is recommended.
-
-Here is an example script to be with <tt>script/runner</tt> via cron:
-
- begin
- Lockfile.new('cron_mail_fetcher.lock', :retries => 0) do
- config = YAML.load_file("#{RAILS_ROOT}/config/mail.yml")
- config = config[RAILS_ENV].to_options
-
- fetcher = Fetcher.create({:receiver => MailReceiver}.merge(config))
- fetcher.fetch
- end
- rescue Lockfile::MaxTriesLockError => e
- puts "Another fetcher is already running. Exiting."
- end
-
-== Extending
-
-You can subclass <tt>Fetcher::Base</tt> or one of the protocol-specific classed to override the standard behavior.
-
-== Further documentation
-
-<shameless-plug>
-
-You can read more about how to use the Fetcher in the PeepCode book {Receiving Email with Ruby}[https://peepcode.com/products/mms2r-pdf].
-
-</shameless-plug>
-
-== Credit & Copyright
-
-Created by Dan Weinand and Luke Francl. Development supported by {Slantwise Design}[http://slantwisedesign.com].
-
-Generators for Rails 3 compatibility added by Amol Hatwár, Exceed Consulting.
-
-Licensed under the terms of the MIT License. Be excellent to each other.
View
22 vendor/plugins/fetcher/Rakefile
@@ -1,22 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the fetcher plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Generate documentation for the fetcher plugin.'
-Rake::RDocTask.new(:rdoc) do |rdoc|
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = 'Fetcher'
- rdoc.options << '--line-numbers' << '--inline-source'
- rdoc.rdoc_files.include('README')
- rdoc.rdoc_files.include('lib/**/*.rb')
-end
View
10 vendor/plugins/fetcher/generators/fetcher_daemon/USAGE
@@ -1,10 +0,0 @@
-Description:
- Create a fetcher daemon with a given name
-
-Example:
- ./script/generate fetcher_daemon MailReader
-
- This will create:
- /config/mail_reader_fetcher.yml
- /script/mail_reader_fetcher
- /lib/daemon.rb
View
9 vendor/plugins/fetcher/generators/fetcher_daemon/fetcher_daemon_generator.rb
@@ -1,9 +0,0 @@
-class FetcherDaemonGenerator < Rails::Generator::NamedBase
- def manifest
- record do |m|
- m.template 'config.yml', "config/#{file_name}.yml"
- m.template 'daemon', "script/#{file_name}_fetcher", :chmod => 0755
- m.template 'daemon.rb', "/lib/daemon.rb"
- end
- end
-end
View
23 vendor/plugins/fetcher/generators/fetcher_daemon/templates/config.yml
@@ -1,23 +0,0 @@
-defaults: &defaults
- type: imap # pop OR imap
- server: imap.example.com # server hostname
- port: # 993 for IMAPs
- ssl: true # Remove if not using SSL
- username: # Username
- password: # Password
- receiver: # ActionMailer that will receive mail
- use_login: true # Required for GMAIL
- sleep_time: # Poll Frequency. 60 seconds by default
- authentication: # LOGIN, CRAM-MD5, PASSWORD (IMAP Only)
-
-development:
- <<: *defaults
- # Override other values here
-
-test:
- <<: *defaults
- # Override other values here
-
-production:
- <<: *defaults
- # Override other values here
View
27 vendor/plugins/fetcher/generators/fetcher_daemon/templates/daemon
@@ -1,27 +0,0 @@
-#!/usr/bin/env ruby
-require File.dirname(__FILE__) + '/../config/environment.rb'
-
-class <%=class_name%>FetcherDaemon < Daemon::Base
-
- @config = YAML.load_file("#{Rails.root}/config/<%=file_name%>.yml")
- @config = @config[Rails.env].to_options
-
- @sleep_time = @config.delete(:sleep_time) || 60
- def self.start
- puts "Starting <%=class_name%>FetcherDaemon"
- # Add your own receiver object below
- @fetcher = Fetcher.create({:receiver => nil}.merge(@config))
-
- loop do
- @fetcher.fetch
- sleep(@sleep_time)
- end
- end
-
- def self.stop
- puts "Stopping <%=class_name%>FetcherDaemon"
- end
-
-end
-
-<%=class_name%>FetcherDaemon.daemonize
View
74 vendor/plugins/fetcher/generators/fetcher_daemon/templates/daemon.rb
@@ -1,74 +0,0 @@
-# Taken from http://snippets.dzone.com/posts/show/2265
-
-require 'fileutils'
-
-module Daemon
- WorkingDirectory = File.join(File.dirname(__FILE__), '..')
-
- class Base
- def self.pid_fn
- File.join(WorkingDirectory, "log", "#{name}.pid")
- end
-
- def self.daemonize
- Controller.daemonize(self)
- end
- end
-
- module PidFile
- def self.store(daemon, pid)
- File.open(daemon.pid_fn, 'w') {|f| f << pid}
- end
-
- def self.recall(daemon)
- IO.read(daemon.pid_fn).to_i rescue nil
- end
- end
-
- module Controller
- def self.daemonize(daemon)
- case !ARGV.empty? && ARGV[0]
- when 'start'
- start(daemon)
- when 'stop'
- stop(daemon)
- when 'restart'
- stop(daemon)
- start(daemon)
- else
- puts "Invalid command. Please specify start, stop or restart."
- exit
- end
- end
-
- def self.start(daemon)
- fork do
- Process.setsid
- exit if fork
- PidFile.store(daemon, Process.pid)
- Dir.chdir WorkingDirectory
- File.umask 0000
- STDIN.reopen "/dev/null"
- #STDOUT.reopen "/dev/null", "a"
- STDERR.reopen STDOUT
- trap("TERM") {daemon.stop; exit}
- daemon.start
- end
- end
-
- def self.stop(daemon)
- if !File.file?(daemon.pid_fn)
- puts "Pid file not found. Is the daemon started?"
- exit
- end
- pid = PidFile.recall(daemon)
- FileUtils.rm(daemon.pid_fn)
-
- begin
- pid && Process.kill("TERM", pid)
- rescue Errno::ESRCH => e
- puts "warning: process #{pid} not found"
- end
- end
- end
-end
View
0  vendor/plugins/fetcher/init.rb
No changes.
View
1  vendor/plugins/fetcher/install.rb
@@ -1 +0,0 @@
-# Install hook code here
View
22 vendor/plugins/fetcher/lib/fetcher.rb
@@ -1,22 +0,0 @@
-module Fetcher
- # Use factory-style initialization or insantiate directly from a subclass
- #
- # Options:
- # * <tt>:type</tt> - Name of class as a symbol to instantiate
- #
- # Other options are the same as Fetcher::Base.new
- #
- # Example:
- #
- # Fetcher.create(:type => :pop) is equivalent to
- # Fetcher::Pop.new()
- def self.create(options={})
- klass = options.delete(:type)
- raise ArgumentError, 'Must supply a type' unless klass
- module_eval "#{klass.to_s.capitalize}.new(options)"
- end
-end
-
-require 'fetcher/base'
-require 'fetcher/pop'
-require 'fetcher/imap'
View
63 vendor/plugins/fetcher/lib/fetcher/base.rb
@@ -1,63 +0,0 @@
-module Fetcher
- class Base
- # Options:
- # * <tt>:server</tt> - Server to connect to.
- # * <tt>:username</tt> - Username to use when connecting to server.
- # * <tt>:password</tt> - Password to use when connecting to server.
- # * <tt>:receiver</tt> - Receiver object to pass messages to. Assumes the
- # receiver object has a receive method that takes a message as it's argument
- #
- # Additional protocol-specific options implimented by sub-classes
- #
- # Example:
- # Fetcher::Base.new(:server => 'mail.example.com',
- # :username => 'pam',
- # :password => 'test',
- # :receiver => IncomingMailHandler)
- def initialize(options={})
- %w(server username password receiver).each do |opt|
- raise ArgumentError, "#{opt} is required" unless options[opt.to_sym]
- # convert receiver to a Class if it isn't already.
- if opt == "receiver" && options[:receiver].is_a?(String)
- options[:receiver] = Kernel.const_get(options[:receiver])
- end
-
- instance_eval("@#{opt} = options[:#{opt}]")
- end
- end
-
- # Run the fetching process
- def fetch
- establish_connection
- get_messages
- close_connection
- end
-
- protected
-
- # Stub. Should be overridden by subclass.
- def establish_connection #:nodoc:
- raise NotImplementedError, "This method should be overridden by subclass"
- end
-
- # Stub. Should be overridden by subclass.
- def get_messages #:nodoc:
- raise NotImplementedError, "This method should be overridden by subclass"
- end
-
- # Stub. Should be overridden by subclass.
- def close_connection #:nodoc:
- raise NotImplementedError, "This method should be overridden by subclass"
- end
-
- # Send message to receiver object
- def process_message(message)
- @receiver.receive(message)
- end
-
- # Stub. Should be overridden by subclass.
- def handle_bogus_message(message) #:nodoc:
- raise NotImplementedError, "This method should be overridden by subclass"
- end
- end
-end
View
88 vendor/plugins/fetcher/lib/fetcher/imap.rb
@@ -1,88 +0,0 @@
-(RUBY_VERSION < '1.9.0') ? require('system_timer') : require('timeout')
-require File.dirname(__FILE__) + '/../vendor/plain_imap'
-
-module Fetcher
- class Imap < Base
-
- PORT = 143
-
- protected
-
- # Additional Options:
- # * <tt>:authentication</tt> - authentication type to use, defaults to PLAIN
- # * <tt>:port</tt> - port to use (defaults to 143)
- # * <tt>:ssl</tt> - use SSL to connect
- # * <tt>:use_login</tt> - use LOGIN instead of AUTHENTICATE to connect (some IMAP servers, like GMail, do not support AUTHENTICATE)
- # * <tt>:processed_folder</tt> - if set to the name of a mailbox, messages will be moved to that mailbox instead of deleted after processing. The mailbox will be created if it does not exist.
- # * <tt>:error_folder:</tt> - the name of a mailbox where messages that cannot be processed (i.e., your receiver throws an exception) will be moved. Defaults to "bogus". The mailbox will be created if it does not exist.
- def initialize(options={})
- @authentication = options.delete(:authentication) || 'PLAIN'
- @port = options.delete(:port) || PORT
- @ssl = options.delete(:ssl)
- @use_login = options.delete(:use_login)
- @in_folder = options.delete(:in_folder) || 'INBOX'
- @processed_folder = options.delete(:processed_folder)
- @error_folder = options.delete(:error_folder) || 'bogus'
- super(options)
- end
-
- # Open connection and login to server
- def establish_connection
- timeout_call = (RUBY_VERSION < '1.9.0') ? "SystemTimer.timeout_after(15.seconds) do" : "Timeout::timeout(15) do"
-
- eval("#{timeout_call}
- @connection = Net::IMAP.new(@server, @port, @ssl)
- if @use_login
- @connection.login(@username, @password)
- else
- @connection.authenticate(@authentication, @username, @password)
- end
- end")
- end
-
- # Retrieve messages from server
- def get_messages
- @connection.select(@in_folder)
- @connection.uid_search(['ALL']).each do |uid|
- msg = @connection.uid_fetch(uid,'RFC822').first.attr['RFC822']
- begin
- process_message(msg)
- add_to_processed_folder(uid) if @processed_folder
- rescue
- handle_bogus_message(msg)
- end
- # Mark message as deleted
- @connection.uid_store(uid, "+FLAGS", [:Seen, :Deleted])
- end
- end
-
- # Store the message for inspection if the receiver errors
- def handle_bogus_message(message)
- create_mailbox(@error_folder)
- @connection.append(@error_folder, message)
- end
-
- # Delete messages and log out
- def close_connection
- @connection.expunge
- @connection.logout
- begin
- @connection.disconnect unless @connection.disconnected?
- rescue
- Rails.logger.info("Fetcher: Remote closed connection before I could disconnect.")
- end
- end
-
- def add_to_processed_folder(uid)
- create_mailbox(@processed_folder)
- @connection.uid_copy(uid, @processed_folder)
- end
-
- def create_mailbox(mailbox)
- unless @connection.list("", mailbox)
- @connection.create(mailbox)
- end
- end
-
- end
-end
View
50 vendor/plugins/fetcher/lib/fetcher/pop.rb
@@ -1,50 +0,0 @@
-require File.dirname(__FILE__) + '/../vendor/secure_pop'
-
-module Fetcher
- class Pop < Base
-
- protected
-
- # Additional Options:
- # * <tt>:ssl</tt> - whether or not to use ssl encryption
- # * <tt>:port</tt> - port to use (defaults to 110)
- def initialize(options={})
- @ssl = options.delete(:ssl)
- @port = options.delete(:port) || Net::POP3.default_port
- super(options)
- end
-
- # Open connection and login to server
- def establish_connection
- @connection = Net::POP3.new(@server, @port)
- @connection.enable_ssl(OpenSSL::SSL::VERIFY_NONE) if @ssl
- @connection.start(@username, @password)
- end
-
- # Retrieve messages from server
- def get_messages
- unless @connection.mails.empty?
- @connection.each_mail do |msg|
- begin
- process_message(msg.pop)
- rescue
- handle_bogus_message(msg.pop)
- end
- # Delete message from server
- msg.delete
- end
- end
- end
-
- # Store the message for inspection if the receiver errors
- def handle_bogus_message(message)
- # This needs a good solution
- end
-
- # Close connection to server
- def close_connection
- @connection.finish
- end
-
- end
-end
View
12 vendor/plugins/fetcher/lib/generators/fetcher_daemon/fetcher_daemon_generator.rb
@@ -1,12 +0,0 @@
-require 'rails/generators'
-
-class FetcherDaemonGenerator < Rails::Generators::NamedBase
- source_root File.join(File.dirname(__FILE__), '../../../generators/fetcher_daemon', 'templates')
-
- def create_fetcher_daemon
- copy_file('daemon.rb', "lib/daemon.rb")
- template('config.yml', File.join('config', "#{file_name}.yml"))
- template('daemon', File.join('script', "#{file_name}_fetcher"))
- chmod(File.join("script", "#{file_name}_fetcher"), 0755)
- end
-end
View
21 vendor/plugins/fetcher/lib/vendor/plain_imap.rb
@@ -1,21 +0,0 @@
-require 'net/imap'
-# add plain as an authentication type...
-# This is taken from:
-# http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/lib/net/imap.rb?revision=7657&view=markup&pathrev=10966
-
-# Authenticator for the "PLAIN" authentication type. See
-# #authenticate().
-class PlainAuthenticator
- def process(data)
- return "\0#{@user}\0#{@password}"
- end
-
- private
-
- def initialize(user, password)
- @user = user
- @password = password
- end
-end
-
-Net::IMAP.add_authenticator "PLAIN", PlainAuthenticator
View
125 vendor/plugins/fetcher/lib/vendor/secure_pop.rb
@@ -1,125 +0,0 @@
-require 'socket'
-require 'net/pop'
-require 'net/protocol'
-require 'openssl/ssl'
-
-# Backport of ruby 1.9's POP3 SSL support
-class Net::POP3
- @@usessl = nil
- @@verify = nil
- @@certs = nil
- PORT = 110
- SSL_PORT = 995
-
- def self.default_port
- PORT
- end
-
- def self.default_ssl_port
- SSL_PORT
- end
-
- # Enable SSL for all new instances.
- # +verify+ is the type of verification to do on the Server Cert; Defaults
- # to OpenSSL::SSL::VERIFY_PEER.
- # +certs+ is a file or directory holding CA certs to use to verify the
- # server cert; Defaults to nil.
- def self.enable_ssl( verify = OpenSSL::SSL::VERIFY_PEER, certs = nil )
- @@usessl = true
- @@verify = verify
- @@certs = certs
- end
-
- # Disable SSL for all new instances.
- def self.disable_ssl
- @@usessl = nil
- @@verify = nil
- @@certs = nil
- end
-
- # Creates a new POP3 object.
- # +addr+ is the hostname or ip address of your POP3 server.
- # The optional +port+ is the port to connect to.
- # The optional +isapop+ specifies whether this connection is going
- # to use APOP authentication; it defaults to +false+.
- # This method does *not* open the TCP connection.
- def initialize(addr, port = nil, isapop = false)
- @address = addr
- @usessl = @@usessl
- if @usessl
- @port = port || SSL_PORT
- else
- @port = port || PORT
- end
- @apop = isapop
-
- @certs = @@certs
- @verify = @@verify
-
- @command = nil
- @socket = nil
- @started = false
- @open_timeout = 30
- @read_timeout = 60
- @debug_output = nil
-
- @mails = nil
- @n_mails = nil
- @n_bytes = nil
- end
-
- # does this instance use SSL?
- def usessl?
- @usessl
- end
-
- # Enables SSL for this instance. Must be called before the connection is
- # established to have any effect.
- # +verify+ is the type of verification to do on the Server Cert; Defaults
- # to OpenSSL::SSL::VERIFY_PEER.
- # +certs+ is a file or directory holding CA certs to use to verify the
- # server cert; Defaults to nil.
- # +port+ is port to establish the SSL conection on; Defaults to 995.
- def enable_ssl(verify = OpenSSL::SSL::VERIFY_PEER, certs = nil,
- port = SSL_PORT)
- @usessl = true
- @verify = verify
- @certs = certs
- @port = port
- end
-
- def disable_ssl
- @usessl = nil
- @verify = nil
- @certs = nil
- end
-
- def do_start( account, password )
- s = timeout(@open_timeout) { TCPSocket.open(@address, @port) }
- if @usessl
- unless defined?(OpenSSL)
- raise "SSL extension not installed"
- end
- sslctx = OpenSSL::SSL::SSLContext.new
- sslctx.verify_mode = @verify
- sslctx.ca_file = @certs if @certs && FileTest::file?(@certs)
- sslctx.ca_path = @certs if @certs && FileTest::directory?(@certs)
- s = OpenSSL::SSL::SSLSocket.new(s, sslctx)
- s.sync_close = true
- s.connect
- end
-
- @socket = Net::InternetMessageIO.new(s)
- on_connect
- @command = Net::POP3Command.new(@socket)
- if apop?
- @command.apop account, password
- else
- @command.auth account, password
- end
- @started = true
- ensure
- do_finish if not @started
- end
- private :do_start
-end
View
4 vendor/plugins/fetcher/tasks/fetcher_tasks.rake
@@ -1,4 +0,0 @@
-# desc "Explaining what the task does"
-# task :fetcher do
-# # Task goes here
-# end
View
74 vendor/plugins/fetcher/test/fetcher_test.rb
@@ -1,74 +0,0 @@
-# require File.dirname(__FILE__) + '/../../../../config/boot'
-require 'rubygems'
-require 'test/unit'
-require 'mocha'
-require 'fetcher'
-
-class FetcherTest < Test::Unit::TestCase
-
- def setup
- @receiver = mock()
- end
-
- def test_should_set_configuration_instance_variables
- create_fetcher
- assert_equal 'test.host', @fetcher.instance_variable_get(:@server)
- assert_equal 'name', @fetcher.instance_variable_get(:@username)
- assert_equal 'password', @fetcher.instance_variable_get(:@password)
- assert_equal @receiver, @fetcher.instance_variable_get(:@receiver)
- end
-
- def test_should_require_subclass
- create_fetcher
- assert_raise(NotImplementedError) { @fetcher.fetch }
- end
-
- def test_should_require_server
- assert_raise(ArgumentError) { create_fetcher(:server => nil) }
- end
-
- def test_should_require_username
- assert_raise(ArgumentError) { create_fetcher(:username => nil) }
- end
-
- def test_should_require_password
- assert_raise(ArgumentError) { create_fetcher(:password => nil) }
- end
-
- def test_should_require_receiver
- assert_raise(ArgumentError) { create_fetcher(:receiver => nil) }
- end
-
- def create_fetcher(options={})
- @fetcher = Fetcher::Base.new({:server => 'test.host', :username => 'name', :password => 'password', :receiver => @receiver}.merge(options))
- end
-
-end
-
-class FactoryFetcherTest < Test::Unit::TestCase
-
- def setup
- @receiver = mock()
- @pop_fetcher = Fetcher.create(:type => :pop, :server => 'test.host',
- :username => 'name',
- :password => 'password',
- :receiver => @receiver)
-
- @imap_fetcher = Fetcher.create(:type => :imap, :server => 'test.host',
- :username => 'name',
- :password => 'password',
- :receiver => @receiver)
- end
-
- def test_should_be_sublcass
- assert_equal Fetcher::Pop, @pop_fetcher.class
- assert_equal Fetcher::Imap, @imap_fetcher.class
- end
-
- def test_should_require_type
- assert_raise(ArgumentError) { Fetcher.create({}) }
- end
-
-end
-
-# Write tests for sub-classes
View
1  vendor/plugins/fetcher/uninstall.rb
@@ -1 +0,0 @@
-# Uninstall hook code here
Please sign in to comment.
Something went wrong with that request. Please try again.