Skip to content
Merged
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
12 changes: 2 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@

source 'https://rubygems.org'

git_source(:github) {|repo| "https://github.com/#{repo}.git" }

gemspec

# Development gems
#
gem 'appraisal'
gem 'json', '~> 2.1'
gem 'rake'
gem 'rspec', '~> 3.6'
gem 'rspec-collection_matchers'
Expand All @@ -20,17 +17,12 @@ gem 'rake-release', '~> 1.0'

# Doc
group :development do
gem 'redcarpet', platform: :ruby
gem 'yard', '~> 0.9.24'

gem 'rubocop-config', github: 'jgraichen/rubocop-config', tag: 'v14'
end

group :test do
gem 'msgpack', '~> 1.1'
gem 'pry'
gem 'pry-byebug'

gem 'simplecov'
gem 'simplecov-cobertura'
gem 'simplecov', require: false
gem 'simplecov-cobertura', require: false
end
2 changes: 1 addition & 1 deletion acfs.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'actionpack', '>= 7.0'
spec.add_dependency 'activemodel', '>= 7.0'
spec.add_dependency 'activesupport', '>= 7.0'
spec.add_dependency 'multi_json', '~> 1.0'
spec.add_dependency 'multi_json', '~> 1.21'
spec.add_dependency 'opentelemetry-api', '~> 1.0'
spec.add_dependency 'opentelemetry-common'
spec.add_dependency 'rack'
Expand Down
11 changes: 3 additions & 8 deletions gemfiles/rails_7.2.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
source "https://rubygems.org"

gem "appraisal"
gem "json", "~> 2.1"
gem "rake"
gem "rspec", "~> 3.6"
gem "rspec-collection_matchers"
Expand All @@ -16,17 +15,13 @@ gem "actionpack", "~> 7.2.0"
gem "railties", "~> 7.2.0", require: "rails"

group :development do
gem "redcarpet", platform: :ruby
gem "yard", "~> 0.9.24"
gem "rubocop-config", tag: "v14", git: "https://github.com/jgraichen/rubocop-config.git"
gem "rubocop-config", github: "jgraichen/rubocop-config", tag: "v14"
end

group :test do
gem "msgpack", "~> 1.1"
gem "pry"
gem "pry-byebug"
gem "simplecov"
gem "simplecov-cobertura"
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
end

gemspec path: "../"
11 changes: 3 additions & 8 deletions gemfiles/rails_8.0.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
source "https://rubygems.org"

gem "appraisal"
gem "json", "~> 2.1"
gem "rake"
gem "rspec", "~> 3.6"
gem "rspec-collection_matchers"
Expand All @@ -16,17 +15,13 @@ gem "actionpack", "~> 8.0.0"
gem "railties", "~> 8.0.0", require: "rails"

group :development do
gem "redcarpet", platform: :ruby
gem "yard", "~> 0.9.24"
gem "rubocop-config", tag: "v14", git: "https://github.com/jgraichen/rubocop-config.git"
gem "rubocop-config", github: "jgraichen/rubocop-config", tag: "v14"
end

group :test do
gem "msgpack", "~> 1.1"
gem "pry"
gem "pry-byebug"
gem "simplecov"
gem "simplecov-cobertura"
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
end

gemspec path: "../"
11 changes: 3 additions & 8 deletions gemfiles/rails_8.1.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
source "https://rubygems.org"

gem "appraisal"
gem "json", "~> 2.1"
gem "rake"
gem "rspec", "~> 3.6"
gem "rspec-collection_matchers"
Expand All @@ -16,17 +15,13 @@ gem "actionpack", "~> 8.1.0"
gem "railties", "~> 8.1.0", require: "rails"

group :development do
gem "redcarpet", platform: :ruby
gem "yard", "~> 0.9.24"
gem "rubocop-config", tag: "v14", git: "https://github.com/jgraichen/rubocop-config.git"
gem "rubocop-config", github: "jgraichen/rubocop-config", tag: "v14"
end

group :test do
gem "msgpack", "~> 1.1"
gem "pry"
gem "pry-byebug"
gem "simplecov"
gem "simplecov-cobertura"
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
end

gemspec path: "../"
19 changes: 7 additions & 12 deletions gemfiles/rails_master.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,25 @@
source "https://rubygems.org"

gem "appraisal"
gem "json", "~> 2.1"
gem "rake"
gem "rspec", "~> 3.6"
gem "rspec-collection_matchers"
gem "rspec-its"
gem "webmock", "~> 3.0"
gem "rake-release", "~> 1.0"
gem "activesupport", git: "https://github.com/rails/rails.git"
gem "activemodel", git: "https://github.com/rails/rails.git"
gem "actionpack", git: "https://github.com/rails/rails.git"
gem "railties", require: "rails", git: "https://github.com/rails/rails.git"
gem "activesupport", github: "rails/rails"
gem "activemodel", github: "rails/rails"
gem "actionpack", github: "rails/rails"
gem "railties", github: "rails/rails", require: "rails"

group :development do
gem "redcarpet", platform: :ruby
gem "yard", "~> 0.9.24"
gem "rubocop-config", tag: "v14", git: "https://github.com/jgraichen/rubocop-config.git"
gem "rubocop-config", github: "jgraichen/rubocop-config", tag: "v14"
end

group :test do
gem "msgpack", "~> 1.1"
gem "pry"
gem "pry-byebug"
gem "simplecov"
gem "simplecov-cobertura"
gem "simplecov", require: false
gem "simplecov-cobertura", require: false
end

gemspec path: "../"
5 changes: 1 addition & 4 deletions lib/acfs.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# frozen_string_literal: true

require 'active_support'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/class'
require 'active_support/core_ext/string'
require 'active_support/core_ext/module'
require 'active_support/core_ext'
require 'active_support/notifications'

require 'opentelemetry'
Expand Down
6 changes: 3 additions & 3 deletions lib/acfs/middleware/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ def mime
end

def encode(data)
::MultiJson.dump(data)
::MultiJSON.generate(data)
end

def decode(body)
::MultiJson.load(body)
rescue ::MultiJson::ParseError => e
::MultiJSON.parse(body)
rescue ::MultiJSON::ParseError => e
raise ::JSON::ParserError.new(e)
end
end
Expand Down
16 changes: 16 additions & 0 deletions spec/acfs/middleware/json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,28 @@
end
end

context 'with #as_json objects' do
let(:data) do
Class.new do
def as_json(*)
{a: 1, b: 3}
end
end.new
end

it 'serializes data with #as_json' do
expect(JSON.parse(request.body)).to eq 'a' => 1, 'b' => 3
end
end

context 'with #to_json objects' do
let(:data) do
Class.new do
def to_json(*)
'{"a": 1, "b": 2}'
end

undef as_json
end.new
end

Expand Down