Class: DisplayBanner

Inherits:
Object
  • Object
show all
Defined in:
lib/tng/ui/display_banner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pastel, version) ⇒ DisplayBanner



9
10
11
12
13
14
15
16
17
# File 'lib/tng/ui/display_banner.rb', line 9

def initialize(pastel, version)
  @pastel = pastel
  @version = version
  @terminal_width = begin
    TTY::Screen.width
  rescue StandardError
    80
  end
end

Instance Attribute Details

#pastelObject (readonly)

Returns the value of attribute pastel.



7
8
9
# File 'lib/tng/ui/display_banner.rb', line 7

def pastel
  @pastel
end

#terminal_widthObject (readonly)

Returns the value of attribute terminal_width.



7
8
9
# File 'lib/tng/ui/display_banner.rb', line 7

def terminal_width
  @terminal_width
end

#versionObject (readonly)

Returns the value of attribute version.



7
8
9
# File 'lib/tng/ui/display_banner.rb', line 7

def version
  @version
end

Instance Method Details

#renderObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/tng/ui/display_banner.rb', line 19

def render
  banner_content = [
    pastel.public_send(Tng::UI::Theme.color(:secondary)).bold("Tng - LLM-Powered Rails Test Generator"),
    pastel.public_send(Tng::UI::Theme.color(:muted), "Version: #{version}"),
    "",
    pastel.public_send(Tng::UI::Theme.color(:accent), "Generate comprehensive tests for your Rails application"),
    pastel.public_send(Tng::UI::Theme.color(:muted), "Powered by LLM and static analysis")
  ].join("\n")

  box_width = 64
  box_width = terminal_width if box_width > terminal_width
  style = Tng::UI::Theme.box_style(:default)

  box = TTY::Box.frame(
    title: { top_left: " Tng ", bottom_right: " Ready " },
    style: style[:style],
    padding: style[:padding],
    align: :center,
    width: box_width
  ) do
    banner_content
  end

  "#{Tng::UI::Theme.center_box(box, box_width, terminal_width)}\n"
end