starlined 0.2.3 → 0.2.4

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: 769c7c296ad84ba0ebd51a77daa0a20881056a387b7cb5cec80cf37b5315132d
4
- data.tar.gz: bf7fcc382c5c796554820685e873a6318b5bb698b4a89111840fc9c81fb762e7
3
+ metadata.gz: d8752698ed43ee158c8555688abd26f748631e99e9cbb3f07be23ee9712a281d
4
+ data.tar.gz: f58a4a33b3850c8ba79b2d06ef32ad5d6d88850b5995127b349e8ebc87e7d977
5
5
  SHA512:
6
- metadata.gz: 2f1d3001275fca9f14893f9e4a4091913afd519a7c4fe877c8583f46c1d8c29b1a444ab5eed2a93dc1b63e4cc6592c38c42f28031c30a5701c75f133728e7531
7
- data.tar.gz: da8192927d5499ca34b5b0dc9f55ba4c2b187092adc57f82b2f5523c070c13e3546de38a1e1ee871a6d00dfed4feb658d8192dd502aef9634caeedef59f6ccf0
6
+ metadata.gz: 45635e40d8f6bc8902de2f7c5200d555340946af45484c0af94d7198066a48a2f7061ef785f9093712939c146e799f5abbaa50ef4570caf4ead623f04c9f6af4
7
+ data.tar.gz: 6ebbb8ed5b0d494c6c1162dfd6eba6bd33e4e86616925bb115de53ba9631342583dd076580ca2368e7fecf98ba71b3cf715ea05b836d76affa6d3cc8c5d5d05e
@@ -1,20 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative "../lib/starlined"
4
+ require_relative '../lib/starlined'
5
5
 
6
6
  include Starlined::Messages
7
7
 
8
- puts "=== Basic Message Examples ==="
8
+ puts '=== Basic Message Examples ==='
9
9
  puts
10
10
 
11
- info("This is an information message")
11
+ info('This is an information message')
12
12
  sleep(1)
13
13
 
14
- warn("This is a warning message")
14
+ warn('This is a warning message')
15
15
  sleep(1)
16
16
 
17
- success("Operation completed successfully", 2.5)
17
+ success('Operation completed successfully', 2.5)
18
18
  sleep(1)
19
19
 
20
20
  # configurar modo verbose
@@ -22,7 +22,7 @@ Starlined.configure do |config|
22
22
  config.verbose = true
23
23
  end
24
24
 
25
- verbose("This verbose message is now visible")
25
+ vrbose('This verbose message is now visible')
26
26
  sleep(1)
27
27
 
28
28
  # ejemplo con error (comentado para no salir del programa)
@@ -33,4 +33,4 @@ name = ask("What's your name?")
33
33
  info("Hello, #{name}!")
34
34
 
35
35
  puts
36
- puts "=== End of Basic Examples ==="
36
+ puts '=== End of Basic Examples ==='
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "colorize"
3
+ require 'colorize'
4
4
 
5
5
  module Starlined
6
6
  module Messages
@@ -8,41 +8,42 @@ module Starlined
8
8
 
9
9
  def error(message = nil, context = nil)
10
10
  clear_line
11
- output = "\r[#{"FAILED".red}] #{context || "Operation failed"}"
11
+ output = "\r[#{'FAILED'.red}] #{context || 'Operation failed'}"
12
12
  output += " (#{message})" unless message.nil?
13
13
  puts output
14
14
  end
15
15
 
16
16
  def info(message)
17
17
  clear_line
18
- puts "\r[ #{"INFO".blue} ] #{message}"
18
+ puts "\r[ #{'INFO'.blue} ] #{message}"
19
19
  end
20
20
 
21
21
  def warn(message)
22
22
  clear_line
23
- puts "\r[ #{"WARN".yellow} ] #{message}"
23
+ puts "\r[ #{'WARN'.yellow} ] #{message}"
24
24
  end
25
25
 
26
26
  def success(message, time = nil)
27
27
  clear_line
28
- output = "\r[ #{"OK".green} ] #{message}"
28
+ output = "\r[ #{'OK'.green} ] #{message}"
29
29
  if time
30
- dots = "." * [3, 36 - message.length - time.to_s.length].max
30
+ dots = '.' * [3, 36 - message.length - time.to_s.length].max
31
31
  output += " #{dots.bold.gray} #{time}s"
32
32
  end
33
33
  puts output
34
34
  end
35
35
 
36
- def verbose(message)
36
+ def vrbose(message)
37
37
  return unless Starlined.configuration.verbose
38
+
38
39
  clear_line
39
- puts "\r[#{"VRBOSE".light_black}] #{message}"
40
+ puts "\r[#{'VRBOSE'.light_black}] #{message}"
40
41
  end
41
42
 
42
43
  def ask(prompt)
43
44
  clear_line
44
- print "\r[ #{"??".light_blue} ] #{prompt}: "
45
- STDIN.gets.chomp
45
+ print "\r[ #{'??'.light_blue} ] #{prompt}: "
46
+ $stdin.gets.chomp
46
47
  end
47
48
 
48
49
  private
@@ -41,6 +41,18 @@ module Starlined
41
41
  @animation&.increment_step
42
42
  end
43
43
 
44
+ def execute(callback, print_err: true, aka: nil, no_count: false, sudo: false)
45
+ handle_sudo if sudo
46
+
47
+ start_step(aka: aka)
48
+ result = callback.call
49
+ end_step(aka: aka, no_count: no_count)
50
+
51
+ handle_error(result, print_err, aka) unless result.last.success?
52
+
53
+ result
54
+ end
55
+
44
56
  private
45
57
 
46
58
  def start_step(aka: nil)
@@ -64,18 +76,6 @@ module Starlined
64
76
  end
65
77
  end
66
78
 
67
- def execute(callback, print_err: true, aka: nil, no_count: false, sudo: false)
68
- handle_sudo if sudo
69
-
70
- start_step(aka: aka)
71
- result = callback.call
72
- end_step(aka: aka, no_count: no_count)
73
-
74
- handle_error(result, print_err, aka) unless result.last.success?
75
-
76
- result
77
- end
78
-
79
79
  def stop_animation
80
80
  return unless @animation
81
81
 
@@ -112,7 +112,7 @@ module Starlined
112
112
  puts result[1] # stderr
113
113
  puts result[0] if result[1].empty? # stdout si stderr está vacío
114
114
 
115
- Messages.verbose("Exit code: #{result.last.exitstatus}")
115
+ Messages.vrbose("Exit code: #{result.last.exitstatus}")
116
116
  exit 1
117
117
  end
118
118
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Starlined
4
- VERSION = '0.2.3'
4
+ VERSION = '0.2.4'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starlined
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - mier