Module: Fontist::Import::ImportDisplay
- Defined in:
- lib/fontist/import/import_display.rb
Overview
Unified progress display for all import commands
Provides consistent, professional Paint-colored output with emojis across Google, SIL, and macOS importers.
Class Method Summary collapse
-
.debug_info(message) ⇒ Object
Display debug/info message in gray bold (like macOS import).
-
.download_url(url) ⇒ Object
Display download URL.
-
.error(message) ⇒ Object
Display error message.
-
.following_link(text) ⇒ Object
Display “Following link…” message.
-
.format_duration(seconds) ⇒ String
Format duration in human-readable format.
-
.found_elements(count, selector) ⇒ Object
Display “Found N elements” message.
-
.header(source, details = {}, import_cache: nil) ⇒ Object
Display import header with Paint styling.
-
.info(message) ⇒ Object
Display info message.
-
.page_url(url) ⇒ Object
Display page URL being visited.
-
.progress(current, total, item, details: nil) ⇒ Object
Display progress update with Paint styling.
-
.section(title) ⇒ Object
Display section header.
-
.status_failed(message) ⇒ Object
Display failure status.
-
.status_overwrite(message) ⇒ Object
Display overwrite warning.
-
.status_skipped(message, tip: nil) ⇒ Object
Display skip status.
-
.status_success(message, details = "") ⇒ Object
Display success status.
-
.summary(results, options = {}) ⇒ Object
Display summary with Paint styling.
-
.warn(message) ⇒ Object
Display warning message.
Class Method Details
.debug_info(message) ⇒ Object
Display debug/info message in gray bold (like macOS import)
144 145 146 |
# File 'lib/fontist/import/import_display.rb', line 144 def self.debug_info() Fontist.ui.say(" #{Paint[, :black, :bright]}") end |
.download_url(url) ⇒ Object
Display download URL
158 159 160 161 |
# File 'lib/fontist/import/import_display.rb', line 158 def self.download_url(url) Fontist.ui.say(" #{Paint['📥', :green]} Download URL: #{Paint[url, :white]}") end |
.error(message) ⇒ Object
Display error message
130 131 132 |
# File 'lib/fontist/import/import_display.rb', line 130 def self.error() Fontist.ui.error("❌ #{}") end |
.following_link(text) ⇒ Object
Display “Following link…” message
166 167 168 |
# File 'lib/fontist/import/import_display.rb', line 166 def self.following_link(text) debug_info("Following #{text}...") end |
.format_duration(seconds) ⇒ String
Format duration in human-readable format
182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/fontist/import/import_display.rb', line 182 def self.format_duration(seconds) return "#{seconds.round(2)}s" if seconds < 60 minutes = (seconds / 60).floor remaining = (seconds % 60).round(2) if minutes < 60 "#{minutes}m #{remaining}s" else hours = (minutes / 60).floor remaining_minutes = minutes % 60 "#{hours}h #{remaining_minutes}m #{remaining.round}s" end end |
.found_elements(count, selector) ⇒ Object
Display “Found N elements” message
174 175 176 |
# File 'lib/fontist/import/import_display.rb', line 174 def self.found_elements(count, selector) debug_info("Found #{count} '#{selector}' elements") if count.positive? end |
.header(source, details = {}, import_cache: nil) ⇒ Object
Display import header with Paint styling
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fontist/import/import_display.rb', line 15 def self.header(source, details = {}, import_cache: nil) Fontist.ui.say("") Fontist.ui.say(Paint["═" * 80, :cyan]) Fontist.ui.say(Paint[" 📦 #{source} Import", :cyan, :bright]) Fontist.ui.say(Paint["═" * 80, :cyan]) Fontist.ui.say("") # Show import cache if provided if import_cache cache_path = import_cache.is_a?(Pathname) ? import_cache.to_s : import_cache.to_s Fontist.ui.say("📦 Import cache: #{Paint[cache_path, :white]}") end # Show other details details.each do |key, value| next unless value label = key.to_s.split("_").map(&:capitalize).join(" ") Fontist.ui.say("📁 #{label}: #{Paint[value.to_s, :white]}") end Fontist.ui.say("") end |
.info(message) ⇒ Object
Display info message
123 124 125 |
# File 'lib/fontist/import/import_display.rb', line 123 def self.info() Fontist.ui.say(" ℹ️ #{}") end |
.page_url(url) ⇒ Object
Display page URL being visited
151 152 153 |
# File 'lib/fontist/import/import_display.rb', line 151 def self.page_url(url) Fontist.ui.say(" #{Paint['🔗', :blue]} Page URL: #{Paint[url, :white]}") end |
.progress(current, total, item, details: nil) ⇒ Object
Display progress update with Paint styling
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/fontist/import/import_display.rb', line 45 def self.progress(current, total, item, details: nil) progress_text = "(#{current}/#{total})" percentage = ((current.to_f / total) * 100).round(1) line = "#{Paint[progress_text, :white]} " \ "#{Paint["#{percentage}%", :yellow]} | " \ "#{Paint[item, :cyan, :bright]}" line += " #{Paint[details, :black, :bright]}" if details Fontist.ui.say(line) end |
.section(title) ⇒ Object
Display section header
114 115 116 117 118 |
# File 'lib/fontist/import/import_display.rb', line 114 def self.section(title) Fontist.ui.say("") Fontist.ui.say("── #{title} " + "─" * (76 - title.length)) Fontist.ui.say("") end |
.status_failed(message) ⇒ Object
Display failure status
86 87 88 89 90 |
# File 'lib/fontist/import/import_display.rb', line 86 def self.status_failed() error_display = .length > 60 ? "#{[0..60]}..." : Fontist.ui.say(" #{Paint['✗', :red]} Failed: #{Paint[error_display, :red]}") end |
.status_overwrite(message) ⇒ Object
Display overwrite warning
95 96 97 |
# File 'lib/fontist/import/import_display.rb', line 95 def self.status_overwrite() Fontist.ui.say(" #{Paint['⚠', :yellow]} #{}") end |
.status_skipped(message, tip: nil) ⇒ Object
Display skip status
78 79 80 81 |
# File 'lib/fontist/import/import_display.rb', line 78 def self.status_skipped(, tip: nil) Fontist.ui.say(" #{Paint['⊝', :yellow]} #{}") Fontist.ui.say(" #{Paint['ℹ', :blue]} #{tip}") if tip end |
.status_success(message, details = "") ⇒ Object
Display success status
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/fontist/import/import_display.rb', line 62 def self.status_success(, details = "") detail_text = if details.empty? "" else " #{Paint[details, :black, :bright]}" end Fontist.ui.say(" #{Paint['✓', :green]} #{Paint[, :white]}#{detail_text}") end |
.summary(results, options = {}) ⇒ Object
Display summary with Paint styling
103 104 105 106 107 108 109 |
# File 'lib/fontist/import/import_display.rb', line 103 def self.summary(results, = {}) print_summary_header print_summary_stats(results) print_summary_errors(results) if results[:errors]&.any? print_summary_tips(results, ) (results) end |