al-quran.reflectslight.io/rake/tasks/t.rake

17 lines
522 B
Ruby
Raw Normal View History

2024-05-20 01:22:14 +02:00
# frozen_string_literal: true
namespace :t do
2024-05-20 01:46:37 +02:00
jsondir = File.join(Dir.getwd, "src", "json")
2024-05-20 01:22:14 +02:00
desc "Generate /json/<locale>/<surahid>/info.json from surahs.json"
task :"surahs.json" do
require "json"
2024-05-20 01:46:37 +02:00
surahs = JSON.parse File.read(File.join(jsondir, "surahs.json"))
2024-05-20 01:22:14 +02:00
surahs.keys.each do |locale|
surahs[locale].each.with_index(1) do |surah, index|
2024-05-20 01:46:37 +02:00
target = File.join(jsondir, locale, index.to_s, "info.json")
2024-05-20 01:22:14 +02:00
File.write(target, JSON.pretty_generate(surah))
end
end
end
end