Sha256: 69601aba52f24ce6fd085639e10bb719e831638644c62a333ba1aaca6e76b4fd
Contents?: true
Size: 1.98 KB
Versions: 3
Compression:
Stored size: 1.98 KB
Contents
# frozen_string_literal: true require "rfix" require "cli/ui" module Rfix::Log extend self def say(message) prt("{{v}} #{message}") end def say_error(message) prt("{{x}} #{message}") end def say_error_sub(message) prt(message.to_s) end def error_box(title) box(title, color: :red) { yield } end def abort_box(title) error_box(title) { yield } exit 1 end def say_test(message) prt("{{i}} #{strip(message)}") end def say_debug(message) # if debug? or test? prt("{{i}} #{strip(message)}", to: $stderr) # end end def say_abort(message) prt("{{x}} #{message}") exit 1 end def debug? return false unless defined?(RSpec) return RSpec.configuration.debug? end def test? Rfix.test? end def say_exit(message) prt("{{v}} #{message}") exit 0 end def say_plain(message) prt(message) end def debug_box(title) unless_debug do box(title) { yield } end end def prt(*args) CLI::UI.puts(*args) end def fmt(*args) CLI::UI.fmt(*args) end alias ftm fmt def log_items(items, title:) box("#{title} (#{items.count})") do return margin(2) do prt "{{warning:No items found}}" end if items.empty? items.each do |item| if block_given? say strip(yield item) else say strip(item.to_s) end end end end def box(title, color: :reset) margin do CLI::UI::Frame.open(title, color: color) do margin(2) do yield end end end end def strip(msg) msg # msg.gsub(current_path, "").gsub(Dir.pwd, ".").chomp end def current_path File.join(Dir.pwd, "/") end def div(title, **args) CLI::UI::Frame.divider(title, **args) margin { yield } end def margin(n = 1) new_line(n) yield new_line(n) end def new_line(n = 1) say_plain("\n" * n) end def unless_debug yield unless Rfix.debug? end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rfix-1.2.2.pre.174 | lib/rfix/log.rb |
rfix-1.2.3.pre | lib/rfix/log.rb |
rfix-1.2.2.pre | lib/rfix/log.rb |