From 93e92850c52c807c30d6e981ed777e7626460979 Mon Sep 17 00:00:00 2001 From: Julian Scheid Date: Tue, 2 May 2023 14:16:47 +0200 Subject: [PATCH] Compatibility with ActiveSupport Closes #2 --- Gemfile | 1 + lib/json/canonicalization.rb | 7 +++---- spec/spec_helper.rb | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 697b11a..da9c0df 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ group :development, :test do gem 'simplecov-lcov', '~> 0.8', platforms: :mri gem 'benchmark-ips' gem 'rake' + gem 'activesupport' end group :debug do diff --git a/lib/json/canonicalization.rb b/lib/json/canonicalization.rb index e972eaf..e8ec97f 100644 --- a/lib/json/canonicalization.rb +++ b/lib/json/canonicalization.rb @@ -15,7 +15,7 @@ class Object # Default canonicalization output for Ruby objects # @return [String] def to_json_c14n - self.to_json + ::JSON.generate(self) end end @@ -86,7 +86,7 @@ class String # Output JSON with control characters escaped # @return [String] def to_json_c14n - self.to_json + ::JSON.generate(self) end end @@ -94,7 +94,6 @@ class Symbol # Output JSON with control characters escaped # @return [String] def to_json_c14n - self.to_json + ::JSON.generate(self) end end - diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bbd5c8e..2e8a590 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,6 +2,8 @@ require "bundler/setup" require 'rspec' +require 'active_support' +require 'active_support/core_ext' begin require 'simplecov'