Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
on:
pull_request:
jobs:
build:
name: >-
Ruby ${{ matrix.ruby }} (${{ matrix.gemfile }})
env:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
ruby:
- '3.1'
- '3.2'
gemfile:
- gemfiles/rails_6.gemfile
- gemfiles/rails_7.gemfile
steps:
- name: Repo checkout
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
rubygems: latest
- name: Run tests
timeout-minutes: 10
run: bundle exec rake spec
16 changes: 16 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: release
on:
push:
branches:
- master
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
id: release
with:
release-type: ruby
package-name: sparkpost_rails
bump-minor-pre-major: true
version-file: "lib/sparkpost_rails/version.rb"
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ config/secrets.yml
/.bundle
/vendor/bundle

Gemfile.lock

# these should all be checked in to normalise the environment:
# Gemfile.lock, .ruby-version, .ruby-gemset
# .ruby-version, .ruby-gemset

# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
Expand All @@ -29,3 +31,5 @@ config/secrets.yml
/vendor/assets/bower_components
*.bowerrc
bower.json

/.idea
20 changes: 20 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require:
- rubocop-rake

Metrics:
Enabled: false

Style:
Enabled: false

Lint:
Enabled: false

Layout/LineLength:
Enabled: false

Gemspec/DevelopmentDependencies:
EnforcedStyle: gemspec

AllCops:
NewCops: enable
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.1
3.1.3
9 changes: 9 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
appraise "rails-6" do
gem "actionmailer", "6.1.4.7"
gem "railties", "6.1.4.7"
end

appraise "rails-7" do
gem "actionmailer", "7.0.6"
gem "railties", "7.0.6"
end
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
source "http://rubygems.org"
# frozen_string_literal: true

source 'http://rubygems.org'

gemspec
118 changes: 0 additions & 118 deletions Gemfile.lock

This file was deleted.

7 changes: 4 additions & 3 deletions Rakefile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/env rake
# frozen_string_literal: true

begin
require 'bundler/setup'
rescue LoadError
Expand All @@ -12,7 +14,7 @@ rescue LoadError
RDoc::Task = Rake::RDocTask
end

require "bundler/gem_tasks"
require 'bundler/gem_tasks'
require 'rake'
require 'rspec/core/rake_task'

Expand All @@ -24,7 +26,6 @@ RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('lib/**/*.rb')
end


Bundler::GemHelper.install_tasks

require 'rake/testtask'
Expand All @@ -41,4 +42,4 @@ RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = '--format documentation'
end

task :default => :spec
task default: :spec
2 changes: 2 additions & 0 deletions gemfiles/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
BUNDLE_RETRY: "1"
8 changes: 8 additions & 0 deletions gemfiles/rails_6.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "actionmailer", "6.1.4.7"
gem "railties", "6.1.4.7"

gemspec path: "../"
8 changes: 8 additions & 0 deletions gemfiles/rails_7.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# This file was generated by Appraisal

source "http://rubygems.org"

gem "actionmailer", "7.0.6"
gem "railties", "7.0.6"

gemspec path: "../"
40 changes: 14 additions & 26 deletions lib/sparkpost_rails.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
require "sparkpost_rails/data_options"
require "sparkpost_rails/delivery_method"
require "sparkpost_rails/exceptions"
require "sparkpost_rails/railtie"
# frozen_string_literal: true

require 'sparkpost_rails/data_options'
require 'sparkpost_rails/delivery_method'
require 'sparkpost_rails/exceptions'
require 'sparkpost_rails/railtie'

module SparkPostRails
class << self
Expand All @@ -18,35 +20,21 @@ def self.configure
end

class Configuration
attr_accessor :api_key
attr_accessor :api_endpoint
attr_accessor :sandbox

attr_accessor :track_opens
attr_accessor :track_clicks

attr_accessor :campaign_id
attr_accessor :return_path

attr_accessor :transactional
attr_accessor :ip_pool
attr_accessor :inline_css
attr_accessor :html_content_only

attr_accessor :subaccount
attr_accessor :api_key, :api_endpoint, :sandbox, :track_opens, :track_clicks, :campaign_id, :return_path,
:transactional, :ip_pool, :inline_css, :html_content_only, :subaccount

def initialize
set_defaults
end

def set_defaults
if ENV.has_key?("SPARKPOST_API_KEY")
@api_key = ENV["SPARKPOST_API_KEY"]
else
@api_key = ""
end
@api_key = if ENV.key?('SPARKPOST_API_KEY')
ENV['SPARKPOST_API_KEY']
else
''
end

@api_endpoint = "https://api.sparkpost.com/api/"
@api_endpoint = 'https://api.sparkpost.com/api/'

@sandbox = false

Expand Down
34 changes: 16 additions & 18 deletions lib/sparkpost_rails/data_options.rb
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
module SparkPostRails
module DataOptions
# frozen_string_literal: true

def self.included(base)
base.class_eval do
prepend InstanceMethods
end
module SparkPostRails
module DataOptions
def self.included(base)
base.class_eval do
prepend InstanceMethods
end
end

module InstanceMethods

def mail(headers={}, &block)
headers = headers.clone
sparkpost_data = headers.delete(:sparkpost_data)
sparkpost_data ||= {}
super(headers, &block).tap do |message|
message.singleton_class.class_eval { attr_accessor "sparkpost_data" }
message.sparkpost_data = sparkpost_data
end
module InstanceMethods
def mail(headers = {}, &)
headers = headers.clone
sparkpost_data = headers.delete(:sparkpost_data)
sparkpost_data ||= {}
super(headers, &).tap do |message|
message.singleton_class.class_eval { attr_accessor 'sparkpost_data' }
message.sparkpost_data = sparkpost_data
end

end

end
end
end
Loading