Class: InstallationScreen

Inherits:
BaseScreen show all
Includes:
InvokeGenerators
Defined in:
lib/desktop/installation_screen.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InvokeGenerators

#add_examples, #add_generator, #generate_framework, #invoke_generator

Instance Attribute Details

#entry_text ⇒ Object

Returns the value of attribute entry_text.



9
10
11
# File 'lib/desktop/installation_screen.rb', line 9

def entry_text
  @entry_text
end

Instance Method Details

#launch ⇒ Object



11
12
13
14
15
16
17
18
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/desktop/installation_screen.rb', line 11

def launch
  window('Ruby Raider', 800, 600) do
    margined true
    tab do
      tab_item('Installer') do
        vertical_box do
          vertical_box do
            stretchy false
            label('Project Name') do
              stretchy false
            end

            entry do
              stretchy false # Smart default option for appending to horizontal_box
              text <=> [self, :entry_text, { after_write: lambda { |text|
                @project_name = text
                $stdout.flush
              } }] # bidirectional data-binding between text property and entry_text attribute, printing after write to model.
            end
          end

          vertical_box do
            stretchy false

            @radio = radio_buttons do
              stretchy false

              items 'Web', 'Mobile'
              selected_item 'Web'
              on_selected do |buttons|
                if buttons.selected_item == 'Web'
                  @mobile_automation.hide
                  @platforms.hide
                  @web_automation.show
                else
                  @web_automation.hide
                  @mobile_automation.show
                  @platforms.show
                end
              end
            end

            @mobile_automation = combobox do
              stretchy false
              visible false
              items 'Appium'
              selected_item 'Appium'
            end

            @web_automation = combobox do
              stretchy false
              visible true
              items 'Selenium', 'Watir'
              selected_item 'Selenium'
            end

            @platforms = combobox do
              stretchy false
              visible false
              items 'Android', 'iOS', 'Cross-Platform'
              selected_item 'iOS'
            end

            @framework = combobox do
              stretchy false
              visible true
              items 'Cucumber', 'Rspec'
              selected_item 'Cucumber'

              on_selected do |items|
                if items.selected_item == 'Rspec' && @radio.selected_item != 'Mobile'
                  @visual_checkbox.show
                else
                  @visual_checkbox.hide
                end
              end
            end

            @visual_checkbox = checkbox('Applitools integration') do
              stretchy false
              visible false
            end

            @example_checkbox = checkbox('Add example files') do
              stretchy false
              visible true
            end

            button('Create Project') do
              stretchy false
              on_clicked do
                automation = if @web_automation.visible?
                               @web_automation.selected_item
                             else
                               @mobile_automation.selected_item
                             end
                structure = {
                  automation: automation,
                  examples: @example_checkbox.checked,
                  framework: @framework.selected_item,
                  generators: %w[Automation Common Helpers],
                  name: @project_name,
                  visual: @visual_checkbox.checked
                }
                generate_framework(structure)
                @installation_box.text = if File.directory?(@project_name)
                                           "Your project has been created, close this window, go to the folder #{@project_name} and run 'raider open'"
                                         else
                                           'There was a problem creating your project try again'
                                         end
              end
            end
          end
          vertical_box do
            stretchy false
            @installation_box = multiline_entry do
              stretchy false
              text 'Your installation result will appear here...'
              $stdout.flush
            end
          end
        end
      end
    end
  end.show
end