Class: Staticz::BuildListener

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/build_command.rb

Instance Method Summary collapse

Constructor Details

#initialize(compilable) ⇒ BuildListener

Returns a new instance of BuildListener.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/commands/build_command.rb', line 65

def initialize(compilable)
  @compilable = compilable

  if Staticz::Settings.verbose?
    puts "Compiling #{generate_text}"
  else
    @spinner = TTY::Spinner.new(
      "[:spinner] #{generate_text}",
      format: :classic,
      success_mark: Colors.in_green(""),
      error_mark: Colors.in_red("")
    )

    @spinner.auto_spin
  end
end

Instance Method Details

#errorObject



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/commands/build_command.rb', line 86

def error
  if Staticz::Settings.verbose?
    puts Colors.in_red("Error:")
  else
    @spinner.error(Colors.in_red("(error)"))
  end

  @compilable.errors.each do |error|
    puts Colors.in_red(error)
  end
end

#finishObject



82
83
84
# File 'lib/commands/build_command.rb', line 82

def finish
  @spinner.success(Colors.in_green("(successful)")) if !Staticz::Settings.verbose?
end