Skip to content

Commit

Permalink
🎨 Removed global $decorate
Browse files Browse the repository at this point in the history
With bootlader to application object handoff, global is no longer needed. Internal object variable @decorate in Loginator is enough.
  • Loading branch information
mkarlesky committed May 2, 2024
1 parent 02e3e1f commit 25f0aa4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
8 changes: 4 additions & 4 deletions bin/cli_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setup
@actions = @actions_wrapper

# Automatic setting of console printing decorations
@loginator.decorate( !windows?() )
@loginator.decorate = !windows?()
end


Expand Down Expand Up @@ -216,17 +216,17 @@ def process_decoration(env, config={})
decorate = true
end

@loginator.decorate( decorate )
@loginator.decorate = decorate
end

# Otherwise inspect project configuration (could be blank and gets skipped)
walk = @config_walkinator.fetch_value( config, :project, :use_decorators )
if (!walk[:value].nil?)
case walk[:value]
when :all
@loginator.decorate( true )
@loginator.decorate = true
when :none
@loginator.decorate( false )
@loginator.decorate = false
else #:auto
# Retain what was set in `setup()` above based on platform
end
Expand Down
12 changes: 4 additions & 8 deletions lib/ceedling/loginator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
class Loginator

attr_reader :project_logging
attr_writer :decorate

constructor :verbosinator, :stream_wrapper, :file_wrapper, :system_wrapper

def setup()
$decorate = false if $decorate.nil?
@decorate = false

@replace = {
# Problematic characters pattern => Simple characters
Expand Down Expand Up @@ -90,15 +91,10 @@ def out(string, verbosity=Verbosity::NORMAL, label=LogLabels::AUTO, stream=nil)
return if !(@verbosinator.should_output?( verbosity ))

# Add labels and fun characters
console_str = format( string, verbosity, label, $decorate )
console_str = format( string, verbosity, label, @decorate )

# Write to output stream after optionally removing any problematic characters
stream.print( sanitize( console_str, $decorate ) )
end


def decorate(d)
$decorate = d
stream.print( sanitize( console_str, @decorate ) )
end

### Private ###
Expand Down

0 comments on commit 25f0aa4

Please sign in to comment.