Class: OtherTestFlowDisplay
- Inherits:
-
Object
- Object
- OtherTestFlowDisplay
- Defined in:
- lib/tng/ui/other_test_flow_display.rb
Instance Method Summary collapse
-
#initialize(prompt, pastel) ⇒ OtherTestFlowDisplay
constructor
A new instance of OtherTestFlowDisplay.
- #select_other_file(other_files) ⇒ Object
- #select_other_method(other_file, methods) ⇒ Object
- #show_no_methods_message(other_file) ⇒ Object
- #show_no_other_files_message ⇒ Object
Constructor Details
#initialize(prompt, pastel) ⇒ OtherTestFlowDisplay
10 11 12 13 14 15 16 17 18 |
# File 'lib/tng/ui/other_test_flow_display.rb', line 10 def initialize(prompt, pastel) @prompt = prompt @pastel = pastel @terminal_width = begin TTY::Screen.width rescue StandardError 80 end end |
Instance Method Details
#select_other_file(other_files) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/tng/ui/other_test_flow_display.rb', line 20 def select_other_file(other_files) header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:config)} Select file to test:") puts Tng::UI::Theme.center_text(header, @terminal_width) @prompt.select( "", cycle: true, per_page: 12, filter: true, symbols: { marker: Tng::UI::Theme.icon(:marker) } ) do || other_files.each do |file| display_name = "#{file[:name]} #{@pastel.public_send(Tng::UI::Theme.color(:muted), "(#{file[:path]})")}" .choice display_name, file end .choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back end end |
#select_other_method(other_file, methods) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/tng/ui/other_test_flow_display.rb', line 50 def select_other_method(other_file, methods) header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:rocket)} Select method to test in #{other_file[:name]}") puts Tng::UI::Theme.center_text(header, @terminal_width) @prompt.select( "", cycle: true, per_page: 10, filter: true, symbols: { marker: Tng::UI::Theme.icon(:marker) } ) do || methods.each do |method| .choice method[:name], method end .choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back end end |
#show_no_methods_message(other_file) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/tng/ui/other_test_flow_display.rb', line 68 def (other_file) error_msg = "#{@pastel.public_send(Tng::UI::Theme.color(:error)).bold("#{Tng::UI::Theme.icon(:error)} No methods found in #{other_file[:name]}")}\n#{@pastel.public_send( Tng::UI::Theme.color(:muted), "File may be empty or have syntax errors" )}" puts Tng::UI::Theme.center_text(error_msg, @terminal_width) @prompt.keypress(Tng::UI::Theme.center_text( @pastel.public_send(Tng::UI::Theme.color(:muted), "Press any key to continue..."), @terminal_width )) end |
#show_no_other_files_message ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/tng/ui/other_test_flow_display.rb', line 39 def error_msg = "#{@pastel.public_send(Tng::UI::Theme.color(:error)).bold("#{Tng::UI::Theme.icon(:error)} No other files found in your application")}\n#{@pastel.public_send( Tng::UI::Theme.color(:muted), "Make sure you have files in supported directories (app/jobs, app/helpers, lib/, app/policies, app/presenters, app/mailers, app/graphql, etc.)" )}" puts Tng::UI::Theme.center_text(error_msg, @terminal_width) @prompt.keypress(Tng::UI::Theme.center_text( @pastel.public_send(Tng::UI::Theme.color(:muted), "Press any key to continue..."), @terminal_width )) end |