From 316133c2350acd99960664091ed22e0eed106370 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Mon, 13 Feb 2023 02:28:57 -0300 Subject: [PATCH] Add `Pull#locale_dir` --- lib/quran-json/command.rb | 4 ++++ lib/quran-json/pull.rb | 7 +++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/quran-json/command.rb b/lib/quran-json/command.rb index 64f225e..ac2ddbd 100644 --- a/lib/quran-json/command.rb +++ b/lib/quran-json/command.rb @@ -19,6 +19,10 @@ module Command File.join(share_dir, "TheQuran") end + def locale_dir + File.join(share_dir, options.locale) + end + def line @line ||= IO::Line.new($stdout) end diff --git a/lib/quran-json/pull.rb b/lib/quran-json/pull.rb index faeaa5c..a7c310a 100644 --- a/lib/quran-json/pull.rb +++ b/lib/quran-json/pull.rb @@ -42,10 +42,9 @@ class Pull end def write(surah_no, rows) - dir = File.join(quran_dir, options.locale) - mkdir_p(dir) + mkdir_p(locale_dir) rows.unshift(Ryo.table_of(surah_info[surah_no - 1])) - File.binwrite File.join(dir, "#{surah_no}.json"), JSON.pretty_generate(rows) + File.binwrite File.join(locale_dir, "#{surah_no}.json"), JSON.pretty_generate(rows) end def keepalive @@ -69,7 +68,7 @@ class Pull end def exist?(surah_no) - File.exist? File.join(quran_dir, options.locale, "#{surah_no}.json") + File.exist? File.join(locale_dir, "#{surah_no}.json") end def headers