Class: MenuGenerator
- Inherits:
-
Object
- Object
- MenuGenerator
- Defined in:
- lib/generators/menu_generator.rb
Instance Attribute Summary collapse
-
#generators ⇒ Object
readonly
Returns the value of attribute generators.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#prompt ⇒ Object
readonly
Returns the value of attribute prompt.
Instance Method Summary collapse
- #choose_mobile_platform ⇒ Object
- #choose_test_framework(automation) ⇒ Object
- #generate_choice_menu ⇒ Object
- #generate_framework(automation, framework) ⇒ Object
-
#initialize(project_name) ⇒ MenuGenerator
constructor
A new instance of MenuGenerator.
- #set_up_framework(automation, framework) ⇒ Object
Constructor Details
#initialize(project_name) ⇒ MenuGenerator
Returns a new instance of MenuGenerator.
13 14 15 16 17 |
# File 'lib/generators/menu_generator.rb', line 13 def initialize(project_name) @prompt = TTY::Prompt.new @name = project_name @generators = %w[Automation Common Helpers] end |
Instance Attribute Details
#generators ⇒ Object (readonly)
Returns the value of attribute generators.
11 12 13 |
# File 'lib/generators/menu_generator.rb', line 11 def generators @generators end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/generators/menu_generator.rb', line 11 def name @name end |
#prompt ⇒ Object (readonly)
Returns the value of attribute prompt.
11 12 13 |
# File 'lib/generators/menu_generator.rb', line 11 def prompt @prompt end |
Instance Method Details
#choose_mobile_platform ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/generators/menu_generator.rb', line 39 def choose_mobile_platform prompt.select('Please select your mobile platform') do || .choice :iOS, -> { choose_test_framework 'ios' } .choice :Android, -> { choose_test_framework 'android' } .choice :Cross_Platform, -> { choose_test_framework 'cross_platform' } .choice :Quit, -> { exit } end end |
#choose_test_framework(automation) ⇒ Object
28 29 30 31 32 |
# File 'lib/generators/menu_generator.rb', line 28 def choose_test_framework(automation) return choose_mobile_platform if automation == 'appium' select_test_framework(automation) end |
#generate_choice_menu ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/generators/menu_generator.rb', line 19 def prompt.select('Please select your automation framework') do || .choice :Appium, -> { choose_test_framework('appium') } .choice :Selenium, -> { choose_test_framework('selenium') } .choice :Watir, -> { choose_test_framework('watir') } .choice :Quit, -> { exit } end end |
#generate_framework(automation, framework) ⇒ Object
48 49 50 51 |
# File 'lib/generators/menu_generator.rb', line 48 def generate_framework(automation, framework) add_generator framework.capitalize generators.each { |generator| invoke_generator(automation, framework, generator) } end |
#set_up_framework(automation, framework) ⇒ Object
34 35 36 37 |
# File 'lib/generators/menu_generator.rb', line 34 def set_up_framework(automation, framework) generate_framework(automation, framework) system "cd #{name} && gem install bundler && bundle install" end |