Class: RunnerComponents
Defined Under Namespace
Classes: CAP, CONFIG_ITEM
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of RunnerComponents.
12
13
14
15
|
# File 'lib/desktop/components/runner_components.rb', line 12
def initialize
super
@folder_exist = File.directory?(@folder)
end
|
Instance Attribute Details
Returns the value of attribute contacts.
7
8
9
|
# File 'lib/desktop/components/runner_components.rb', line 7
def contacts
@contacts
end
|
Instance Method Details
#config_tab ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/desktop/components/runner_components.rb', line 84
def config_tab
tab_item('Configuration') do
@config_data = load_or_create_config
@config_items = @config_data.map { |key, value| CONFIG_ITEM.new(key, value) }
vertical_box do
refined_table(
model_array: @config_items,
table_columns: {
'Attribute' => :text,
'Value' => { text: { editable: true } }
},
table_editable: true,
per_page: 20
)
end
end
end
|
#editor_tab ⇒ Object
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
# File 'lib/desktop/components/runner_components.rb', line 102
def editor_tab
tab_item('Editor') do
horizontal_box do
vertical_box do
horizontal_box do
button('Create Test') do
on_clicked do
Scaffolding.new([@test_name.text]).generate_spec
end
end
@test_name = entry do
text 'test_example'
end
end
horizontal_box do
button('Create Page') do
on_clicked do
Scaffolding.new([@page_name.text]).generate_class
end
end
@page_name = entry do
text 'page_example'
end
end
horizontal_box do
button('Create Helper') do
on_clicked do
Scaffolding.new([@helper_name.text]).generate_helper
end
end
@helper_name = entry do
text 'helper_example'
end
end
vertical_separator do
stretchy false
end
end
vertical_box do
@editable_files = combobox do
@all_files = @folder_exist ? load_all_files : ['There are no files created']
stretchy false
visible true
items @all_files
selected_item @all_files.first
on_selected do |items|
if @folder_exist
path = items.selected_item
@edit_file = File.open(path)
@edit_box.text = @edit_file.read
end
end
end
@edit_box = multiline_entry do
text File.read(@all_files.first) if @folder_exist
on_changed do |e|
if @folder_exist
File.write(@editable_files.selected_item, e.text)
$stdout.flush end
end
end
end
end
end
end
|
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
|
# File 'lib/desktop/components/runner_components.rb', line 17
def
grid do
stretchy false
button('▶') do
left 0
on_clicked do
output = Open3.popen3("#{@framework} #{@tests.selected_item}") do |_stdin, stdout, _stderr|
stdout.read
end
system "#{@framework} #{@tests.selected_item}"
@results.text = output
end
end
button('■') do
left 1
on_clicked do
pp 'The stop feature will be implemented in a later release'
end
end
@tests = combobox do
left 2
files = Dir.glob(File.join(@folder, @extension))
multiple_items = files.count.positive? ? files : ['There are no tests please create a new one']
items multiple_items
selected_item files.first
@file = files.count.positive? ? File.open(files.first) : ''
on_selected do |items|
@results.text = ''
path = items.selected_item
@file = File.open(path)
@text_box.text = @file.read
end
end
button('Open Dashboard') do
left 3
halign :end
on_clicked do
system 'allure serve allure-reports'
end
end
end
end
|
#tests_tab ⇒ Object
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/desktop/components/runner_components.rb', line 64
def tests_tab
tab_item('Tests') do
horizontal_box do
@text_box = multiline_entry do
test_code = @folder_exist ? @file.read : 'No tests have been created, please create your first test'
text test_code
on_changed do |e|
File.write(@tests.selected_item, e.text)
$stdout.flush end
end
@results = multiline_entry do
text ''
end
end
end
end
|