--- template.orig	2020-11-23 22:44:13.976004000 +0600
+++ template	2020-11-24 22:09:08.930216000 +0600
@@ -5,2 +5,4 @@ pkgname=ruby
 version=2.7.2
+# Liberation: Adds pure Ruby json version
+_jsonver=2.3.0
 revision=1
@@ -18,4 +20,7 @@ maintainer="Leah Neukirchen <leah@vuxu.o
 license="Ruby, BSD-2-Clause"
-distfiles="https://cache.ruby-lang.org/pub/ruby/${version%.*}/${pkgname}-${version}.tar.bz2"
-checksum=65a590313d244d48dc2ef9a9ad015dd8bc6faf821621bbb269aa7462829c75ed
+# Liberation: Adds pure Ruby json distfile
+distfiles="https://cache.ruby-lang.org/pub/ruby/${version%.*}/${pkgname}-${version}.tar.bz2
+ https://github.com/flori/json/archive/v${_jsonver}.tar.gz"
+checksum="65a590313d244d48dc2ef9a9ad015dd8bc6faf821621bbb269aa7462829c75ed
+ b8a7576b9b6dfb997d9b3911e13b2e5b1bde50ff1f5aea46b116c560649ec1a4"
 
@@ -55,2 +60,24 @@ post_patch() {
 	patch -sNp1 -i ${FILESDIR}/rubygems-avoid-platform-specific-gems.patch
+
+	# Liberation: Implement pure Ruby json
+	# Some codes are taken from:
+	# https://git.parabola.nu/abslibre.git/tree/libre/ruby/PKGBUILD
+	cd "${XBPS_BUILDDIR}/json-${_jsonver}"
+
+	# Modify 'json' so that it doesn't try to load (non-free!) 'json/ext'
+	echo "applying json-libre.patch to json"
+	rm -rf -- json.gemspec ext lib/json/ext*
+	patch -p1 -i "${FILESDIR}/json-libre.patch"
+
+	# Now remove the json ext from the ruby sources
+	cd "${XBPS_BUILDDIR}/${wrksrc}"
+	rm -r ext/json test/json
+
+	# and insert the json_pure lib instead
+	cp -r  ../json-${_jsonver}/lib/*             -t lib/
+	cp     ../json-${_jsonver}/json_pure.gemspec -t lib/json/
+	cp -rT ../json-${_jsonver}/tests                test/json
+
+	# Clean up the original json sources
+	rm -rf "{XBPS_BUILDDIR}/json-${_jsonver}"
 }
