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
9 changes: 7 additions & 2 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ jobs:
tests:
env:
COV: true
BUNDLE_GEMFILE: "gemfiles/faraday_${{ matrix.faraday_version }}.gemfile"

runs-on: ubuntu-latest
name: Ruby ${{ matrix.ruby }} on Faraday ${{ matrix.faraday_version }}

strategy:
fail-fast: true
matrix:
# ruby: [2.5, 2.6, 2.7, jruby, truffleruby]
ruby: [2.5, 2.6, 2.7]

ruby: [2.5, 2.6, 2.7, "3.0", 3.1]
faraday_version: [1, 2]
exclude:
- ruby: 2.5
faraday_version: 2
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.config
.yardoc
Gemfile.lock
gemfiles/*.lock
InstalledFiles
_yardoc
coverage
Expand Down
8 changes: 7 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ inherit_gem:
- config/default.yml

AllCops:
TargetRubyVersion: 2.5'
TargetRubyVersion: 2.5
Exclude:
- 'gemfiles/**/*'
- '**/*.json'

Naming/VariableNumber:
Enabled: false

RSpec/MultipleMemoizedHelpers:
Enabled: false
11 changes: 0 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,7 @@ source 'https://rubygems.org'
gemspec

gem 'codeclimate-test-reporter'
gem 'factory_bot'
gem 'gem-release'
gem 'pry'
gem 'rake'
gem 'reek'
gem 'rspec'
gem 'rspec-json_expectations'
gem 'rubocop-mhenrixon'
gem 'simplecov'
gem 'simplecov-material'
gem 'vcr'
gem 'webmock'

platform :mri do
gem 'simplecov-oj'
Expand Down
17 changes: 16 additions & 1 deletion active_campaign.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/mhenrixon/active_campaign'
spec.license = 'MIT'

spec.required_ruby_version = '>= 2.5'

if spec.respond_to?(:metadata)
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/mhenrixon/rubocop-mhenrixon'
spec.metadata['changelog_uri'] = 'https://github.com/mhenrixon/rubocop-mhenrixon'
spec.metadata['rubygems_mfa_required'] = 'true'
else
raise 'RubyGems 2.0 or newer is required to protect against ' \
'public gem pushes.'
'public gem pushes.'
end

spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
Expand All @@ -32,4 +35,16 @@ Gem::Specification.new do |spec|
spec.add_dependency 'activesupport', '>= 4.0', '< 8.0'
spec.add_dependency 'faraday', '>= 1.0', '< 3.0'
spec.add_dependency 'oj', '>= 3.0', '< 4.0'

spec.add_development_dependency 'factory_bot', '~> 6'
spec.add_development_dependency 'pry', '~> 0.14'
spec.add_development_dependency 'rake', '~> 13'
spec.add_development_dependency 'reek', '~> 6'
spec.add_development_dependency 'rspec', '~> 3.11'
spec.add_development_dependency 'rspec-json_expectations', '~> 2.2'
spec.add_development_dependency 'rubocop-mhenrixon', '~> 1'
spec.add_development_dependency 'simplecov', '~> 0.21'
spec.add_development_dependency 'simplecov-material', '~> 1'
spec.add_development_dependency 'vcr', '~> 6'
spec.add_development_dependency 'webmock', '~> 3'
end
10 changes: 5 additions & 5 deletions bin/bundle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ m = Module.new do
update_index = nil
ARGV.each_with_index do |a, i|
bundler_version = a if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/o

bundler_version = Regexp.last_match(1)
update_index = i
Expand Down Expand Up @@ -57,7 +57,7 @@ m = Module.new do
return unless File.file?(lockfile)

lockfile_contents = File.read(lockfile)
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/o

Regexp.last_match(1)
end
Expand Down Expand Up @@ -88,7 +88,7 @@ m = Module.new do
activate_bundler
end

def activate_bundler # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
def activate_bundler # rubocop:disable Metrics/MethodLength
gem_error = activation_error_handling do
gem 'bundler', bundler_requirement
end
Expand All @@ -102,8 +102,8 @@ m = Module.new do
end

warn "Activating bundler (#{bundler_requirement})" \
" failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires," \
" run `gem install bundler -v '#{bundler_requirement}'`"
" failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires," \
" run `gem install bundler -v '#{bundler_requirement}'`"
exit 42
end

Expand Down
20 changes: 20 additions & 0 deletions gemfiles/faraday_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec path: '../'

gem 'codeclimate-test-reporter'
gem 'faraday', '~> 1'
gem 'gem-release'

platform :mri do
gem 'simplecov-oj'
end

if respond_to?(:install_if)
install_if -> { RUBY_PLATFORM.include? 'darwin' } do
gem 'fuubar'
gem 'rspec-nc'
end
end
20 changes: 20 additions & 0 deletions gemfiles/faraday_2.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec path: '../'

gem 'codeclimate-test-reporter'
gem 'faraday', '~> 2'
gem 'gem-release'

platform :mri do
gem 'simplecov-oj'
end

if respond_to?(:install_if)
install_if -> { RUBY_PLATFORM.include? 'darwin' } do
gem 'fuubar'
gem 'rspec-nc'
end
end
4 changes: 4 additions & 0 deletions lib/active_campaign.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def configure
yield config if block_given?
end

# rubocop:disable Lint/MissingSuper

# @private
def respond_to_missing?(method_name, include_private = false)
client.respond_to?(method_name, include_private)
Expand Down Expand Up @@ -106,4 +108,6 @@ def respond_to_missing?(method_name, include_private = false)
client.respond_to?(method_name, include_private)
end
end

# rubocop:enable Lint/MissingSuper
end
4 changes: 4 additions & 0 deletions lib/active_campaign/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def endpoint(endpoint)
raise DependencyMissing, endpoint
end

# rubocop:disable ThreadSafety/InstanceVariableInClassMethod

#
# Memoized logger for convenience
#
Expand All @@ -54,6 +56,8 @@ def endpoint(endpoint)
def logger
@logger ||= ActiveCampaign.logger
end

# rubocop:enable ThreadSafety/InstanceVariableInClassMethod
end
end
end
3 changes: 2 additions & 1 deletion lib/active_campaign/api/contacts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def sync_contact(params)
# Get a list of contacts
#
# @param [Hash] params
# @option params param [String] :ids Filter contacts by ID. Can be repeated for multiple IDs. Example: ids: [42, 43, 1]
# @option params param [String] :ids Filter contacts by ID. Can be repeated for multiple IDs.
# Example: ids: [42, 43, 1]
# @option params [Date] :datetime Contacts created on the specified date
# @option params [String] :email Email address of the contact you want to get
# @option params [String] :email_like Filter contacts that contain the given value in the email address
Expand Down
4 changes: 0 additions & 4 deletions lib/active_campaign/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ def safe_http_call # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
raise ProxyAuthError, e
rescue ::Faraday::ConflictError => e
raise ConflictError, e
rescue ::Faraday::UnauthorizedError => e
raise UnauthorizedError, e
rescue ::Faraday::UnprocessableEntityError => e
raise UnprocessableEntityError, e
rescue ::Faraday::ServerError => e
Expand All @@ -110,8 +108,6 @@ def safe_http_call # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
raise TimeoutError, e
rescue ::Faraday::NilStatusError => e
raise NilStatusError, e
rescue ::Faraday::ConnectionFailed => e
raise ConnectionFailed, e
rescue ::Faraday::SSLError => e
raise SSLError, e
end
Expand Down
2 changes: 1 addition & 1 deletion lib/active_campaign/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def initialize
self.api_timeout = 5
self.api_token = API_TOKEN
self.debug = false
self.logger = Logger.new(STDOUT)
self.logger = Logger.new($stdout)
@request_middleware = {}
@response_middleware = {}
end
Expand Down
2 changes: 2 additions & 0 deletions lib/active_campaign/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Error < RuntimeError
def initialize(response = nil, exception = nil)
self.response = response
@exception = exception
super
end

def message
Expand Down Expand Up @@ -56,6 +57,7 @@ def env
class ErrorProxy < RuntimeError
def initialize(error = nil)
self.error = error
super
end

def message
Expand Down
7 changes: 5 additions & 2 deletions lib/active_campaign/faraday/middleware/request.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# frozen_string_literal: true

require 'faraday'
require 'oj'

module ActiveCampaign
module Faraday
module Middleware
Expand All @@ -9,7 +12,7 @@ module Middleware
# @author Mikael Henriksson <mikael@mhenrixon.com>
#
class Request < ::Faraday::Middleware
dependency 'oj'
dependency 'oj' if respond_to?(:dependency)

include TransformHash

Expand Down Expand Up @@ -45,7 +48,7 @@ def normalize_body(env)
end

def logger
@logger ||= Logger.new(STDOUT)
@logger ||= Logger.new($stdout)
end
end
end
Expand Down
7 changes: 4 additions & 3 deletions lib/active_campaign/faraday/middleware/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

require 'logger'
require 'faraday/logging/formatter'
require 'oj'

module ActiveCampaign
LOGGER = ::Logger.new(STDOUT)
LOGGER = ::Logger.new($stdout)
module Faraday
module Middleware
#
# Gem specific response middleware for Faraday
#
# @author Mikael Henriksson <mikael@mhenrixon.com>
#
class Response < ::Faraday::Response::Middleware
dependency 'oj'
class Response < ::Faraday::Middleware
dependency 'oj' if respond_to?(:dependency)

include TransformHash

Expand Down
1 change: 1 addition & 0 deletions lib/active_campaign/transform_hash.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

require 'active_support'
require 'active_support/core_ext/string'

module ActiveCampaign
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_contexts/with_deal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
let(:deal_value) { 156.24 }
let(:deal_currency) { 'eur' }
let(:deal_group) { pipeline_id }
let(:deal_stage) {}
let(:deal_stage) { nil }
let(:deal_owner) { user_id }
let(:deal_percent) { 50 }
let(:deal_status) { 0 }
Expand Down