Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.2
4.0.2
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## [0.4.12] - 2026-02-09

### Changed
- Upgraded to Ruby 4.0.2 compatibility
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we specify which versions of Ruby are supported now?

- Upgraded Faraday from 1.x to 2.14.1 for Ruby 4.0+ support
- Upgraded Vertebrae from 0.8.0 to 1.0.5
- Upgraded Hashie from 3.6.0 to 5.1.0
Comment thread
ehimen-io marked this conversation as resolved.
- Removed juwelier dependency in favor of standard Bundler gem tasks
- Updated Faraday middleware to use Faraday 2.x API

## [0.4.11] - 2025-10-27

### Bugfixes
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Comment thread
ehimen-io marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

source 'http://rubygems.org'
source 'https://rubygems.org'

gem 'vertebrae', '>= 0.6.0'
Comment thread
ehimen-io marked this conversation as resolved.
Outdated

Expand All @@ -10,7 +10,7 @@ group :development do
gem 'em-http-request', '>=1.1.5', '<2.0'
gem 'em-synchrony', '>=1.0.6', '<2.0'
gem 'eventmachine', '>=1.2.5', '<2.0'
gem 'juwelier', git: 'https://github.com/flajann2/juwelier.git'
gem 'rake'
gem 'rspec', '~> 3.7'
gem 'rubocop'
gem 'webmock', '~> 3.3'
Expand Down
42 changes: 4 additions & 38 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,13 @@
# 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 './lib/action_kit_rest/version'

require 'juwelier'
Juwelier::Tasks.new do |gem|
gem.name = 'action_kit_rest'
gem.version = ActionKitRest::VERSION::STRING
gem.homepage = 'http://github.com/controlshift/action_kit_rest'
gem.license = 'MIT'
gem.summary = %(A wrapper for the ActionKit REST API)
gem.description = %(Gem for interacting with the ActionKit API)
gem.email = 'systems@controlshiftlabs.com'
gem.authors = ['Nathan Woodhull', 'Diego Marcet', 'Grey Moore']
# dependencies defined in Gemfile
end
Juwelier::RubygemsDotOrgTasks.new

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

desc 'Default: run specs.'
task default: :spec

desc 'Run specs'
RSpec::Core::RakeTask.new do |t|
t.pattern = './spec/**/*_spec.rb' # don't need this, it's default.
RSpec::Core::RakeTask.new(:spec) do |t|
t.pattern = './spec/**/*_spec.rb'
t.rspec_opts = '--color'
end

require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ''

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "action_kit_rest #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end
144 changes: 39 additions & 105 deletions action_kit_rest.gemspec
Original file line number Diff line number Diff line change
@@ -1,111 +1,45 @@
# Generated by juwelier
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: action_kit_rest 0.4.11 ruby lib
# frozen_string_literal: true

Gem::Specification.new do |s|
s.name = "action_kit_rest".freeze
s.version = "0.4.11"
require_relative "lib/action_kit_rest/version"

s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Nathan Woodhull".freeze, "Diego Marcet".freeze, "Grey Moore".freeze]
s.date = "2025-10-27"
s.description = "Gem for interacting with the ActionKit API".freeze
s.email = "systems@controlshiftlabs.com".freeze
s.extra_rdoc_files = [
"LICENSE.txt",
"README.md"
]
s.files = [
".document",
".github/workflows/ci.yml",
".rspec",
".rubocop.yml",
".ruby-gemset",
".ruby-version",
"CHANGELOG.md",
"Gemfile",
"LICENSE.txt",
"README.md",
"Rakefile",
"action_kit_rest.gemspec",
"lib/action_kit_rest.rb",
"lib/action_kit_rest/action.rb",
"lib/action_kit_rest/actions/event_create_action.rb",
"lib/action_kit_rest/actions/event_signup_action.rb",
"lib/action_kit_rest/actions/unsubscribe_action.rb",
"lib/action_kit_rest/allowed_user_field.rb",
"lib/action_kit_rest/api.rb",
"lib/action_kit_rest/base.rb",
"lib/action_kit_rest/client.rb",
"lib/action_kit_rest/event.rb",
"lib/action_kit_rest/event_signup.rb",
"lib/action_kit_rest/language.rb",
"lib/action_kit_rest/list.rb",
"lib/action_kit_rest/page.rb",
"lib/action_kit_rest/pages/base.rb",
"lib/action_kit_rest/pages/donation_page.rb",
"lib/action_kit_rest/pages/event_campaign_page.rb",
"lib/action_kit_rest/pages/import_page.rb",
"lib/action_kit_rest/pages/signup_page.rb",
"lib/action_kit_rest/pages/unsubscribe_page.rb",
"lib/action_kit_rest/phone.rb",
"lib/action_kit_rest/railties.rb",
"lib/action_kit_rest/response/collection.rb",
"lib/action_kit_rest/response/raise_error.rb",
"lib/action_kit_rest/response/validation_error.rb",
"lib/action_kit_rest/response/wrapper.rb",
"lib/action_kit_rest/tag.rb",
"lib/action_kit_rest/user.rb",
"lib/action_kit_rest/version.rb",
"spec/fixtures/action/event_create_action.json",
"spec/fixtures/action/event_signup_action.json",
"spec/fixtures/allowed_user_field/get.json",
"spec/fixtures/allowed_user_field/list.json",
"spec/fixtures/allowed_user_field/list_filtered.json",
"spec/fixtures/error.json",
"spec/fixtures/page/campaign.json",
"spec/fixtures/page/collection.json",
"spec/fixtures/page/find_campaign.json",
"spec/fixtures/page/find_event_create.json",
"spec/fixtures/page/find_event_signup.json",
"spec/fixtures/page/object.json",
"spec/fixtures/phone/object.json",
"spec/fixtures/user/object_with_phones.json",
"spec/fixtures/user/object_without_phones.json",
"spec/lib/action_kit_rest/actions/event_create_action_spec.rb",
"spec/lib/action_kit_rest/actions/event_signup_action_spec.rb",
"spec/lib/action_kit_rest/allowed_user_field_spec.rb",
"spec/lib/action_kit_rest/api_spec.rb",
"spec/lib/action_kit_rest/logger_spec.rb",
"spec/lib/action_kit_rest/page_spec.rb",
"spec/lib/action_kit_rest/pages/event_campaign_page_spec.rb",
"spec/lib/action_kit_rest/pages/import_page_spec.rb",
"spec/lib/action_kit_rest/response/collection_spec.rb",
"spec/lib/action_kit_rest/response/validation_error_spec.rb",
"spec/lib/action_kit_rest/response/wrapper_spec.rb",
"spec/lib/action_kit_rest/user_spec.rb",
"spec/spec_helper.rb",
"spec/support/shared_contexts/stub_logger.rb"
]
s.homepage = "http://github.com/controlshift/action_kit_rest".freeze
s.licenses = ["MIT".freeze]
s.rubygems_version = "3.4.10".freeze
s.summary = "A wrapper for the ActionKit REST API".freeze
Gem::Specification.new do |spec|
spec.name = "action_kit_rest"
spec.version = ActionKitRest::VERSION::STRING
spec.authors = ["Nathan Woodhull", "Diego Marcet", "Grey Moore"]
Comment thread
ehimen-io marked this conversation as resolved.
Outdated
spec.email = ["systems@controlshiftlabs.com"]

s.specification_version = 4
spec.summary = "A wrapper for the ActionKit REST API"
spec.description = "Gem for interacting with the ActionKit API"
spec.homepage = "https://github.com/controlshift/action_kit_rest"
spec.license = "MIT"
spec.required_ruby_version = ">= 3.0.0"
Comment thread
ehimen-io marked this conversation as resolved.

s.add_runtime_dependency(%q<vertebrae>.freeze, [">= 0.6.0"])
s.add_development_dependency(%q<bundler>.freeze, [">= 2.0", "< 3.0"])
s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
s.add_development_dependency(%q<em-http-request>.freeze, [">= 1.1.5", "< 2.0"])
s.add_development_dependency(%q<em-synchrony>.freeze, [">= 1.0.6", "< 2.0"])
s.add_development_dependency(%q<eventmachine>.freeze, [">= 1.2.5", "< 2.0"])
s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.7"])
s.add_development_dependency(%q<rubocop>.freeze, [">= 0"])
s.add_development_dependency(%q<webmock>.freeze, ["~> 3.3"])
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
Comment thread
ehimen-io marked this conversation as resolved.
Outdated
Comment thread
ehimen-io marked this conversation as resolved.
Outdated

# 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.
spec.files = Dir.chdir(__dir__) do
Comment thread
ehimen-io marked this conversation as resolved.
`git ls-files -z`.split("\x0").reject do |f|
(File.expand_path(f) == __FILE__) ||
f.start_with?(*%w[bin/ spec/ .git .github .document .idea coverage/])
end
end
spec.require_paths = ["lib"]
Comment thread
ehimen-io marked this conversation as resolved.
Outdated

# Runtime dependencies
spec.add_dependency "vertebrae", ">= 0.6.0"
Comment thread
ehimen-io marked this conversation as resolved.
Outdated

# Development dependencies
spec.add_development_dependency "bundler", ">= 2.0", "< 3.0"
spec.add_development_dependency "byebug"
spec.add_development_dependency "em-http-request", ">= 1.1.5", "< 2.0"
spec.add_development_dependency "em-synchrony", ">= 1.0.6", "< 2.0"
spec.add_development_dependency "eventmachine", ">= 1.2.5", "< 2.0"
spec.add_development_dependency "rake"
Comment thread
ehimen-io marked this conversation as resolved.
spec.add_development_dependency "rspec", "~> 3.7"
spec.add_development_dependency "rubocop"
spec.add_development_dependency "webmock", "~> 3.3"
end

33 changes: 23 additions & 10 deletions lib/action_kit_rest/api.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require 'faraday/mashify'
Comment thread
ehimen-io marked this conversation as resolved.
Outdated

module ActionKitRest
class API < Vertebrae::API
def request(*args)
Expand Down Expand Up @@ -35,21 +37,32 @@ def default_options
end

def setup
connection.stack do |builder|
builder.use Faraday::Request::Multipart
builder.use Faraday::Request::UrlEncoded
# Override the faraday connection to use ActionKitRest's custom error handler
connection.faraday_connection = Faraday.new(connection.configuration.faraday_options) do |f|
if connection.configuration.authenticated?
builder.use Faraday::Request::BasicAuthentication, connection.configuration.username,
connection.configuration.password
f.request :authorization, :basic, connection.configuration.username, connection.configuration.password
end
f.request :multipart
f.request :url_encoded
Comment thread
ehimen-io marked this conversation as resolved.

builder.use Faraday::Response::Logger if ENV['DEBUG']
f.response :logger if ENV['DEBUG']

builder.use FaradayMiddleware::Mashify
builder.use FaradayMiddleware::ParseJson
unless initialisation_options[:raw]
f.response :mashify
f.response :json
end

builder.use ActionKitRest::Response::RaiseError
builder.adapter connection.configuration.adapter
f.use ActionKitRest::Response::RaiseError

# Handle adapter registration - some adapters need to be required separately in Faraday 2.x
adapter_name = connection.configuration.adapter
begin
f.adapter adapter_name
rescue Faraday::Error => e
# Fall back to default adapter if the requested one isn't available
warn "Adapter #{adapter_name} not available (#{e.message}), falling back to default"
f.adapter Faraday.default_adapter
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/action_kit_rest/response/raise_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module ActionKitRest
module Response
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
Expand Down
2 changes: 1 addition & 1 deletion lib/action_kit_rest/response/wrapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Wrapper

attr_reader :response, :kind, :obj

def_delegators :body, :empty?, :size, :include?, :length, :to_a, :first, :flatten, :include?, :keys, :[]
Comment thread
ehimen-io marked this conversation as resolved.
def_delegators :body, :empty?, :size, :include?, :length, :to_a, :first, :flatten, :keys

def initialize(response)
@response = response
Expand Down
2 changes: 1 addition & 1 deletion lib/action_kit_rest/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get(id)
# (user.phones attribute includes the path for associated phones, not the data itself)
if user.id.present? && user.phones.any?
phones_list = client.phone.list(user: user.id)
user.obj.phones = phones_list.obj.to_a
user.obj.phones = phones_list.collection? ? phones_list.obj.to_a : phones_list.obj
Comment thread
ehimen-io marked this conversation as resolved.
Outdated
end

user
Expand Down
2 changes: 1 addition & 1 deletion lib/action_kit_rest/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module ActionKitRest
module VERSION
MAJOR = 0
MINOR = 4
PATCH = 11
PATCH = 12
Comment thread
ehimen-io marked this conversation as resolved.
Outdated
BUILD = nil

STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/action_kit_rest/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
let(:phone_body) { fixture('phone/object.json') }

it 'should include phones' do
stub_get('phone/?user=1').to_return(body: phone_body, status: 200)
stub_get('phone/?user=1').to_return(body: phone_body, status: 200,
headers: { content_type: 'application/json; charset=utf-8' })
expect(subject.user.get(1).phones.count).to eq 3
expect(subject.user.get(1).phones.map(&:phone)).to match_array(%w[7755555555 7755555577 310-310-3310])
end
Expand Down