diff --git a/bin/quran-json b/bin/quran-json index a3c9b31..4421660 100755 --- a/bin/quran-json +++ b/bin/quran-json @@ -25,9 +25,9 @@ def main(argv) case argv[0] when "pull" - options = Quran::JSON::Pull.cli(argv[1..]) + cli = Quran::JSON::Pull.cli(argv[1..]) sources.each do |locale, source| - case options.locale + case cli.locale when locale wait spawn(libexec_dir, source["http"]["hostname"], *argv[1..]) end diff --git a/libexec/quran-json/quran.com b/libexec/quran-json/quran.com index beae4ae..7e66c75 100755 --- a/libexec/quran-json/quran.com +++ b/libexec/quran-json/quran.com @@ -4,16 +4,24 @@ require File.join(lib_dir, "quran", "json") require "optparse" require "nokogiri" +## +# Grep for ayah content def grep(res) html = Nokogiri::HTML(res.body) el = html.css("div[class^='TranslationText']").last el.text.gsub(/[0-9]/, "") end +## +# CLI parser +def parse_cli(argv) + Quran::JSON::Pull.cli(argv) +end + ## # main def main(argv) - cmd = Quran::JSON::Pull.new(Quran::JSON::Pull.cli(argv)) + cmd = Quran::JSON::Pull.new parse_cli(argv) cmd.keepalive do 1.upto(114) do |surah_no| if cmd.keep?(surah_no) diff --git a/libexec/quran-json/www.searchtruth.com b/libexec/quran-json/www.searchtruth.com index 94ee3a7..b6ac15c 100755 --- a/libexec/quran-json/www.searchtruth.com +++ b/libexec/quran-json/www.searchtruth.com @@ -4,6 +4,8 @@ require File.join(lib_dir, "quran", "json") require "optparse" require "nokogiri" +## +# Grep for ayah content def grep(res) sel = "table[dir='ltr'] tr td div:last-child, " \ "table[dir='rtl'] tr td div:last-child" @@ -11,10 +13,16 @@ def grep(res) html.css(sel).map { _1.text.strip.gsub(/^[0-9]+\.\s*/, "") } end +## +# CLI parser +def parse_cli(argv) + Quran::JSON::Pull.cli(argv) +end + ## # main def main(argv) - cmd = Quran::JSON::Pull.new(Quran::JSON::Pull.cli(argv)) + cmd = Quran::JSON::Pull.new parse_cli(argv) cmd.keepalive do 1.upto(114) do |surah_no| if cmd.keep?(surah_no)