From d9eb895c1f9adc275de8381bb5c0505e84195dc8 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Fri, 15 Jul 2022 18:14:34 -0300 Subject: [PATCH] pull-english: improve --- bin/json/pull-english | 12 ++++++++---- binlib/io/line.rb | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/json/pull-english b/bin/json/pull-english index 4769129..c29ed31 100755 --- a/bin/json/pull-english +++ b/bin/json/pull-english @@ -43,17 +43,21 @@ http.use_ssl = true 1.upto(114) do |chapter| rows = [] vcount = vmap[chapter.to_s] + line.rewind.print("Download chapter #{chapter}:").end 1.upto(vcount) do |verse| - line.rewind.print("Download: #{verse}/#{vcount}") + line.rewind.print("#{verse} of #{vcount} verses downloaded. ") res = http.request_get("/#{chapter}/#{verse}") if Net::HTTPOK === res rows.push([verse, find_content.(res)]) else - line.end.print(Paint["Error: ", :red, :bold], res.class).end + line.end.print(Paint["ABORT", :red, :bold]) + .end.print("Bad response: ", res.class) + .end exit(1) end - sleep delay + sleep(delay) end File.write(format(dest, chapter:), JSON.pretty_generate(rows)) - line.end.print(Paint["OK", :green, :bold]).end + line.end.print(Paint["Done.", :bold]) + .end.end end diff --git a/binlib/io/line.rb b/binlib/io/line.rb index 50fcb9d..9c19845 100644 --- a/binlib/io/line.rb +++ b/binlib/io/line.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true class IO::Line require "io/console" + attr_reader :io def initialize(io)