From 0601e0caa49be80b3ce91ee9e4217414955e980e Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sat, 22 Jun 2024 00:04:27 -0300 Subject: [PATCH] Update t.rake --- Rakefile.rb | 1 + rake/tasks/t.rake | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Rakefile.rb b/Rakefile.rb index 4e504213e..826649913 100644 --- a/Rakefile.rb +++ b/Rakefile.rb @@ -4,6 +4,7 @@ require "bundler/setup" require "nanoc" require "ryo" require "ryo/yaml" +require "ryo/json" require_relative "nanoc/lib/utils" include Utils diff --git a/rake/tasks/t.rake b/rake/tasks/t.rake index 0e2324390..ecb93badd 100644 --- a/rake/tasks/t.rake +++ b/rake/tasks/t.rake @@ -1,15 +1,13 @@ # frozen_string_literal: true namespace :t do - jsondir = File.join(dirs.content, "json") desc "Generate /json///info.json from surahs.json" task :"surahs.json" do - require "json" - surahs = JSON.parse File.read(File.join(jsondir, "surahs.json")) - surahs.keys.each do |locale| + surahs = Ryo.from_json(path: File.join(dirs.content, "json", "surahs.json")) + Ryo.properties_of(surahs).each do |locale| surahs[locale].each.with_index(1) do |surah, index| - target = File.join(jsondir, locale, index.to_s, "info.json") - File.write(target, JSON.pretty_generate(surah)) + File.write File.join(dirs.content, "json", locale, index.to_s, "info.json"), + JSON.pretty_generate(Ryo.table_of(surah, recursive: true)) end end end