erebrus 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0a0cf035d47b272eefe1385dd63919f5b6c58c75765248dc165f3ba942057b6
4
- data.tar.gz: 637e125435680c16aefe62e318bc78990b2b0e1910d3c669071757996442279c
3
+ metadata.gz: 2b58c1ca924ac2f95499d284111464068d82a0e6820285bbde05c58799caac73
4
+ data.tar.gz: 8a4deb8f063ea47317cac4ff9fc2910943756da449ce0f2c33018534f9939ac3
5
5
  SHA512:
6
- metadata.gz: 935badb603ccfa49c812c702fd884f143a130fa051fda3f66fab25080a704549c11df48fc4fb3d731dd3789a1225488d2bd3229a700a5ef0dcab42cb6136bd9f
7
- data.tar.gz: '008219953c4f5ca5f9e245240bc824c7db35cba780830dee4e2fa58680fe3a8259a87350e4146f42bb91ab838381a51c0b8b899a960338e6eb4bdcd69496861d'
6
+ metadata.gz: 3a2c8188a7fc58ea49bee72c54a517d1a1ed4c774b1ab01203b7b41af4f09f5a0afef33c854052d253ffe0adfffa6920f6c02f3f194da27cf9d49f75dcad3ebc
7
+ data.tar.gz: 4f67840ed5820865d5b005e313a1b14ed52a182a3982994af699d0c8983226522bc227bbe45828a16079cf21687ecd5bf21da75e7170055fdbb959e7f24f03f8
data/bin/erebrus CHANGED
@@ -39,7 +39,7 @@ class ErebrusCommand < Thor
39
39
  load_buildfile_with_error_handling
40
40
 
41
41
  begin
42
- puts "" # spacing for readability
42
+ puts ""
43
43
  if namespace
44
44
  say_title("Targets in namespace '#{namespace}'")
45
45
  else
@@ -209,7 +209,6 @@ class ErebrusCommand < Thor
209
209
 
210
210
  context.merge!(options[:var]) if options[:var]
211
211
 
212
- # Legacy variables for backward compatibility
213
212
  context["PLATFORM"] = RUBY_PLATFORM
214
213
  context["RUBY_VERSION"] = RUBY_VERSION
215
214
  context["PWD"] = Dir.pwd
@@ -217,7 +216,6 @@ class ErebrusCommand < Thor
217
216
  context
218
217
  end
219
218
 
220
- # --- Styling helpers -----------------------------------------------------
221
219
  def color_enabled?
222
220
  options[:color] && $stdout.respond_to?(:isatty) && $stdout.isatty && ENV["NO_COLOR"].nil?
223
221
  rescue StandardError
@@ -19,7 +19,6 @@ module Erebrus
19
19
  @progress_count = 0
20
20
  @progress_enabled = false
21
21
  @progress_line_open = false
22
- # Predefine useful system and build variables
23
22
  @variables["HOST_OS"] = detect_host_os
24
23
  @variables["HOST_ARCH"] = detect_host_arch
25
24
  @variables["CPU_COUNT"] = detect_cpu_count
@@ -140,7 +139,6 @@ module Erebrus
140
139
 
141
140
  merged_context = @variables.merge(context)
142
141
 
143
- # Setup build-level progress bar across targets to execute
144
142
  target_obj = @targets[target_name]
145
143
  to_run = collect_targets_to_run(target_obj)
146
144
  @progress_total = to_run.size
@@ -255,7 +253,6 @@ module Erebrus
255
253
  execute_target(dep_target, context, visited.dup)
256
254
  end
257
255
 
258
- # Ensure progress bar line is terminated before any action output
259
256
  finish_progress_bar if @progress_enabled
260
257
  target.execute(context)
261
258
  increment_progress!
@@ -267,7 +264,6 @@ module Erebrus
267
264
  @targets.each_value(&:reset!)
268
265
  end
269
266
 
270
- # Progress helpers -------------------------------------------------------
271
267
  def collect_targets_to_run(root)
272
268
  seen = Set.new
273
269
  stack = [root]
@@ -295,14 +291,66 @@ module Erebrus
295
291
  def print_progress_bar(current, total)
296
292
  current = [current, total].min
297
293
  percent = total.zero? ? 100 : ((current.to_f / total) * 100).round
298
- bar_length = 30
299
- filled = (percent * bar_length / 100.0).round
300
- bar = "[" + "#" * filled + " " * (bar_length - filled) + "]"
301
- $stdout.print "\rProgress #{bar} #{percent}% (#{current}/#{total})"
294
+ bar_length = 25
295
+
296
+ filled_exact = (percent * bar_length / 100.0)
297
+ filled_full = filled_exact.floor
298
+ partial = filled_exact - filled_full
299
+
300
+ full_block = "█"
301
+ partial_blocks = ["", "▏", "▎", "▍", "▌", "▋", "▊", "▉"]
302
+ empty_block = "░"
303
+
304
+ bar = ""
305
+ bar += full_block * filled_full
306
+
307
+ if filled_full < bar_length && partial > 0
308
+ partial_index = (partial * (partial_blocks.length - 1)).round
309
+ bar += partial_blocks[partial_index]
310
+ filled_full += 1
311
+ end
312
+
313
+ bar += empty_block * (bar_length - filled_full)
314
+
315
+ if color_supported?
316
+ colored_bar = colorize_progress_bar(bar, filled_exact, bar_length)
317
+ $stdout.print "\r#{colored_bar} #{colorize(percent.to_s + "%",
318
+ :cyan)} #{colorize("(#{current}/#{total})", :dim)}"
319
+ else
320
+ $stdout.print "\r#{bar} #{percent}% (#{current}/#{total})"
321
+ end
322
+
302
323
  $stdout.flush
303
324
  @progress_line_open = true
304
325
  end
305
326
 
327
+ def color_supported?
328
+ $stdout.respond_to?(:isatty) && $stdout.isatty && ENV["NO_COLOR"].nil?
329
+ rescue StandardError
330
+ false
331
+ end
332
+
333
+ def colorize(text, color)
334
+ return text unless color_supported?
335
+
336
+ case color
337
+ when :green then "\e[32m#{text}\e[0m"
338
+ when :cyan then "\e[36m#{text}\e[0m"
339
+ when :dim then "\e[2m#{text}\e[0m"
340
+ else text
341
+ end
342
+ end
343
+
344
+ def colorize_progress_bar(bar, filled_exact, bar_length)
345
+ return bar unless color_supported?
346
+
347
+ filled_chars = filled_exact.ceil
348
+ filled_portion = bar[0, filled_chars]
349
+ empty_portion = bar[filled_chars..-1] || ""
350
+
351
+ "\e[32m#{filled_portion}\e[0m\e[2m#{empty_portion}\e[0m"
352
+ end
353
+
306
354
  def finish_progress_bar
307
355
  return unless @progress_enabled
308
356
  return unless @progress_line_open
@@ -1,3 +1,3 @@
1
1
  module Erebrus
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erebrus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jel9