Update t.rake

This commit is contained in:
0x1eef 2024-06-22 00:04:27 -03:00
parent c0c3d7b8ec
commit 0601e0caa4
2 changed files with 5 additions and 6 deletions

View file

@ -4,6 +4,7 @@ require "bundler/setup"
require "nanoc"
require "ryo"
require "ryo/yaml"
require "ryo/json"
require_relative "nanoc/lib/utils"
include Utils

View file

@ -1,15 +1,13 @@
# frozen_string_literal: true
namespace :t do
jsondir = File.join(dirs.content, "json")
desc "Generate /json/<locale>/<surahid>/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