Class: ControllerTestFlowDisplay
- Inherits:
-
Object
- Object
- ControllerTestFlowDisplay
- Defined in:
- lib/tng/ui/controller_test_flow_display.rb
Instance Method Summary collapse
-
#initialize(prompt, pastel) ⇒ ControllerTestFlowDisplay
constructor
A new instance of ControllerTestFlowDisplay.
- #select_controller(controllers) ⇒ Object
- #select_controller_method(controller, methods) ⇒ Object
- #show_no_controllers_message ⇒ Object
- #show_no_methods_message(controller) ⇒ Object
Constructor Details
#initialize(prompt, pastel) ⇒ ControllerTestFlowDisplay
Returns a new instance of ControllerTestFlowDisplay.
10 11 12 13 14 15 16 17 18 |
# File 'lib/tng/ui/controller_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_controller(controllers) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/tng/ui/controller_test_flow_display.rb', line 20 def select_controller(controllers) header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:config)} Select controller 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 || controllers.each do |controller| display_name = "#{controller[:name]} #{@pastel.public_send(Tng::UI::Theme.color(:muted), "(#{controller[:path]})")}" .choice display_name, controller end .choice @pastel.public_send(Tng::UI::Theme.color(:secondary), "#{Tng::UI::Theme.icon(:back)} Back"), :back end end |
#select_controller_method(controller, methods) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tng/ui/controller_test_flow_display.rb', line 51 def select_controller_method(controller, methods) header = @pastel.public_send(Tng::UI::Theme.color(:primary)).bold("#{Tng::UI::Theme.icon(:rocket)} Select method to test in #{controller[: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_controllers_message ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/tng/ui/controller_test_flow_display.rb', line 40 def error_msg = "#{@pastel.public_send(Tng::UI::Theme.color(:error)).bold("#{Tng::UI::Theme.icon(:error)} No controllers found in your application")}\n#{@pastel.public_send( Tng::UI::Theme.color(:muted), "Make sure you have controllers in app/controllers/" )}" 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_methods_message(controller) ⇒ Object
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/tng/ui/controller_test_flow_display.rb', line 69 def (controller) error_msg = "#{@pastel.public_send(Tng::UI::Theme.color(:error)).bold("#{Tng::UI::Theme.icon(:error)} No methods found in #{controller[:name]}")}\n#{@pastel.public_send( Tng::UI::Theme.color(:muted), "Controller 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 |