standardrb: fix.

This commit is contained in:
0x1eef 2022-04-26 15:26:17 -03:00
parent 39a37b6887
commit 9263c5366a
2 changed files with 23 additions and 27 deletions

View file

@ -35,7 +35,7 @@ end
def get_request(path, htm_file)
Net::HTTP::Get.new(
format(path, htm_file: htm_file),
'Accept' => 'text/html'
"Accept" => "text/html"
)
end
@ -43,14 +43,14 @@ end
# Helper method.
def extract_verses!(res, rows)
doc = Nokogiri::HTML(res.body)
verses = doc.css('table tr td p[align=RIGHT]')
verses = doc.css("table tr td p[align=RIGHT]")
verses.each do |verse|
verse_num = Integer(verse.css('a').inner_text)
verse_num = Integer(verse.css("a").inner_text)
verse_txt = verse.text.delete(verse_num.to_s)
rows.push([
verse_num,
verse_txt.gsub("\u200F", "").gsub("\u200E", "").strip
verse_txt.delete("\u200F").delete("\u200E").strip
])
end
end
@ -74,5 +74,3 @@ end
print Paint["Chill for #{cool_off} seconds", :blue, :bold], "\n", "\n"
sleep cool_off
end

View file

@ -24,7 +24,7 @@ http.use_ssl = true
def get_request(path, chapter_num, verse_num)
Net::HTTP::Get.new(
format(path, chapter_num:, verse_num:),
'Accept' => 'text/html'
"Accept" => "text/html"
)
end
@ -40,7 +40,7 @@ end
when Net::HTTPOK
doc = Nokogiri::HTML(res.body)
el = doc.css("div[class^='TranslationText']").last
text = el.text.gsub(/[0-9]/, '')
text = el.text.gsub(/[0-9]/, "")
rows.push([verse_num, text])
print Paint["OK: ", :green, :bold], text, "\n"
else
@ -52,5 +52,3 @@ end
File.write(final_dest, JSON.pretty_generate(rows))
print Paint["OK: ", :green, :bold], final_dest, "\n"
end