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 "nanoc"
require "ryo" require "ryo"
require "ryo/yaml" require "ryo/yaml"
require "ryo/json"
require_relative "nanoc/lib/utils" require_relative "nanoc/lib/utils"
include Utils include Utils

View file

@ -1,15 +1,13 @@
# frozen_string_literal: true # frozen_string_literal: true
namespace :t do namespace :t do
jsondir = File.join(dirs.content, "json")
desc "Generate /json/<locale>/<surahid>/info.json from surahs.json" desc "Generate /json/<locale>/<surahid>/info.json from surahs.json"
task :"surahs.json" do task :"surahs.json" do
require "json" surahs = Ryo.from_json(path: File.join(dirs.content, "json", "surahs.json"))
surahs = JSON.parse File.read(File.join(jsondir, "surahs.json")) Ryo.properties_of(surahs).each do |locale|
surahs.keys.each do |locale|
surahs[locale].each.with_index(1) do |surah, index| surahs[locale].each.with_index(1) do |surah, index|
target = File.join(jsondir, locale, index.to_s, "info.json") File.write File.join(dirs.content, "json", locale, index.to_s, "info.json"),
File.write(target, JSON.pretty_generate(surah)) JSON.pretty_generate(Ryo.table_of(surah, recursive: true))
end end
end end
end end