Permalink
Browse files

Mailkit becomes Incoming!

  • Loading branch information...
joshuap committed Feb 17, 2013
1 parent a7aeea9 commit e07afb580518c2aaa6dae57701a7e85f68cfdfb5
View
@@ -3,4 +3,4 @@ rvm:
- 1.8.7
- 1.9.2
- 1.9.3
script: rspec spec
script: rake
View
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
mailkit (0.1.1)
incoming (0.1.0)
mail (~> 2.4.1)
postmark-mitt (~> 0.0.11)
@@ -38,6 +38,7 @@ GEM
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
rake (10.0.3)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
@@ -47,7 +48,6 @@ GEM
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.2)
slop (3.4.3)
sqlite3 (1.3.5)
terminal-table (1.4.5)
thor (0.17.0)
treetop (1.4.12)
@@ -60,6 +60,6 @@ PLATFORMS
DEPENDENCIES
guard
guard-rspec
mailkit!
incoming!
rake
rspec
sqlite3
@@ -1,14 +1,14 @@
Mailkit
Incoming!
-----------
Mailkit helps you receive email in your Rack apps.
Incoming! helps you receive email in your Rack apps.
Brought to you by :zap: **Honeybadger.io**, painless [Rails exception tracking](https://www.honeybadger.io/).
## Sendgrid example:
```ruby
class EmailReceiver < Mailkit::Strategies::Sendgrid
class EmailReceiver < Incoming::Strategies::Sendgrid
def receive(mail)
puts %(Got message from #{mail.to.first} with subject "#{mail.subject}")
end
@@ -21,7 +21,7 @@ result = EmailReceiver.receive(req) # => Got message from whoever@wherever.com w
## Mailgun example:
```ruby
class EmailReceiver < Mailkit::Strategies::Mailgun
class EmailReceiver < Incoming::Strategies::Mailgun
setup :api_key => 'asdf'
def receive(mail)
@@ -36,7 +36,7 @@ result = EmailReceiver.receive(req) # => Got message from whoever@wherever.com w
## Postmark example:
```ruby
class EmailReceiver < Mailkit::Strategies::Postmark
class EmailReceiver < Incoming::Strategies::Postmark
def receive(mail)
puts %(Got message from #{mail.to.first} with subject "#{mail.subject}")
end
@@ -49,7 +49,7 @@ result = EmailReceiver.receive(req) # => Got message from whoever@wherever.com w
## Postfix example:
```ruby
class EmailReceiver < Mailkit::Strategies::HTTPPost
class EmailReceiver < Incoming::Strategies::HTTPPost
setup :secret => '6d7e5337a0cd69f52c3fcf9f5af438b1'
def receive(mail)
@@ -115,9 +115,9 @@ end
2. Create a topic branch `git checkout -b my_branch`
3. Commit your changes `git commit -am "Boom"`
3. Push to your branch `git push origin my_branch`
4. Send a [pull request](https://github.com/honeybadger-io/mailkit/pulls)
4. Send a [pull request](https://github.com/honeybadger-io/incoming/pulls)
## License
Mailkit is Copyright 2013 © Honeybadger Industries LLC. It is free software, and
Incoming! is Copyright 2013 © Honeybadger Industries LLC. It is free software, and
may be redistributed under the terms specified in the MIT-LICENSE file.
View
@@ -5,10 +5,12 @@ rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
require 'rubygems'
require 'rake'
require 'date'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task :default => :spec
#############################################################################
#
# Helper functions
@@ -28,10 +30,6 @@ def date
Date.today.to_s
end
def rubyforge_project
name
end
def gemspec_file
"#{name}.gemspec"
end
@@ -44,48 +42,6 @@ def replace_header(head, header_name)
head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
end
#############################################################################
#
# Standard tasks
#
#############################################################################
task :default => :test
require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end
desc "Generate RCov test coverage and open in your browser"
task :coverage do
require 'rcov'
sh "rm -fr coverage"
sh "rcov test/*_test.rb"
sh "open coverage/index.html"
end
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = "#{name} #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
desc "Open an irb session preloaded with this library"
task :console do
sh "irb -rubygems -r ./lib/#{name}.rb"
end
#############################################################################
#
# Custom tasks (add your own tasks here)
#
#############################################################################
#############################################################################
#
# Packaging tasks
@@ -102,7 +58,7 @@ task :release => :build do
sh "git tag v#{version}"
sh "git push origin master"
sh "git push origin v#{version}"
sh "fury push pkg/#{name}-#{version}.gem"
sh "gem push pkg/#{name}-#{version}.gem"
end
desc "Build #{gem_file} into the pkg directory"
@@ -121,8 +77,6 @@ task :gemspec => :validate do
replace_header(spec, :name)
replace_header(spec, :version)
replace_header(spec, :date)
#comment this out if your rubyforge_project has a different name
replace_header(spec, :rubyforge_project)
# piece file back together and write
File.open(gemspec_file, 'w') { |io| io.write(spec) }
@@ -141,4 +95,3 @@ task :validate do
exit!
end
end
View
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
require 'mailkit'
require 'incoming'
require 'net/http'
require 'uri'
require 'openssl'
View
@@ -0,0 +1,28 @@
Gem::Specification.new do |s|
# The following lines are updated automatically by `rake gemspec`
s.name = 'incoming'
s.version = '0.1.0'
s.date = '2013-02-16'
s.summary = 'Incoming! helps you receive email in your Rack apps.'
s.description = 'Incoming! standardizes various mail parse apis, making it a snap to receive emails through HTTP post hooks.'
s.authors = ['Joshua Wood']
s.email = ['josh@honeybadger.io']
s.homepage = 'https://www.honeybadger.io/'
s.required_rubygems_version = Gem::Requirement.new('>= 1.8.25')
s.files = Dir['{app,config,db,lib}/**/*'] + ['LICENSE', 'Rakefile', 'README.markdown']
s.require_paths = %w[lib]
s.executables << 'http_post'
s.add_dependency 'mail', '~> 2.4.1'
s.add_dependency 'postmark-mitt', '~> 0.0.11'
s.add_development_dependency 'rake'
s.add_development_dependency 'rspec'
s.add_development_dependency 'guard'
s.add_development_dependency 'guard-rspec'
end
View
@@ -0,0 +1,14 @@
require 'mail'
require 'incoming/strategy'
module Incoming
VERSION = '0.1.0'
module Strategies
autoload :Sendgrid, 'incoming/strategies/sendgrid'
autoload :Mailgun, 'incoming/strategies/mailgun'
autoload :Postmark, 'incoming/strategies/postmark'
autoload :HTTPPost, 'incoming/strategies/http_post'
autoload :Raw, 'incoming/strategies/raw'
end
end
@@ -1,4 +1,4 @@
module Mailkit
module Incoming
module Strategies
class HTTPPost < Raw
option :secret
@@ -1,23 +1,23 @@
require 'json'
module Mailkit
module Incoming
module Strategies
# Public: MailGun Incoming Mail Strategy
# Public: MailGun Incoming! Mail Strategy
#
# API Documentation:
# http://documentation.mailgun.net/user_manual.html#receiving-messages
#
# Examples:
#
# class MailReceiver < Mailkit::Strategies::Mailgun
# class MailReceiver < Incoming::Strategies::Mailgun
# setup api_key: 'asdf'
#
# def receive(mail)
# puts "Got message from mailgun: #{mail.subject}"
# end
# end
class Mailgun
include Mailkit::Strategy
include Incoming::Strategy
# Mailgun API key
option :api_key
@@ -1,7 +1,9 @@
module Mailkit
require 'postmark_mitt'
module Incoming
module Strategies
class Postmark
include Mailkit::Strategy
include Incoming::Strategy
def initialize(request)
email = ::Postmark::Mitt.new(request.body.read)
@@ -1,7 +1,7 @@
module Mailkit
module Incoming
module Strategies
class Raw
include Mailkit::Strategy
include Incoming::Strategy
def initialize(raw_mail)
@message = Mail.new(raw_mail)
@@ -1,7 +1,7 @@
module Mailkit
module Incoming
module Strategies
class Sendgrid
include Mailkit::Strategy
include Incoming::Strategy
def initialize(request)
params = request.params.dup
@@ -1,4 +1,4 @@
module Mailkit
module Incoming
module Strategy
def self.included(base)
base.extend ClassMethods
@@ -34,8 +34,8 @@ def default_options
#
# Examples:
#
# class Mailkit::Strategies::MyStrategy
# include Mailkit::Strategy
# class Incoming::Strategies::MyStrategy
# include Incoming::Strategy
# option :api_key
# option :mime, false
# end
@@ -51,7 +51,7 @@ def option(name, value = nil)
#
# Examples:
#
# class MailReceiver < Mailkit::Strategies::MyStrategy
# class MailReceiver < Incoming::Strategies::MyStrategy
# setup api_key: 'asdf', mime: true
# end
#
@@ -88,7 +88,7 @@ def receive(mail)
#
# Examples:
#
# class MailReceiver < Mailkit::Strategies::MyStrategy
# class MailReceiver < Incoming::Strategies::MyStrategy
# def initialize(request)
# @secret_word = request.params['secret_word']
# end
View

This file was deleted.

Oops, something went wrong.
View

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit e07afb5

Please sign in to comment.