diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02625de..01b7919 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,32 +4,22 @@ on: [push] jobs: test: runs-on: ubuntu-latest - strategy: matrix: - ruby-version: ['3.1', '3.2'] - + ruby-version: ['3.3', '3.4', '4.0'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true - - run: bundle install - run: bundle exec rspec - rubocop: runs-on: ubuntu-latest - - strategy: - matrix: - ruby-version: ['3.1', '3.2'] - steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby-version }} + ruby-version: '4.0' bundler-cache: true - - run: bundle install - run: bundle exec rubocop diff --git a/.ruby-version b/.ruby-version index 0aec50e..1454f6e 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.4 +4.0.1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 24e94a2..e4d9ce1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [1.1.0] - 2026-02-11 + +### BREAKING CHANGES +- Now requires Faraday 2.x (previously supported Faraday 1.x) +- Dropped support for Ruby versions older than 3.3. Officially supported versions are Ruby 3.3, 3.4, and 4.0. + ## [1.0.0] - 2023-10-17 ### BREAKING CHANGES diff --git a/README.md b/README.md index 500302b..fb43f53 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,11 @@ Client gem for the ENS API to Engaging Networks [![CI Status](https://github.com/controlshift/engaging-networks-rest/actions/workflows/ci.yml/badge.svg)](https://github.com/controlshift/engaging-networks-rest/actions/workflows/ci.yml) +## Requirements + +- Ruby 3.3, 3.4, or 4.0 +- Faraday ~> 2.0 + ## Install `gem install engaging-networks-rest` diff --git a/Rakefile b/Rakefile index 800b45d..82bb534 100644 --- a/Rakefile +++ b/Rakefile @@ -1,38 +1,8 @@ # frozen_string_literal: true -require 'rubygems' -require 'bundler' -begin - Bundler.setup(:default, :development) -rescue Bundler::BundlerError => e - warn e.message - warn 'Run `bundle install` to install missing gems' - exit e.status_code -end -require 'rake' - +require 'bundler/gem_tasks' require 'rspec/core/rake_task' -desc 'Run specs' -RSpec::Core::RakeTask.new do |t| - t.pattern = './spec/**/*_spec.rb' # don't need this, it's default. - t.rspec_opts = '--color' -end -desc 'Code coverage detail' -task :simplecov do - ENV['COVERAGE'] = 'true' - Rake::Task['test'].execute -end +RSpec::Core::RakeTask.new(:spec) -desc 'Default: run specs' task default: :spec - -require 'rdoc/task' -Rake::RDocTask.new do |rdoc| - version = File.exist?('VERSION') ? File.read('VERSION') : '' - - rdoc.rdoc_dir = 'rdoc' - rdoc.title = "engaging-networks-rest #{version}" - rdoc.rdoc_files.include('README*') - rdoc.rdoc_files.include('lib/**/*.rb') -end diff --git a/VERSION b/VERSION index 3eefcb9..9084fa2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.0 +1.1.0 diff --git a/engaging-networks-rest.gemspec b/engaging-networks-rest.gemspec index 92ab13e..7cfeb35 100644 --- a/engaging-networks-rest.gemspec +++ b/engaging-networks-rest.gemspec @@ -1,42 +1,38 @@ # frozen_string_literal: true -Gem::Specification.new do |s| - s.name = "engaging-networks-rest".freeze - s.version = "1.0.0" - - s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib".freeze] - s.authors = ["Grey Moore".freeze] - s.date = "2023-10-17" - s.description = "Client gem for the ENS API to Engaging Networks".freeze - s.email = "systems@controlshiftlabs.com".freeze - s.extra_rdoc_files = [ - "LICENSE", - "LICENSE.txt", - "README.md" - ] - - # Specify which files should be added to the gem when it is released. - # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - s.files = Dir.chdir(File.expand_path(__dir__)) do +lib = File.expand_path('lib', __dir__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) + +Gem::Specification.new do |spec| + spec.name = 'engaging-networks-rest' + spec.version = File.read(File.expand_path('VERSION', __dir__)).strip + spec.authors = ['Grey Moore', 'Owens Ehimen', 'Diego Marcet'] + spec.email = ['talk@controlshiftlabs.com'] + + spec.summary = 'Client gem for the ENS API to Engaging Networks' + spec.description = 'Client gem for the ENS API to Engaging Networks' + spec.homepage = 'https://github.com/controlshift/engaging-networks-rest' + spec.license = 'MIT' + + spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } end + spec.require_paths = ['lib'] - s.homepage = 'https://github.com/controlshift/engaging-networks-rest'.freeze - s.licenses = ["MIT".freeze] - s.summary = "Client gem for the ENS API to Engaging Networks".freeze + spec.required_ruby_version = ['>= 3.3', '< 5.0'] - if s.respond_to? :specification_version then - s.specification_version = 4 - end + # Runtime dependencies + spec.add_runtime_dependency 'faraday', '~> 2.0' - s.add_runtime_dependency(%q.freeze, [">= 1.0"]) - s.add_runtime_dependency(%q.freeze, [">= 0"]) + # Development dependencies + spec.add_development_dependency 'bundler', '>= 2.0', '< 5.0' + spec.add_development_dependency 'debug', '~> 1.0' + spec.add_development_dependency 'faker', '~> 3.0' + spec.add_development_dependency 'faraday-detailed_logger', '~> 2.0' + spec.add_development_dependency 'rake', '~> 13.0' + spec.add_development_dependency 'rspec', '~> 3.0' + spec.add_development_dependency 'rubocop', '~> 1.0' + spec.add_development_dependency 'webmock', '~> 3.0' - s.add_development_dependency(%q.freeze, ["> 2.20.0"]) - s.add_development_dependency(%q.freeze, [">= 2.1.2"]) - s.add_development_dependency(%q.freeze, ["> 0"]) - s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, [">= 0"]) - s.add_development_dependency(%q.freeze, ["> 3.4"]) + spec.metadata['rubygems_mfa_required'] = 'true' end diff --git a/lib/engaging_networks_rest/client.rb b/lib/engaging_networks_rest/client.rb index acfdd2d..57fb749 100644 --- a/lib/engaging_networks_rest/client.rb +++ b/lib/engaging_networks_rest/client.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'faraday' -require 'faraday_middleware' require 'engaging_networks_rest/client/pages' require 'engaging_networks_rest/response/raise_error' @@ -53,11 +52,10 @@ def request(method:, path:, params: {}, body: {}) authenticate! unless authenticated? response = connection.send(method) do |req| - req.headers['Content-Type'] = 'application/json' req.path = path req.params = params req.headers['ens-auth-token'] = ens_auth_key - req.body = ::JSON.generate(body) unless body.empty? + req.body = body unless body.empty? end response.body diff --git a/lib/engaging_networks_rest/response/raise_error.rb b/lib/engaging_networks_rest/response/raise_error.rb index ad0952b..a38ce8e 100644 --- a/lib/engaging_networks_rest/response/raise_error.rb +++ b/lib/engaging_networks_rest/response/raise_error.rb @@ -8,7 +8,7 @@ class Unauthorized < StandardError; end class InternalError < StandardError; end - class RaiseError < Faraday::Response::Middleware + class RaiseError < Faraday::Middleware def on_complete(response) status_code = response[:status].to_i if (400...600).include? status_code diff --git a/spec/client/pages_spec.rb b/spec/client/pages_spec.rb index 53ea3ea..de62383 100644 --- a/spec/client/pages_spec.rb +++ b/spec/client/pages_spec.rb @@ -6,7 +6,8 @@ let(:host) { 'example.com' } let(:api_key) { 'abc-123' } let(:ens_auth_key) { 'tmp-auth-key-456' } - let(:standard_headers) { { 'Content-Type' => 'application/json', 'Ens-Auth-Token' => ens_auth_key } } + let(:standard_headers) { { 'Ens-Auth-Token' => ens_auth_key } } + let(:json_headers) { standard_headers.merge('Content-Type' => 'application/json') } subject { EngagingNetworksRest::Client.new(api_key:, host:) } @@ -77,7 +78,7 @@ stub_request(:post, page_req_url) .with(body: { 'txn1' => 'foo', 'txn2' => 'bar', 'suppressAutoResponder' => true, supporter: { 'lastName' => 'Smith', 'emailAddress' => email } }.to_json, - headers: standard_headers) + headers: json_headers) .to_return(status: '200', headers: { content_type: 'application/json; charset=utf-8' }, body: response.to_json) @@ -91,7 +92,7 @@ it 'should process the page request and return its ID' do stub_request(:post, page_req_url) - .with(body: { supporter: supporter_hash }.to_json, headers: standard_headers) + .with(body: { supporter: supporter_hash }.to_json, headers: json_headers) .to_return(status: '200', headers: { content_type: 'application/json; charset=utf-8' }, body: response.to_json) @@ -105,7 +106,7 @@ it 'should raise if response status is not SUCCESS' do stub_request(:post, page_req_url) - .with(body: { supporter: supporter_hash }.to_json, headers: standard_headers) + .with(body: { supporter: supporter_hash }.to_json, headers: json_headers) .to_return(status: '200', headers: { content_type: 'application/json; charset=utf-8' }, body: failure_response.to_json)