Update t.rake
This commit is contained in:
parent
c0c3d7b8ec
commit
0601e0caa4
2 changed files with 5 additions and 6 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue