diff --git a/Rakefile.rb b/Rakefile.rb index 4e50421..8266499 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 0e23243..ecb93ba 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