Skip to content

Commit

Permalink
turn into a gem
Browse files Browse the repository at this point in the history
  • Loading branch information
hone committed May 5, 2011
1 parent 10f708c commit b3e767e
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 21 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,4 @@
source "http://rubygems.org"

# Specify your gem's dependencies in heroku-sendgrid-test-email.gemspec
gemspec
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'bundler'
Bundler::GemHelper.install_tasks
23 changes: 23 additions & 0 deletions heroku-sendgrid-test-email.gemspec
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "heroku-sendgrid-test-email/version"

Gem::Specification.new do |s|
s.name = "heroku-sendgrid-test-email"
s.version = Heroku::Command::Sendgrid::TestEmail::VERSION
s.authors = ["Terence Lee"]
s.email = ["hone02@gmail.com"]
s.homepage = ""
s.summary = %q{Heroku plugin to test sendgrid addon}
s.description = %q{Heroku plugin to test sendgrid addon}

s.rubyforge_project = "heroku-sendgrid-test-email"

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_dependency "heroku", "~> 2.0.0"
s.add_development_dependency "rake"
end
22 changes: 1 addition & 21 deletions init.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,21 +1 @@
class Heroku::Command::Sendgrid < Heroku::Command::Base require 'heroku-sendgrid-test-email'
def test_email
app = extract_app
vars = heroku.config_vars(app)
to = ''
args.each do |arg|
key, value = arg.split("=")
to = value if key == "to"
end

if to.empty?
error "please specify an address to send to using to=<me@example.com>"
else
resource = RestClient::Resource.new("https://pony-mail-test.heroku.com")
display resource["/mail"].post(:sendgrid_username => vars["SENDGRID_USERNAME"],
:sendgrid_password => vars["SENDGRID_PASSWORD"],
:sendgrid_domain => vars["SENDGRID_DOMAIN"],
:to => to)
end
end
end
1 change: 1 addition & 0 deletions lib/heroku-sendgrid-test-email.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
require 'heroku-sendgrid-test-email/command/sendgrid'
23 changes: 23 additions & 0 deletions lib/heroku-sendgrid-test-email/command/sendgrid.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'heroku/command/base'

class Heroku::Command::Sendgrid < Heroku::Command::Base
def test_email
app = extract_app
vars = heroku.config_vars(app)
to = ''
args.each do |arg|
key, value = arg.split("=")
to = value if key == "to"
end

if to.empty?
error "please specify an address to send to using to=<me@example.com>"
else
resource = RestClient::Resource.new("https://pony-mail-test.heroku.com")
display resource["/mail"].post(:sendgrid_username => vars["SENDGRID_USERNAME"],
:sendgrid_password => vars["SENDGRID_PASSWORD"],
:sendgrid_domain => vars["SENDGRID_DOMAIN"],
:to => to)
end
end
end
9 changes: 9 additions & 0 deletions lib/heroku-sendgrid-test-email/version.rb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,9 @@
module Heroku
module Command
module Sendgrid
module TestEmail
VERSION = "0.0.1"
end
end
end
end

0 comments on commit b3e767e

Please sign in to comment.