diff --git a/README.rdoc b/README.rdoc index e7806d0..9013105 100644 --- a/README.rdoc +++ b/README.rdoc @@ -17,7 +17,7 @@ In your Gemfile: In config/initializers/mail.rb: - ActionMailer::Base.register_interceptor(SendGrid::MailInterceptor) + ActionMailer::Base.register_interceptor(SendGridRails::MailInterceptor) ActionMailer::Base.smtp_settings = { :address => 'smtp.sendgrid.net', @@ -30,7 +30,7 @@ In config/initializers/mail.rb: If you use Heroku, here what the mailer initializer may look like: - ActionMailer::Base.register_interceptor(SendGrid::MailInterceptor) + ActionMailer::Base.register_interceptor(SendGridRails::MailInterceptor) if ENV['SENDGRID_USERNAME'] && ENV['SENDGRID_PASSWORD'] ActionMailer::Base.smtp_settings = { @@ -53,7 +53,7 @@ By default set to 'dummy@email.com' In config/initializers/mail.rb: - SendGrid.configure do |config| + SendGridRails.configure do |config| config.dummy_recipient = 'noreply@example.com' end diff --git a/lib/send_grid.rb b/lib/send_grid.rb index 349621f..38857c3 100644 --- a/lib/send_grid.rb +++ b/lib/send_grid.rb @@ -1,4 +1,4 @@ -module SendGrid +module SendGridRails autoload :ApiHeader, 'send_grid/api_header' autoload :MailInterceptor, 'send_grid/mail_interceptor' autoload :VERSION, 'send_grid/version' @@ -15,7 +15,7 @@ def self.included(base) module InstanceMethods def send_grid_header - @send_grid_header ||= SendGrid::ApiHeader.new + @send_grid_header ||= SendGridRails::ApiHeader.new end def mail(headers={}, &block) @@ -33,7 +33,7 @@ class << self attr_writer :config def config - @config ||= SendGrid::Config.new + @config ||= SendGridRails::Config.new end # Sendgrid.config will be default if block is not passed diff --git a/lib/send_grid/api_header.rb b/lib/send_grid/api_header.rb index e10d031..e7acb76 100644 --- a/lib/send_grid/api_header.rb +++ b/lib/send_grid/api_header.rb @@ -1,4 +1,4 @@ -class SendGrid::ApiHeader +class SendGridRails::ApiHeader attr_reader :data def initialize diff --git a/lib/send_grid/config.rb b/lib/send_grid/config.rb index 09aece9..0279d30 100644 --- a/lib/send_grid/config.rb +++ b/lib/send_grid/config.rb @@ -1,4 +1,4 @@ -class SendGrid::Config +class SendGridRails::Config attr_accessor :dummy_recipient def initialize diff --git a/lib/send_grid/mail_interceptor.rb b/lib/send_grid/mail_interceptor.rb index 9a3aa79..9651205 100644 --- a/lib/send_grid/mail_interceptor.rb +++ b/lib/send_grid/mail_interceptor.rb @@ -1,12 +1,8 @@ -module SendGrid +module SendGridRails class MailInterceptor def self.delivering_email(mail) sendgrid_header = mail.instance_variable_get(:@sendgrid_header) - sendgrid_header.add_recipients(mail.to) - sendgrid_header.add_recipients(mail.cc) - sendgrid_header.add_recipients(mail.bcc) mail.header['X-SMTPAPI'] = sendgrid_header.to_json if sendgrid_header.data.present? - mail.header['to'] = SendGrid.config.dummy_recipient end end end diff --git a/lib/send_grid/version.rb b/lib/send_grid/version.rb index 7cfd272..c853db5 100644 --- a/lib/send_grid/version.rb +++ b/lib/send_grid/version.rb @@ -1,4 +1,3 @@ -module SendGrid - VERSION = "3.1.0" +module SendGridRails + VERSION = '3.1.0' end - diff --git a/lib/sendgrid-rails.rb b/lib/sendgrid-rails.rb index ad35574..572b44d 100644 --- a/lib/sendgrid-rails.rb +++ b/lib/sendgrid-rails.rb @@ -3,4 +3,4 @@ require 'active_support/core_ext' require 'action_mailer' -ActionMailer::Base.send :include, SendGrid +ActionMailer::Base.send :include, SendGridRails diff --git a/send_grid.gemspec b/send_grid.gemspec index cf9c47f..c37bc10 100644 --- a/send_grid.gemspec +++ b/send_grid.gemspec @@ -4,7 +4,7 @@ require "send_grid/version" Gem::Specification.new do |s| s.name = "sendgrid-rails" - s.version = SendGrid::VERSION + s.version = SendGridRails::VERSION s.platform = Gem::Platform::RUBY s.authors = ["PavelTyk"] s.email = ["paveltyk@gmail.com"] diff --git a/spec/api_header_spec.rb b/spec/api_header_spec.rb index 20daaf9..1e1aea8 100644 --- a/spec/api_header_spec.rb +++ b/spec/api_header_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -describe SendGrid::ApiHeader do - let(:header) { SendGrid::ApiHeader.new } +describe SendGridRails::ApiHeader do + let(:header) { SendGridRails::ApiHeader.new } describe "#to_json" do it "returns valid json if no data was set" do header.to_json.should eql "{}" diff --git a/spec/mailer_spec.rb b/spec/mailer_spec.rb index 4e3717f..2751beb 100644 --- a/spec/mailer_spec.rb +++ b/spec/mailer_spec.rb @@ -54,7 +54,7 @@ it 'should be used in To defined in config dummy_recipient' do # dummy_recipient can be redefined config/initializers - SendGrid.configure do |config| + SendGridRails.configure do |config| config.dummy_recipient = 'noreply@example.com' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 97d1e43..6a03426 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,6 +1,6 @@ require 'sendgrid-rails' -ActionMailer::Base.register_interceptor(SendGrid::MailInterceptor) +ActionMailer::Base.register_interceptor(SendGridRails::MailInterceptor) ActionMailer::Base.delivery_method = :test ActionMailer::Base.prepend_view_path File.join(File.dirname(__FILE__), "fixtures", "views") diff --git a/spec/version_spec.rb b/spec/version_spec.rb index dad3aba..c766065 100644 --- a/spec/version_spec.rb +++ b/spec/version_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -describe 'SendGrid::VERSION' do +describe 'SendGridRails::VERSION' do it "returns string" do - SendGrid::VERSION.should be_an_instance_of(String) + SendGridRails::VERSION.should be_an_instance_of(String) end end