diff --git a/Gemfile b/Gemfile index 26b7a2a..19bb945 100644 --- a/Gemfile +++ b/Gemfile @@ -4,3 +4,4 @@ gem "nokogiri", "~> 1.13" gem "paint", "~> 2.2" gem "json", "~> 2.6" gem "standard", "~> 1.12" +gem "io-line.rb", "~> 0.1", github: "0x1eef/io-line.rb", tag: "v0.1.0" diff --git a/bin/json/insert-chapter-metadata b/bin/json/insert-chapter-metadata index 93e6902..6c4e704 100755 --- a/bin/json/insert-chapter-metadata +++ b/bin/json/insert-chapter-metadata @@ -19,7 +19,7 @@ Process.setproctitle("quran-pull (insert-chapter-metadata)") require "bundler/setup" require "json" require "paint" -require_relative "../../binlib/io/line" +require "io/line" ## # Utils diff --git a/bin/json/insert-chapters-data b/bin/json/insert-chapters-data index b2470e0..4d1463f 100755 --- a/bin/json/insert-chapters-data +++ b/bin/json/insert-chapters-data @@ -15,7 +15,7 @@ Process.setproctitle("quran-pull (pull-chapters-data)") require "bundler/setup" require "json" require "paint" -require_relative "../../binlib/io/line" +require "io/line" ## # Utils diff --git a/bin/json/private/al-quran b/bin/json/private/al-quran index 8df171b..4f51a8e 100755 --- a/bin/json/private/al-quran +++ b/bin/json/private/al-quran @@ -22,7 +22,7 @@ require "nokogiri" require "json" require "paint" require "fileutils" -require_relative "../../../binlib/io/line" +require "io/line" ## # Configuration variables diff --git a/bin/json/pull-arabic b/bin/json/pull-arabic index 8ccc151..9543d5c 100755 --- a/bin/json/pull-arabic +++ b/bin/json/pull-arabic @@ -20,7 +20,7 @@ require "net/http" require "nokogiri" require "json" require "paint" -require_relative "../../binlib/io/line" +require "io/line" ## # Configuration variables. diff --git a/bin/json/pull-english b/bin/json/pull-english index 217889a..a7269f9 100755 --- a/bin/json/pull-english +++ b/bin/json/pull-english @@ -20,7 +20,7 @@ require "net/http" require "nokogiri" require "json" require "paint" -require_relative "../../binlib/io/line" +require_relative "io/line" ## # Configuration variables. diff --git a/binlib/io/line.rb b/binlib/io/line.rb deleted file mode 100644 index 31ee0aa..0000000 --- a/binlib/io/line.rb +++ /dev/null @@ -1,25 +0,0 @@ -# frozen_string_literal: true - -class IO::Line - require "io/console" - attr_reader :io - - def initialize(io) - @io = io - end - - def print(*strs) - tap { @io.print(strs.join.gsub($/, "")) } - end - - def end - tap { @io.print($/) } - end - - def rewind - tap do - @io.erase_line(2) - @io.goto_column(0) - end - end -end diff --git a/binlib/io/line/multiple.rb b/binlib/io/line/multiple.rb deleted file mode 100644 index 7305189..0000000 --- a/binlib/io/line/multiple.rb +++ /dev/null @@ -1,19 +0,0 @@ -# frozen_string_literal: true - -class IO::Line::Multiple - def initialize(lines, cursor) - @lines = lines - @cursor = cursor - end - - def print(*strs, lineno:) - line = @lines[lineno] - if lineno > @cursor - line.io.cursor_down(lineno - @cursor) - elsif lineno < @cursor - line.io.cursor_up(lineno + @cursor) - end - @cursor = lineno - line.rewind.print(*strs) - end -end