ruber 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +25 -0
- data/bin/ruber +0 -0
- data/data/share/apps/ruber/ruberui.rc +15 -1
- data/data/share/icons/{ruber.png → ruber-old.pgn} +0 -0
- data/lib/ruber/application/application.rb +216 -73
- data/lib/ruber/application/plugin.yaml +2 -2
- data/lib/ruber/document_project.rb +25 -5
- data/lib/ruber/documents/document_list.rb +11 -15
- data/lib/ruber/editor/document.rb +106 -50
- data/lib/ruber/editor/editor_view.rb +4 -2
- data/lib/ruber/external_program_plugin.rb +8 -0
- data/lib/ruber/kde_config_option_backend.rb +12 -4
- data/lib/ruber/kde_sugar.rb +35 -1
- data/lib/ruber/main_window/choose_plugins_dlg.rb +10 -10
- data/lib/ruber/main_window/hint_solver.rb +263 -0
- data/lib/ruber/main_window/main_window.rb +462 -206
- data/lib/ruber/main_window/main_window_actions.rb +228 -62
- data/lib/ruber/main_window/main_window_internal.rb +169 -115
- data/lib/ruber/main_window/plugin.yaml +13 -3
- data/lib/ruber/main_window/save_modified_files_dlg.rb +1 -1
- data/lib/ruber/main_window/ui/choose_plugins_widget.rb +1 -1
- data/lib/ruber/main_window/ui/main_window_settings_widget.rb +1 -1
- data/lib/ruber/main_window/ui/new_project_widget.rb +1 -1
- data/lib/ruber/main_window/ui/open_file_in_project_dlg.rb +1 -1
- data/lib/ruber/main_window/ui/output_color_widget.rb +1 -1
- data/lib/ruber/main_window/ui/workspace_settings_widget.rb +51 -0
- data/lib/ruber/main_window/ui/workspace_settings_widget.ui +28 -0
- data/lib/ruber/main_window/view_manager.rb +418 -0
- data/lib/ruber/main_window/workspace.png +0 -0
- data/lib/ruber/output_widget.rb +43 -37
- data/lib/ruber/pane.rb +621 -0
- data/lib/ruber/plugin_specification_reader.rb +8 -1
- data/lib/ruber/projects/project_files_list.rb +6 -0
- data/lib/ruber/projects/ui/project_files_rule_chooser_widget.rb +1 -1
- data/lib/ruber/projects/ui/project_files_widget.rb +1 -1
- data/lib/ruber/qt_sugar.rb +94 -4
- data/lib/ruber/utils.rb +16 -7
- data/lib/ruber/version.rb +2 -2
- data/plugins/autosave/autosave.rb +62 -1
- data/plugins/autosave/plugin.yaml +1 -0
- data/plugins/autosave/ui/autosave_config_widget.rb +37 -14
- data/plugins/autosave/ui/autosave_config_widget.ui +62 -12
- data/plugins/find_in_files/find_in_files_widgets.rb +1 -3
- data/plugins/find_in_files/ui/config_widget.rb +1 -1
- data/plugins/find_in_files/ui/find_in_files_widget.rb +1 -1
- data/plugins/rake/plugin.yaml +1 -1
- data/plugins/rake/ui/add_quick_task_widget.rb +1 -1
- data/plugins/rake/ui/choose_task_widget.rb +1 -1
- data/plugins/rake/ui/config_widget.rb +1 -1
- data/plugins/rake/ui/project_widget.rb +1 -1
- data/plugins/rspec/rspec.rb +14 -22
- data/plugins/rspec/ruber_rspec_formatter.rb +4 -1
- data/plugins/rspec/ui/rspec_project_widget.rb +1 -1
- data/plugins/ruby_development/plugin.yaml +7 -2
- data/plugins/ruby_development/ruby_development.rb +134 -13
- data/plugins/ruby_development/ui/config_widget.rb +66 -0
- data/plugins/ruby_development/ui/config_widget.ui +58 -0
- data/plugins/ruby_development/ui/project_widget.rb +1 -1
- data/plugins/ruby_runner/plugin.yaml +2 -2
- data/plugins/ruby_runner/ruby_runner.rb +15 -3
- data/plugins/ruby_runner/ui/config_widget.rb +1 -1
- data/plugins/ruby_runner/ui/project_widget.rb +1 -1
- data/plugins/ruby_runner/ui/ruby_runnner_plugin_option_widget.rb +1 -1
- data/plugins/state/plugin.yaml +6 -2
- data/plugins/state/state.rb +305 -81
- data/plugins/state/ui/config_widget.rb +1 -1
- data/spec/common.rb +11 -3
- data/spec/document_list_spec.rb +8 -8
- data/spec/document_project_spec.rb +98 -25
- data/spec/document_spec.rb +178 -152
- data/spec/editor_view_spec.rb +26 -5
- data/spec/framework.rb +5 -0
- data/spec/hint_solver_spec.rb +450 -0
- data/spec/kde_sugar_spec.rb +73 -6
- data/spec/output_widget_spec.rb +172 -156
- data/spec/pane_spec.rb +1165 -0
- data/spec/plugin_specification_reader_spec.rb +37 -1
- data/spec/project_files_list_spec.rb +30 -20
- data/spec/qt_sugar_spec.rb +269 -0
- data/spec/state_spec.rb +566 -353
- data/spec/utils_spec.rb +1 -1
- data/spec/view_manager_spec.rb +71 -0
- metadata +16 -4
|
@@ -405,9 +405,6 @@ because the document corresponding to the file was modified
|
|
|
405
405
|
it.each_row do |line, _, repl|
|
|
406
406
|
lines_to_replace[line.text.to_i] = repl.text if line.checked?
|
|
407
407
|
end
|
|
408
|
-
# TODO see what the line below did. In my opinion, it is the remainder of some line
|
|
409
|
-
# I added for testing and forgot to remove
|
|
410
|
-
# path = file.sub( '/home/stefano/tmp/ruber', '').gsub('/', '_')
|
|
411
408
|
lines = File.readlines(file)
|
|
412
409
|
lines_to_replace.each_pair{|idx, text| lines[idx - 1] = text + "\n"}
|
|
413
410
|
new_text = lines.join ''
|
|
@@ -421,6 +418,7 @@ because the document corresponding to the file was modified
|
|
|
421
418
|
doc.text = new_text
|
|
422
419
|
end
|
|
423
420
|
doc.save
|
|
421
|
+
#If the document doesn't have a view, pos will be nil
|
|
424
422
|
doc.view.go_to pos.line, pos.column if pos
|
|
425
423
|
else
|
|
426
424
|
Tempfile.open(File.basename(file)) do |f|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
** Form generated from reading ui file 'config_widget.ui'
|
|
3
3
|
**
|
|
4
|
-
** Created:
|
|
4
|
+
** Created: mar nov 16 11:52:49 2010
|
|
5
5
|
** by: Qt User Interface Compiler version 4.7.0
|
|
6
6
|
**
|
|
7
7
|
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
** Form generated from reading ui file 'find_in_files_widget.ui'
|
|
3
3
|
**
|
|
4
|
-
** Created:
|
|
4
|
+
** Created: mar nov 16 11:52:49 2010
|
|
5
5
|
** by: Qt User Interface Compiler version 4.7.0
|
|
6
6
|
**
|
|
7
7
|
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
data/plugins/rake/plugin.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
** Form generated from reading ui file 'add_quick_task_widget.ui'
|
|
3
3
|
**
|
|
4
|
-
** Created:
|
|
4
|
+
** Created: mar nov 16 11:52:49 2010
|
|
5
5
|
** by: Qt User Interface Compiler version 4.7.0
|
|
6
6
|
**
|
|
7
7
|
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
** Form generated from reading ui file 'choose_task_widget.ui'
|
|
3
3
|
**
|
|
4
|
-
** Created:
|
|
4
|
+
** Created: mar nov 16 11:52:49 2010
|
|
5
5
|
** by: Qt User Interface Compiler version 4.7.0
|
|
6
6
|
**
|
|
7
7
|
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
** Form generated from reading ui file 'config_widget.ui'
|
|
3
3
|
**
|
|
4
|
-
** Created:
|
|
4
|
+
** Created: mar nov 16 11:52:49 2010
|
|
5
5
|
** by: Qt User Interface Compiler version 4.7.0
|
|
6
6
|
**
|
|
7
7
|
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
** Form generated from reading ui file 'project_widget.ui'
|
|
3
3
|
**
|
|
4
|
-
** Created:
|
|
4
|
+
** Created: mar nov 16 11:52:49 2010
|
|
5
5
|
** by: Qt User Interface Compiler version 4.7.0
|
|
6
6
|
**
|
|
7
7
|
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
data/plugins/rspec/rspec.rb
CHANGED
|
@@ -278,21 +278,30 @@ which, most likely, will cause it to fail.
|
|
|
278
278
|
@return [Boolean] *true* if the spec program is started and *false* otherwise
|
|
279
279
|
(including the case when the process was already running or autosaving failed)
|
|
280
280
|
=end
|
|
281
|
-
def run_current
|
|
281
|
+
def run_current what = :all
|
|
282
282
|
prj = Ruber[:projects].current_project
|
|
283
283
|
unless prj
|
|
284
284
|
KDE::MessageBox.error nil, "You must have an open project to choose this entry.\nYOU SHOULD NEVER SEE THIS MESSAGE"
|
|
285
285
|
return
|
|
286
286
|
end
|
|
287
287
|
opts = options prj
|
|
288
|
-
|
|
288
|
+
view = Ruber[:main_window].active_editor
|
|
289
|
+
doc = view.document
|
|
290
|
+
unless doc.url.local_file?
|
|
291
|
+
KDE::MessageBox.sorry nil, 'You can\'t run rspec for remote files'
|
|
292
|
+
return
|
|
293
|
+
end
|
|
289
294
|
unless doc
|
|
290
|
-
KDE::MessageBox.error nil, "You must have an open
|
|
295
|
+
KDE::MessageBox.error nil, "You must have an open editor to choose this entry.\nYOU SHOULD NEVER SEE THIS MESSAGE"
|
|
291
296
|
return
|
|
292
297
|
end
|
|
293
298
|
files = specs_for_file opts, doc.path
|
|
294
299
|
files.reject!{|f| !File.exist? f}
|
|
295
300
|
opts[:files] = files.empty? ? [doc.path] : files
|
|
301
|
+
if what == :current_line
|
|
302
|
+
line = view.cursor_position.line + 1
|
|
303
|
+
opts[:spec_options] += ["-l", line.to_s]
|
|
304
|
+
end
|
|
296
305
|
run_rspec_for prj, opts, :files => :documents_with_file, :on_failure => :ask,
|
|
297
306
|
:message => 'Do you want to run the tests all the same?'
|
|
298
307
|
end
|
|
@@ -309,26 +318,9 @@ current file is the example file, not the source.
|
|
|
309
318
|
(including the case when the process was already running or autosaving failed)
|
|
310
319
|
=end
|
|
311
320
|
def run_current_line
|
|
312
|
-
|
|
313
|
-
unless prj
|
|
314
|
-
KDE::MessageBox.error nil, "You must have an open project to choose this entry.\nYOU SHOULD NEVER SEE THIS MESSAGE"
|
|
315
|
-
return
|
|
316
|
-
end
|
|
317
|
-
opts = options prj
|
|
318
|
-
doc = Ruber[:main_window].current_document
|
|
319
|
-
unless doc
|
|
320
|
-
KDE::MessageBox.error nil, "You must have an open document to choose this entry.\nYOU SHOULD NEVER SEE THIS MESSAGE"
|
|
321
|
-
return
|
|
322
|
-
end
|
|
323
|
-
line = doc.view.cursor_position.line + 1
|
|
324
|
-
files = specs_for_file opts, doc.path
|
|
325
|
-
files.reject!{|f| !File.exist? f}
|
|
326
|
-
opts[:files] = files.empty? ? [doc.path] : files
|
|
327
|
-
opts[:spec_options] += ["-l", line.to_s]
|
|
328
|
-
run_rspec_for prj, opts, :files => :documents_with_file, :on_failure => :ask,
|
|
329
|
-
:message => 'Do you want to run the tests all the same?'
|
|
321
|
+
run_current :current_line
|
|
330
322
|
end
|
|
331
|
-
|
|
323
|
+
|
|
332
324
|
=begin rdoc
|
|
333
325
|
Runs the spec command for the given object
|
|
334
326
|
|
|
@@ -272,7 +272,10 @@ by newlines
|
|
|
272
272
|
hash = {}
|
|
273
273
|
hash[:type] = :failure
|
|
274
274
|
hash[:description] = ex.metadata[:full_description]
|
|
275
|
-
|
|
275
|
+
# It seems that rspec up tp 2.2 uses :exception_encountered, while from
|
|
276
|
+
# 2.3 it uses :exception. This should work for both
|
|
277
|
+
exception = ex.metadata[:execution_result][:exception]
|
|
278
|
+
exception ||= ex.metadata[:execution_result][:exception_encountered]
|
|
276
279
|
hash[:exception] = exception.class.name
|
|
277
280
|
hash[:message] = exception.message
|
|
278
281
|
hash[:location] = ex.metadata[:location]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
=begin
|
|
2
2
|
** Form generated from reading ui file 'rspec_project_widget.ui'
|
|
3
3
|
**
|
|
4
|
-
** Created:
|
|
4
|
+
** Created: mar nov 16 11:52:49 2010
|
|
5
5
|
** by: Qt User Interface Compiler version 4.7.0
|
|
6
6
|
**
|
|
7
7
|
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
|
@@ -11,12 +11,17 @@ class: Ruber::FilesRunner::Plugin
|
|
|
11
11
|
require: ruby_development
|
|
12
12
|
ui_file: ruby_developmentui.rc
|
|
13
13
|
tool_widgets: {:class: Ruber::FilesRunner::OutputWidget, :caption: Ruby output, :position: :bottom, :name: ruby_output_widget, pixmap: ruby_development.png}
|
|
14
|
+
config_options:
|
|
15
|
+
ruby:
|
|
16
|
+
run_in_terminal_cmd: {default: 'konsole --workdir %d --hold -e %r'}
|
|
17
|
+
config_widgets:
|
|
18
|
+
- {caption: Ruby, class: Ruber::FilesRunner::ConfigWidget}
|
|
14
19
|
project_options:
|
|
15
20
|
ruby:
|
|
16
21
|
main_program: {default: "''", relative_path: true}
|
|
17
|
-
options: {default: [], scope: [document, global]}
|
|
22
|
+
options: {default: [], scope: [document, global], place: all}
|
|
18
23
|
working_dir: {default: '.', relative_path: true}
|
|
19
|
-
run_in_terminal: {default: false, scope: [document, global]}
|
|
24
|
+
run_in_terminal: {default: false, scope: [document, global], place: all}
|
|
20
25
|
project_widgets:
|
|
21
26
|
- {caption: Ruby, class: Ruber::FilesRunner::ProjectWidget, scope: [document, global]}
|
|
22
27
|
actions:
|
|
@@ -3,6 +3,7 @@ require 'ruber/filtered_output_widget'
|
|
|
3
3
|
require 'ruby_runner/ruby_runner'
|
|
4
4
|
|
|
5
5
|
require_relative 'ui/project_widget'
|
|
6
|
+
require_relative 'ui/config_widget'
|
|
6
7
|
|
|
7
8
|
module Ruber
|
|
8
9
|
|
|
@@ -15,6 +16,9 @@ the file corresponding to the current document or another file specified by the
|
|
|
15
16
|
user. The output of the program (both standard output and standard error) are
|
|
16
17
|
displayied in a tool widget.
|
|
17
18
|
|
|
19
|
+
To allow ruby to run a remote file (or a document associated with a remote file),
|
|
20
|
+
a temporary file is created and the contents of the remote file are copied in it.
|
|
21
|
+
|
|
18
22
|
The interpreter to use can be set document- or project-wise using the Ruby runner
|
|
19
23
|
plugin.
|
|
20
24
|
|
|
@@ -42,6 +46,8 @@ Plugin object for the Files runner plugn
|
|
|
42
46
|
=end
|
|
43
47
|
class Plugin < RubyRunner::RubyRunnerPlugin
|
|
44
48
|
|
|
49
|
+
FakeFileInfo = Struct.new :file, :url
|
|
50
|
+
|
|
45
51
|
slots :load_settings
|
|
46
52
|
|
|
47
53
|
=begin rdoc
|
|
@@ -49,7 +55,7 @@ Plugin object for the Files runner plugn
|
|
|
49
55
|
=end
|
|
50
56
|
def initialize psf
|
|
51
57
|
super psf, :ruby, :scope => [:document, :global], :file_extension => %w[*.rb Rakefile rakefile],
|
|
52
|
-
:mimetype => ['application/x-ruby']
|
|
58
|
+
:mimetype => ['application/x-ruby'], :place => [:local, :remote]
|
|
53
59
|
process.next_open_mode = Qt::IODevice::ReadOnly | Qt::IODevice::Unbuffered
|
|
54
60
|
Ruber[:autosave].register_plugin self, true
|
|
55
61
|
connect self, SIGNAL('process_finished(int, QString)'), self, SLOT('ruby_exited(int, QString)')
|
|
@@ -66,6 +72,7 @@ Plugin object for the Files runner plugn
|
|
|
66
72
|
o.register_plugin self, true if f == 'autosave'
|
|
67
73
|
end
|
|
68
74
|
@output_widget = @widget
|
|
75
|
+
@fake_file = nil
|
|
69
76
|
end
|
|
70
77
|
|
|
71
78
|
=begin rdoc
|
|
@@ -126,8 +133,8 @@ as first argument to {Autosave::AutosavePlugin#autosave}
|
|
|
126
133
|
Ruber[:main_window].show_tool @widget
|
|
127
134
|
Ruber[:main_window].change_state 'ruby_running', true
|
|
128
135
|
if opts[:run_in_terminal]
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
terminal, *term_opts = terminal_command opts[:dir], ([opts[:ruby]] + cmd)
|
|
137
|
+
run_process terminal, opts[:dir], term_opts
|
|
131
138
|
else run_process opts[:ruby], opts[:dir], cmd
|
|
132
139
|
end
|
|
133
140
|
true
|
|
@@ -206,6 +213,18 @@ successfully or not
|
|
|
206
213
|
prj = doc.project
|
|
207
214
|
file = File.basename(doc.path)
|
|
208
215
|
dir = File.dirname(doc.path)
|
|
216
|
+
url = doc.url
|
|
217
|
+
if url.remote_file?
|
|
218
|
+
@fake_file = FakeFileInfo.new Tempfile.new('ruby_development'), url
|
|
219
|
+
@fake_file.file.write doc.text
|
|
220
|
+
@fake_file.file.flush
|
|
221
|
+
file = @fake_file.file.path
|
|
222
|
+
dir = ENV['HOME']
|
|
223
|
+
end
|
|
224
|
+
unless prj.has_setting?(:ruby, :options)
|
|
225
|
+
KDE::MessageBox.sorry nil, "The document #{url.pretty_url} doesn't seem to be a ruby file, so it can't be run"
|
|
226
|
+
return
|
|
227
|
+
end
|
|
209
228
|
run_ruby_for prj, file, dir, prj[:ruby, :options], run_in_terminal?(doc.project),
|
|
210
229
|
:files => [doc], :on_failure => :ask
|
|
211
230
|
end
|
|
@@ -215,32 +234,48 @@ Runs a file in ruby.
|
|
|
215
234
|
|
|
216
235
|
If the file is associated with a document, this method will work like {#run_document}.
|
|
217
236
|
|
|
218
|
-
|
|
237
|
+
The file can be local or remote.
|
|
238
|
+
|
|
239
|
+
Ruby will be executed from the directory where the file is or from the user's
|
|
240
|
+
home directory if the file is remote.
|
|
219
241
|
|
|
220
242
|
The program will be run in a terminal if the corresponding action is checked.
|
|
221
243
|
|
|
222
244
|
This method uses {#run_ruby_for}
|
|
223
245
|
|
|
224
246
|
*Note:* it is not possible to specify command line options to be passed to _file_.
|
|
225
|
-
@param [String, nil] file the path of the file to run. If *nil*, an "Open file"
|
|
247
|
+
@param [String, nil] file the path or url of the file to run. If *nil*, an "Open file"
|
|
226
248
|
dialog is shown to the user
|
|
227
249
|
@return [Boolean, nil] *true* or *false* depending on whether the ruby process
|
|
228
250
|
was started. If the user pressed the Cancel button of the dialog, *nil* is returned.
|
|
229
251
|
@see #run_ruby_for
|
|
230
252
|
=end
|
|
231
253
|
def run_file file = nil
|
|
232
|
-
|
|
233
|
-
|
|
254
|
+
if file then url = KDE::Url.new file
|
|
255
|
+
else
|
|
256
|
+
url = KDE::FileDialog.get_open_url KDE::Url.new(Ruber[:config][:general, :default_script_directory]),
|
|
234
257
|
"*.rb|Ruby files (*.rb)", nil, "Choose file to run"
|
|
235
|
-
return unless
|
|
258
|
+
return unless url
|
|
259
|
+
file = url.to_encoded.to_s
|
|
236
260
|
end
|
|
237
261
|
|
|
238
|
-
if doc = Ruber[:docs].
|
|
262
|
+
if doc = Ruber[:docs].document_for_url(url)
|
|
239
263
|
return run_document doc
|
|
240
264
|
end
|
|
241
265
|
|
|
242
|
-
|
|
243
|
-
|
|
266
|
+
if url.local_file?
|
|
267
|
+
dir = File.dirname(file)
|
|
268
|
+
file = File.basename(file)
|
|
269
|
+
else
|
|
270
|
+
@fake_file = FakeFileInfo.new Tempfile.new('ruby_development'), url
|
|
271
|
+
downloaded = KIO::NetAccess.download url, @fake_file.file.path, Ruber[:main_window]
|
|
272
|
+
unless downloaded
|
|
273
|
+
KDE::MessageBox.sorry Ruber[:main_window], KDE::NetAccess.last_error_string
|
|
274
|
+
return
|
|
275
|
+
end
|
|
276
|
+
file = @fake_file.file.path
|
|
277
|
+
dir = ENV['HOME']
|
|
278
|
+
end
|
|
244
279
|
run_ruby_for nil, file, dir, [], run_in_terminal?
|
|
245
280
|
end
|
|
246
281
|
slots :run_file
|
|
@@ -274,6 +309,30 @@ if the project has document scope
|
|
|
274
309
|
|
|
275
310
|
private
|
|
276
311
|
|
|
312
|
+
=begin rdoc
|
|
313
|
+
The command line to use to run the given ruby command in a terminal
|
|
314
|
+
|
|
315
|
+
This method replaces every instance of @%d@ in the @ruby/run_in_terminal_cmd@
|
|
316
|
+
setting with the working directory and every instance of @%r@ with the ruby command.
|
|
317
|
+
If @%r@ is sourrounded by spaces, it'll be replaced by _ruby_command_ as it is;
|
|
318
|
+
it @%r@ is part of a string, it'll be replaced by the elements of _ruby_command_
|
|
319
|
+
joined with spaces.
|
|
320
|
+
|
|
321
|
+
@param [String] dir the working directory
|
|
322
|
+
@param [Array<String>] ruby_command the ruby command to execute in the terminal
|
|
323
|
+
@return [Array<String>] the command to run the terminal, in a form suitable to be
|
|
324
|
+
passed to {#run_process}
|
|
325
|
+
=end
|
|
326
|
+
def terminal_command dir, ruby_command
|
|
327
|
+
cmd = Ruber[:config][:ruby, :run_in_terminal_cmd].split(/\s+/)
|
|
328
|
+
cmd.each do |c|
|
|
329
|
+
c.gsub!('%d', dir)
|
|
330
|
+
c.gsub!('%r', ruby_command.join(' ')) unless c == '%r'
|
|
331
|
+
end
|
|
332
|
+
cmd.each_with_index.find{|e, i| e == '%r'}.each_index{|i| cmd[i] = ruby_command}
|
|
333
|
+
cmd.flatten
|
|
334
|
+
end
|
|
335
|
+
|
|
277
336
|
=begin rdoc
|
|
278
337
|
Starts executing a given ruby program and displays the tool widget
|
|
279
338
|
|
|
@@ -295,7 +354,7 @@ started correctly
|
|
|
295
354
|
@see #run_ruby
|
|
296
355
|
@see RubyRunner::RubyRunnerPluginInternal#ruby_command_for
|
|
297
356
|
=end
|
|
298
|
-
def run_ruby_for what, file, dir, prog_options, run_in_terminal, autosave_opts, &blk
|
|
357
|
+
def run_ruby_for what, file, dir, prog_options, run_in_terminal, autosave_opts={}, &blk
|
|
299
358
|
ruby, *ruby_opts = ruby_command_for what, dir
|
|
300
359
|
opts = {
|
|
301
360
|
:dir => dir,
|
|
@@ -318,7 +377,8 @@ was started correctly and *nil* if no document exists
|
|
|
318
377
|
=end
|
|
319
378
|
def run_current_document
|
|
320
379
|
doc = Ruber[:main_window].current_document
|
|
321
|
-
|
|
380
|
+
return unless doc
|
|
381
|
+
run_document doc
|
|
322
382
|
end
|
|
323
383
|
slots :run_current_document
|
|
324
384
|
|
|
@@ -354,9 +414,60 @@ Resets the UI, scrolls the tool widget at the end and gives focus to the editor
|
|
|
354
414
|
Ruber[:main_window].change_state 'ruby_running', false
|
|
355
415
|
@widget.scroll_to -1
|
|
356
416
|
Ruber[:main_window].focus_on_editor
|
|
417
|
+
if @fake_file
|
|
418
|
+
@fake_file.file.close true
|
|
419
|
+
@fake_file = nil
|
|
420
|
+
end
|
|
357
421
|
nil
|
|
358
422
|
end
|
|
359
423
|
slots 'ruby_exited(int, QString)'
|
|
424
|
+
|
|
425
|
+
=begin rdoc
|
|
426
|
+
Replaces the path of the fake file used for running remote documents with the URL
|
|
427
|
+
of the document
|
|
428
|
+
|
|
429
|
+
It does nothing if there's no fake file (that is, if we're not executing the document
|
|
430
|
+
associated with a remote file).
|
|
431
|
+
|
|
432
|
+
*Note:* for efficency reasons the replacement is performed in place, so create a
|
|
433
|
+
duplicate of the array before calling this method if you need to preserve it.
|
|
434
|
+
|
|
435
|
+
@param [Array<String>] the lines of text to perform the replacement into
|
|
436
|
+
@return [Array<String>] the lines with all occurrences of the fake file path replaced
|
|
437
|
+
with the url of the remote file. If no fake file is in use, _lines_ will be returned
|
|
438
|
+
unchanged
|
|
439
|
+
=end
|
|
440
|
+
def replace_fake_file lines
|
|
441
|
+
if @fake_file
|
|
442
|
+
lines.map!{|l| l.gsub(@fake_file.file.path, @fake_file.url.pretty_url)}
|
|
443
|
+
end
|
|
444
|
+
lines
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
=begin rdoc
|
|
448
|
+
Override of {ExternalProgramPlugin#process_standard_output}
|
|
449
|
+
|
|
450
|
+
It processes the lines using {#replace_fake_file} before passing it to the base
|
|
451
|
+
class's method
|
|
452
|
+
@param (see Ruber::ExternalProgramPlugin#process_standard_output)
|
|
453
|
+
@return (see Ruber::ExternalProgramPlugin#process_standard_output)
|
|
454
|
+
=end
|
|
455
|
+
def process_standard_output lines
|
|
456
|
+
super replace_fake_file(lines)
|
|
457
|
+
end
|
|
458
|
+
|
|
459
|
+
=begin rdoc
|
|
460
|
+
Override of {ExternalProgramPlugin#process_standard_error}
|
|
461
|
+
|
|
462
|
+
It processes the lines using {#replace_fake_file} before passing it to the base
|
|
463
|
+
class's method
|
|
464
|
+
@param (see Ruber::ExternalProgramPlugin#process_standard_error)
|
|
465
|
+
@return (see Ruber::ExternalProgramPlugin#process_standard_error)
|
|
466
|
+
=end
|
|
467
|
+
def process_standard_error lines
|
|
468
|
+
super replace_fake_file(lines)
|
|
469
|
+
end
|
|
470
|
+
|
|
360
471
|
|
|
361
472
|
end
|
|
362
473
|
|
|
@@ -447,6 +558,16 @@ project with document scope.
|
|
|
447
558
|
end
|
|
448
559
|
|
|
449
560
|
end
|
|
561
|
+
|
|
562
|
+
class ConfigWidget < Qt::Widget
|
|
563
|
+
|
|
564
|
+
def initialize parent = nil
|
|
565
|
+
super
|
|
566
|
+
@ui = Ui::RubyDevelopmentConfigWidget.new
|
|
567
|
+
@ui.setupUi self
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
end
|
|
450
571
|
|
|
451
572
|
end
|
|
452
573
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
** Form generated from reading ui file 'config_widget.ui'
|
|
3
|
+
**
|
|
4
|
+
** Created: mar gen 11 14:57:22 2011
|
|
5
|
+
** by: Qt User Interface Compiler version 4.7.1
|
|
6
|
+
**
|
|
7
|
+
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
|
8
|
+
=end
|
|
9
|
+
|
|
10
|
+
class Ui_RubyDevelopmentConfigWidget
|
|
11
|
+
attr_reader :horizontalLayout
|
|
12
|
+
attr_reader :label
|
|
13
|
+
attr_reader :_ruby__run_in_terminal_cmd
|
|
14
|
+
|
|
15
|
+
def setupUi(rubyDevelopmentConfigWidget)
|
|
16
|
+
if rubyDevelopmentConfigWidget.objectName.nil?
|
|
17
|
+
rubyDevelopmentConfigWidget.objectName = "rubyDevelopmentConfigWidget"
|
|
18
|
+
end
|
|
19
|
+
rubyDevelopmentConfigWidget.resize(400, 38)
|
|
20
|
+
@horizontalLayout = Qt::HBoxLayout.new(rubyDevelopmentConfigWidget)
|
|
21
|
+
@horizontalLayout.objectName = "horizontalLayout"
|
|
22
|
+
@label = Qt::Label.new(rubyDevelopmentConfigWidget)
|
|
23
|
+
@label.objectName = "label"
|
|
24
|
+
|
|
25
|
+
@horizontalLayout.addWidget(@label)
|
|
26
|
+
|
|
27
|
+
@_ruby__run_in_terminal_cmd = KDE::LineEdit.new(rubyDevelopmentConfigWidget)
|
|
28
|
+
@_ruby__run_in_terminal_cmd.objectName = "_ruby__run_in_terminal_cmd"
|
|
29
|
+
|
|
30
|
+
@horizontalLayout.addWidget(@_ruby__run_in_terminal_cmd)
|
|
31
|
+
|
|
32
|
+
@label.buddy = @_ruby__run_in_terminal_cmd
|
|
33
|
+
|
|
34
|
+
retranslateUi(rubyDevelopmentConfigWidget)
|
|
35
|
+
|
|
36
|
+
Qt::MetaObject.connectSlotsByName(rubyDevelopmentConfigWidget)
|
|
37
|
+
end # setupUi
|
|
38
|
+
|
|
39
|
+
def setup_ui(rubyDevelopmentConfigWidget)
|
|
40
|
+
setupUi(rubyDevelopmentConfigWidget)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def retranslateUi(rubyDevelopmentConfigWidget)
|
|
44
|
+
rubyDevelopmentConfigWidget.windowTitle = Qt::Application.translate("RubyDevelopmentConfigWidget", "Form", nil, Qt::Application::UnicodeUTF8)
|
|
45
|
+
@label.toolTip = Qt::Application.translate("RubyDevelopmentConfigWidget", "The command to use to run a ruby script in a terminal", nil, Qt::Application::UnicodeUTF8)
|
|
46
|
+
@label.whatsThis = Qt::Application.translate("RubyDevelopmentConfigWidget", "In the command line, use %d to indicate the initial working directory for the terminal and %r to indicate where to put the ruby command line. The %r sequence should be either sourrounded by spaces or have a space before it and the end of the command after it.\n" \
|
|
47
|
+
"\n" \
|
|
48
|
+
"Note that you can't use arguments containing spaces in the command line.", nil, Qt::Application::UnicodeUTF8)
|
|
49
|
+
@label.text = Qt::Application.translate("RubyDevelopmentConfigWidget", "&Terminal", nil, Qt::Application::UnicodeUTF8)
|
|
50
|
+
@_ruby__run_in_terminal_cmd.toolTip = Qt::Application.translate("RubyDevelopmentConfigWidget", "The command to use to run a ruby script in a terminal", nil, Qt::Application::UnicodeUTF8)
|
|
51
|
+
@_ruby__run_in_terminal_cmd.whatsThis = Qt::Application.translate("RubyDevelopmentConfigWidget", "In the command line, use %d to indicate the initial working directory for the terminal and %r to indicate where to put the ruby command line.\n" \
|
|
52
|
+
"\n" \
|
|
53
|
+
"Note that you can't use arguments containing spaces in the command line", nil, Qt::Application::UnicodeUTF8)
|
|
54
|
+
end # retranslateUi
|
|
55
|
+
|
|
56
|
+
def retranslate_ui(rubyDevelopmentConfigWidget)
|
|
57
|
+
retranslateUi(rubyDevelopmentConfigWidget)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
module Ui
|
|
63
|
+
class RubyDevelopmentConfigWidget < Ui_RubyDevelopmentConfigWidget
|
|
64
|
+
end
|
|
65
|
+
end # module Ui
|
|
66
|
+
|