ruber 0.0.1.1
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/COPYING +339 -0
- data/INSTALL +137 -0
- data/LICENSE +8 -0
- data/bin/ruber +65 -0
- data/data/share/apps/ruber/core_components.yaml +31 -0
- data/data/share/apps/ruber/ruberui.rc +109 -0
- data/data/share/icons/ruber.png +0 -0
- data/data/share/pixmaps/ruby.png +0 -0
- data/icons/ruber-16.png +0 -0
- data/icons/ruber-32.png +0 -0
- data/icons/ruber-48.png +0 -0
- data/icons/ruber-8.png +0 -0
- data/lib/ruber/application/application.rb +288 -0
- data/lib/ruber/application/plugin.yaml +11 -0
- data/lib/ruber/component_manager.rb +899 -0
- data/lib/ruber/config/config.rb +82 -0
- data/lib/ruber/config/plugin.yaml +3 -0
- data/lib/ruber/document_project.rb +209 -0
- data/lib/ruber/documents/document_list.rb +416 -0
- data/lib/ruber/documents/plugin.yaml +4 -0
- data/lib/ruber/editor/document.rb +506 -0
- data/lib/ruber/editor/editor_view.rb +167 -0
- data/lib/ruber/editor/ktexteditor_wrapper.rb +202 -0
- data/lib/ruber/exception_widgets.rb +245 -0
- data/lib/ruber/external_program_plugin.rb +397 -0
- data/lib/ruber/filtered_output_widget.rb +342 -0
- data/lib/ruber/gui_states_handler.rb +231 -0
- data/lib/ruber/kde_config_option_backend.rb +167 -0
- data/lib/ruber/kde_sugar.rb +249 -0
- data/lib/ruber/main_window/choose_plugins_dlg.rb +353 -0
- data/lib/ruber/main_window/main_window.rb +524 -0
- data/lib/ruber/main_window/main_window_actions.rb +537 -0
- data/lib/ruber/main_window/main_window_internal.rb +239 -0
- data/lib/ruber/main_window/open_file_in_project_dlg.rb +212 -0
- data/lib/ruber/main_window/output_color_widget.rb +35 -0
- data/lib/ruber/main_window/plugin.yaml +58 -0
- data/lib/ruber/main_window/save_modified_files_dlg.rb +89 -0
- data/lib/ruber/main_window/status_bar.rb +156 -0
- data/lib/ruber/main_window/ui/choose_plugins_widget.rb +90 -0
- data/lib/ruber/main_window/ui/choose_plugins_widget.ui +77 -0
- data/lib/ruber/main_window/ui/main_window_settings_widget.rb +108 -0
- data/lib/ruber/main_window/ui/main_window_settings_widget.ui +89 -0
- data/lib/ruber/main_window/ui/new_project_widget.rb +119 -0
- data/lib/ruber/main_window/ui/new_project_widget.ui +178 -0
- data/lib/ruber/main_window/ui/open_file_in_project_dlg.rb +109 -0
- data/lib/ruber/main_window/ui/open_file_in_project_dlg.ui +168 -0
- data/lib/ruber/main_window/ui/output_color_widget.rb +241 -0
- data/lib/ruber/main_window/ui/output_color_widget.ui +204 -0
- data/lib/ruber/main_window/workspace.rb +442 -0
- data/lib/ruber/output_widget.rb +1093 -0
- data/lib/ruber/plugin.rb +264 -0
- data/lib/ruber/plugin_like.rb +589 -0
- data/lib/ruber/plugin_specification.rb +106 -0
- data/lib/ruber/plugin_specification_reader.rb +451 -0
- data/lib/ruber/project.rb +493 -0
- data/lib/ruber/project_backend.rb +105 -0
- data/lib/ruber/projects/plugin.yaml +11 -0
- data/lib/ruber/projects/project_files_list.rb +314 -0
- data/lib/ruber/projects/project_files_widget.rb +301 -0
- data/lib/ruber/projects/project_list.rb +314 -0
- data/lib/ruber/projects/ui/project_files_rule_chooser_widget.rb +74 -0
- data/lib/ruber/projects/ui/project_files_rule_chooser_widget.ui +61 -0
- data/lib/ruber/projects/ui/project_files_widget.rb +117 -0
- data/lib/ruber/projects/ui/project_files_widget.ui +123 -0
- data/lib/ruber/qt_sugar.rb +673 -0
- data/lib/ruber/settings_container.rb +515 -0
- data/lib/ruber/settings_dialog.rb +244 -0
- data/lib/ruber/settings_dialog_manager.rb +503 -0
- data/lib/ruber/utils.rb +414 -0
- data/lib/ruber/yaml_option_backend.rb +159 -0
- data/outsider_files +15 -0
- data/plugins/autosave/autosave.rb +404 -0
- data/plugins/autosave/plugin.yaml +16 -0
- data/plugins/autosave/ui/autosave_config_widget.rb +83 -0
- data/plugins/autosave/ui/autosave_config_widget.ui +68 -0
- data/plugins/command/command.png +0 -0
- data/plugins/command/command.rb +74 -0
- data/plugins/command/plugin.yaml +11 -0
- data/plugins/find_in_files/find_in_files.rb +337 -0
- data/plugins/find_in_files/find_in_files_dlg.rb +411 -0
- data/plugins/find_in_files/find_in_files_ui.rc +11 -0
- data/plugins/find_in_files/find_in_files_widgets.rb +485 -0
- data/plugins/find_in_files/plugin.yaml +23 -0
- data/plugins/find_in_files/ui/config_widget.rb +58 -0
- data/plugins/find_in_files/ui/config_widget.ui +41 -0
- data/plugins/find_in_files/ui/find_in_files_widget.rb +260 -0
- data/plugins/find_in_files/ui/find_in_files_widget.ui +324 -0
- data/plugins/project_browser/plugin.yaml +10 -0
- data/plugins/project_browser/project_browser.rb +245 -0
- data/plugins/rake/plugin.yaml +39 -0
- data/plugins/rake/rake.png +0 -0
- data/plugins/rake/rake.rb +567 -0
- data/plugins/rake/rake_extension.rb +153 -0
- data/plugins/rake/rake_widgets.rb +615 -0
- data/plugins/rake/rakeui.rc +27 -0
- data/plugins/rake/ui/add_quick_task_widget.rb +71 -0
- data/plugins/rake/ui/add_quick_task_widget.ui +59 -0
- data/plugins/rake/ui/choose_task_widget.rb +77 -0
- data/plugins/rake/ui/choose_task_widget.ui +72 -0
- data/plugins/rake/ui/config_widget.rb +127 -0
- data/plugins/rake/ui/config_widget.ui +123 -0
- data/plugins/rake/ui/project_widget.rb +217 -0
- data/plugins/rake/ui/project_widget.ui +246 -0
- data/plugins/rspec/plugin.yaml +30 -0
- data/plugins/rspec/rspec.png +0 -0
- data/plugins/rspec/rspec.rb +945 -0
- data/plugins/rspec/rspec.svg +90 -0
- data/plugins/rspec/rspecui.rc +20 -0
- data/plugins/rspec/ruber_rspec_formatter.rb +312 -0
- data/plugins/rspec/ui/rspec_project_widget.rb +170 -0
- data/plugins/rspec/ui/rspec_project_widget.ui +193 -0
- data/plugins/ruby_development/plugin.yaml +27 -0
- data/plugins/ruby_development/ruby_development.png +0 -0
- data/plugins/ruby_development/ruby_development.rb +453 -0
- data/plugins/ruby_development/ruby_developmentui.rc +19 -0
- data/plugins/ruby_development/ui/project_widget.rb +112 -0
- data/plugins/ruby_development/ui/project_widget.ui +108 -0
- data/plugins/ruby_runner/config_widget.rb +116 -0
- data/plugins/ruby_runner/plugin.yaml +26 -0
- data/plugins/ruby_runner/project_widget.rb +62 -0
- data/plugins/ruby_runner/ruby.png +0 -0
- data/plugins/ruby_runner/ruby_interpretersui.rc +26 -0
- data/plugins/ruby_runner/ruby_runner.rb +411 -0
- data/plugins/ruby_runner/ui/config_widget.rb +92 -0
- data/plugins/ruby_runner/ui/config_widget.ui +91 -0
- data/plugins/ruby_runner/ui/project_widget.rb +60 -0
- data/plugins/ruby_runner/ui/project_widget.ui +48 -0
- data/plugins/ruby_runner/ui/ruby_runnner_plugin_option_widget.rb +59 -0
- data/plugins/ruby_runner/ui/ruby_runnner_plugin_option_widget.ui +44 -0
- data/plugins/state/plugin.yaml +28 -0
- data/plugins/state/state.rb +520 -0
- data/plugins/state/ui/config_widget.rb +92 -0
- data/plugins/state/ui/config_widget.ui +89 -0
- data/plugins/syntax_checker/plugin.yaml +18 -0
- data/plugins/syntax_checker/syntax_checker.rb +662 -0
- data/ruber.desktop +10 -0
- data/spec/annotation_model_spec.rb +174 -0
- data/spec/common.rb +119 -0
- data/spec/component_manager_spec.rb +1259 -0
- data/spec/document_list_spec.rb +626 -0
- data/spec/document_project_spec.rb +373 -0
- data/spec/document_spec.rb +779 -0
- data/spec/editor_view_spec.rb +167 -0
- data/spec/external_program_plugin_spec.rb +676 -0
- data/spec/filtered_output_widget_spec.rb +642 -0
- data/spec/gui_states_handler_spec.rb +304 -0
- data/spec/kde_config_option_backend_spec.rb +214 -0
- data/spec/kde_sugar_spec.rb +101 -0
- data/spec/ktexteditor_wrapper_spec.rb +305 -0
- data/spec/output_widget_spec.rb +1703 -0
- data/spec/plugin_spec.rb +1393 -0
- data/spec/plugin_specification_reader_spec.rb +1765 -0
- data/spec/plugin_specification_spec.rb +401 -0
- data/spec/project_backend_spec.rb +172 -0
- data/spec/project_files_list_spec.rb +401 -0
- data/spec/project_list_spec.rb +511 -0
- data/spec/project_spec.rb +990 -0
- data/spec/qt_sugar_spec.rb +328 -0
- data/spec/settings_container_spec.rb +617 -0
- data/spec/settings_dialog_manager_spec.rb +773 -0
- data/spec/settings_dialog_spec.rb +419 -0
- data/spec/state_spec.rb +991 -0
- data/spec/utils_spec.rb +406 -0
- data/spec/workspace_spec.rb +869 -0
- data/spec/yaml_option_backend_spec.rb +246 -0
- metadata +284 -0
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<!DOCTYPE kpartgui SYSTEM 'kpartgui.dtd'>
|
|
2
|
+
<kpartgui version="1" name="ruber-ruby_runner_plugin" >
|
|
3
|
+
<MenuBar>
|
|
4
|
+
<Menu noMerge="1" name="ruby" >
|
|
5
|
+
<text>&Ruby</text>
|
|
6
|
+
<Separator/>
|
|
7
|
+
<Menu name="interpreter">
|
|
8
|
+
<text>Ruby &Interpreter</text>
|
|
9
|
+
<Action name="ruby_runner-configured_interpreter"/>
|
|
10
|
+
<Separator/>
|
|
11
|
+
<ActionList name="ruby_runner-interpreters"/>
|
|
12
|
+
</Menu>
|
|
13
|
+
<Separator/>
|
|
14
|
+
<Action name="ruby_runner-run" />
|
|
15
|
+
<Action name="ruby_runner-run_current_file" text="Run current file" />
|
|
16
|
+
<Action name="ruby_runner-run_file" />
|
|
17
|
+
<Separator/>
|
|
18
|
+
<Action name="ruby_runner-stop" />
|
|
19
|
+
<Separator/>
|
|
20
|
+
<Action name="ruby_runner-run_in_terminal"/>
|
|
21
|
+
<DefineGroup name="ruby_tools"/>
|
|
22
|
+
<Merge/>
|
|
23
|
+
</Menu>
|
|
24
|
+
</MenuBar>
|
|
25
|
+
<ActionProperties/>
|
|
26
|
+
</kpartgui>
|
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Copyright (C) 2010 by Stefano Crocco
|
|
3
|
+
stefano.crocco@alice.it
|
|
4
|
+
|
|
5
|
+
This program is free software; you can redistribute it andor modify
|
|
6
|
+
it under the terms of the GNU General Public License as published by
|
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License
|
|
16
|
+
along with this program; if not, write to the
|
|
17
|
+
Free Software Foundation, Inc.,
|
|
18
|
+
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
19
|
+
=end
|
|
20
|
+
|
|
21
|
+
require 'shellwords'
|
|
22
|
+
|
|
23
|
+
require 'ruber/plugin_specification_reader'
|
|
24
|
+
require 'ruber/external_program_plugin'
|
|
25
|
+
require_relative 'ui/ruby_runnner_plugin_option_widget'
|
|
26
|
+
|
|
27
|
+
require 'ruby_runner/project_widget'
|
|
28
|
+
require 'ruby_runner/config_widget'
|
|
29
|
+
|
|
30
|
+
module Ruber
|
|
31
|
+
|
|
32
|
+
=begin rdoc
|
|
33
|
+
Plugin providing support for running ruby programs.
|
|
34
|
+
|
|
35
|
+
It provides:
|
|
36
|
+
* an option for the user to choose which ruby interpreter to use (both at global
|
|
37
|
+
and project level)
|
|
38
|
+
* a menu entry to temporarily choose another interpreter
|
|
39
|
+
* a ready to use widget where the user can enter the options to pass to ruby
|
|
40
|
+
* a class from which plugins which need to run a ruby program may inherit
|
|
41
|
+
|
|
42
|
+
@api feature ruby_runner
|
|
43
|
+
@plugin RubyInterpretersPlugin
|
|
44
|
+
@api_class Ruber::RubyRunner::RubyOptionsWidget
|
|
45
|
+
@api_class Ruber::RubyRunner::RubyRunnerPluginInternal Ruber::RubyRunner::RubyRunnerPlugin
|
|
46
|
+
@config_option ruby interpreters [<String>] a list of the interpreters to display
|
|
47
|
+
in the menu
|
|
48
|
+
@config_option ruby ruby [String] the path of the default interpreter to use
|
|
49
|
+
@config_option ruby ruby_options [<String>] a list of the options to pass to the
|
|
50
|
+
ruby interpreter
|
|
51
|
+
@project_option ruby ruby [String] the path of the interpreter to use for the project
|
|
52
|
+
=end
|
|
53
|
+
module RubyRunner
|
|
54
|
+
|
|
55
|
+
=begin rdoc
|
|
56
|
+
Widget to use to set the @ruby_options@ setting.
|
|
57
|
+
|
|
58
|
+
It is made by a KDE::LineEdit and the corresponding Qt::Label.
|
|
59
|
+
It already provides the signal property to be used by SettingsDialogContainer (set
|
|
60
|
+
to <tt>text_changed(QString)</tt>).
|
|
61
|
+
|
|
62
|
+
Plugin developers should only need to put this widget inside their project widget
|
|
63
|
+
and give it the appropriate name (usually <tt>_grp__ruby_options</tt>, where _grp_
|
|
64
|
+
is the group specified in RubyRunnerPlugin.new)
|
|
65
|
+
|
|
66
|
+
If something fancier is needed, the underlying label and line edit widgets can
|
|
67
|
+
be accessed using the @label_widget@ and @text_widget@ methods.
|
|
68
|
+
|
|
69
|
+
@todo Put this class inside the namespace after it's been changed from Ruber (as rbuic
|
|
70
|
+
puts all classes starting with K in the KDE namespace)
|
|
71
|
+
=end
|
|
72
|
+
class RubyOptionsWidget < Ruber::ProjectConfigWidget
|
|
73
|
+
|
|
74
|
+
=begin rdoc
|
|
75
|
+
Signal emitted whenever the text inside the line edit changes.
|
|
76
|
+
|
|
77
|
+
@param [String] text the new content of the line edit
|
|
78
|
+
=end
|
|
79
|
+
signals 'text_changed(QString)'
|
|
80
|
+
|
|
81
|
+
=begin rdoc
|
|
82
|
+
Creates a new instance
|
|
83
|
+
|
|
84
|
+
@param [Qt::Widget] parent the parent widget
|
|
85
|
+
=end
|
|
86
|
+
def initialize parent = nil
|
|
87
|
+
super
|
|
88
|
+
@ui = Ui::RubyRunnerPluginOptionWidget.new
|
|
89
|
+
@ui.setupUi self
|
|
90
|
+
connect @ui.text, SIGNAL('textChanged(QString)'), self, SIGNAL('text_changed(QString)')
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
=begin rdoc
|
|
94
|
+
The label widget.
|
|
95
|
+
|
|
96
|
+
This is useful, for example, if you don't like the default label.
|
|
97
|
+
|
|
98
|
+
@return [Qt::Label] the label widget
|
|
99
|
+
=end
|
|
100
|
+
def label_widget
|
|
101
|
+
@ui.label
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
=begin rdoc
|
|
105
|
+
The line edit widget widget.
|
|
106
|
+
|
|
107
|
+
In most cases, you shouldn't need to use this
|
|
108
|
+
|
|
109
|
+
@return [KDE::LineEdit] the line edit widget
|
|
110
|
+
|
|
111
|
+
=end
|
|
112
|
+
def text_widget
|
|
113
|
+
@ui.text
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
=begin rdoc
|
|
117
|
+
Sets the text in the line edit
|
|
118
|
+
|
|
119
|
+
@param [<String>] val an array of strings, with each string being a shell token
|
|
120
|
+
=end
|
|
121
|
+
def text= val
|
|
122
|
+
@ui.text.text = val.join ' '
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
=begin rdoc
|
|
126
|
+
Converts the contents of the line edit to an array
|
|
127
|
+
|
|
128
|
+
@return [<String>] an array of shell tokens
|
|
129
|
+
=end
|
|
130
|
+
def text
|
|
131
|
+
Shellwords.split_with_quotes @ui.text.text
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
=begin rdoc
|
|
137
|
+
The plugin object for the @ruby_runner@ feature.
|
|
138
|
+
|
|
139
|
+
This class provides a way to set the ruby interpreter to use, allowing to override
|
|
140
|
+
the interpreter set globally or for the current project. This choice can be made
|
|
141
|
+
programmaticaly or by the user, using the "Interpreter" submenu added by this class
|
|
142
|
+
to the "Ruby" menu.
|
|
143
|
+
|
|
144
|
+
The interpreters which can be chosen are configured globally by the user.
|
|
145
|
+
|
|
146
|
+
@api_method #chosen_interpreter
|
|
147
|
+
@api_method #choose_interpreter
|
|
148
|
+
=end
|
|
149
|
+
class RubyInterpretersPlugin < GuiPlugin
|
|
150
|
+
|
|
151
|
+
=begin rdoc
|
|
152
|
+
Creates a new RubyInterpretersPlugin.
|
|
153
|
+
@param [Ruber::PluginSpecification] psf the plugin specification object describing
|
|
154
|
+
the plugin
|
|
155
|
+
=end
|
|
156
|
+
def initialize psf
|
|
157
|
+
silently do
|
|
158
|
+
Object.const_set :RubyOptionsWidget, RubyOptionsWidget
|
|
159
|
+
Ruber::RubyRunner.const_set :RubyRunnerPlugin, RubyRunnerPluginInternal
|
|
160
|
+
end
|
|
161
|
+
super
|
|
162
|
+
@default_interpreter_action = action_collection.action('ruby_runner-configured_interpreter')
|
|
163
|
+
@interpreter_actions = []
|
|
164
|
+
@interpreters_group = Qt::ActionGroup.new self
|
|
165
|
+
@interpreters_group.add_action @default_interpreter_action
|
|
166
|
+
@default_interpreter_action.checked = true
|
|
167
|
+
fill_interpreters_menu
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
=begin rdoc
|
|
171
|
+
The path of the interpreter chosen by the user
|
|
172
|
+
@return [String,nil] a string with the path of the interpreter to use or *nil* if
|
|
173
|
+
the default interpreter should be used
|
|
174
|
+
=end
|
|
175
|
+
def chosen_interpreter
|
|
176
|
+
checked = @interpreters_group.checked_action
|
|
177
|
+
checked.same?( @default_interpreter_action) ? nil : checked.object_name
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
=begin rdoc
|
|
181
|
+
Sets the ruby interpreter to use.
|
|
182
|
+
|
|
183
|
+
Calling this method will check one of the entries of the "Interpreters" submenu
|
|
184
|
+
|
|
185
|
+
@param [String, nil] arg the interpreter to use. If *nil*, the default interpreter
|
|
186
|
+
will be used. If it is a string, it is the path of the interpreter to use. If this
|
|
187
|
+
doesn't correspond to one of the entries in the "Interpreters" submenu, nothing
|
|
188
|
+
is done.
|
|
189
|
+
@return [String,nil] the chosen interpreter or *nil* if the default one should
|
|
190
|
+
be used.
|
|
191
|
+
=end
|
|
192
|
+
def choose_interpreter arg
|
|
193
|
+
if arg.nil? then @default_interpreter_action.checked = true
|
|
194
|
+
else
|
|
195
|
+
action = @interpreters_group.actions.find{|a| a.object_name == arg}
|
|
196
|
+
action.checked = true if action
|
|
197
|
+
end
|
|
198
|
+
chosen_interpreter
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
private
|
|
202
|
+
|
|
203
|
+
=begin rdoc
|
|
204
|
+
Finds the ruby interpreters availlable on the system.
|
|
205
|
+
|
|
206
|
+
The interpreters are searched using the @which -a@ command (this means that only
|
|
207
|
+
interpreters in the @PATH@ environment variable will be found). The names which
|
|
208
|
+
are tried are: @ruby@, @ruby19@, @ruby18@, @ruby1.9@ and @ruby1.8@.
|
|
209
|
+
@return [<String>] a list with the paths of the ruby interpreters availlable on
|
|
210
|
+
the system
|
|
211
|
+
=end
|
|
212
|
+
def find_interpreters
|
|
213
|
+
look_for = %w[ruby ruby19 ruby18 ruby1.9 ruby1.8]
|
|
214
|
+
look_for.map{|r| interpreters = `which #{r} 2> /dev/null`.split_lines}.flatten
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
=begin rdoc
|
|
218
|
+
Clears and refills the "Interpreters" submenu
|
|
219
|
+
|
|
220
|
+
The list of availlable interpreters is read from the @ruby/interpreters@ config
|
|
221
|
+
option
|
|
222
|
+
|
|
223
|
+
The selection is preserved if possible (that is, if an interpreter with the same
|
|
224
|
+
path as the previously selected one still exists). If this isn't possible, the
|
|
225
|
+
default entry is selected.
|
|
226
|
+
|
|
227
|
+
@return *nil*
|
|
228
|
+
=end
|
|
229
|
+
def fill_interpreters_menu
|
|
230
|
+
@gui.unplug_action_list 'ruby_runner-interpreters'
|
|
231
|
+
old_checked = @interpreters_group.checked_action.object_name
|
|
232
|
+
@interpreter_actions.each{|a| @interpreters_group.remove_action a}
|
|
233
|
+
@interpreter_actions.clear
|
|
234
|
+
@interpreter_actions = Ruber[:config][:ruby, :interpreters].map do |i|
|
|
235
|
+
a = KDE::ToggleAction.new i, action_collection
|
|
236
|
+
a.object_name = i
|
|
237
|
+
@interpreters_group.add_action a
|
|
238
|
+
a.checked = true if i == old_checked
|
|
239
|
+
a
|
|
240
|
+
end
|
|
241
|
+
@gui.plug_action_list 'ruby_runner-interpreters', @interpreter_actions
|
|
242
|
+
unless @interpreters_group.checked_action
|
|
243
|
+
action_collection.action('ruby_runner-configured_interpreter').checked = true
|
|
244
|
+
end
|
|
245
|
+
nil
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
=begin
|
|
251
|
+
Abstract class plugins which need to run a ruby program can derive from.
|
|
252
|
+
|
|
253
|
+
It provides some convenience methods to retrieve an option for a target (which
|
|
254
|
+
can be either a global project, a document or a file) so that, if the option isn't
|
|
255
|
+
found in the target itself, a global value is used. It also provide methods to
|
|
256
|
+
retrieve the path of the ruby interpreter to use for a given target, taking into
|
|
257
|
+
account the choice made by the user in the "Interpreters" submenu.
|
|
258
|
+
|
|
259
|
+
Lastly, this class adds a project option called @ruby_options@ to the PS for the
|
|
260
|
+
plugin.
|
|
261
|
+
|
|
262
|
+
*Note:* classes which want to derive from this class should derive from
|
|
263
|
+
{Ruber::RubyRunner::RubyRunnerPlugin} rather than from this.
|
|
264
|
+
|
|
265
|
+
@api_method #option_for
|
|
266
|
+
@api_method #interpreter_for
|
|
267
|
+
@api_method #ruby_command_for
|
|
268
|
+
=end
|
|
269
|
+
class RubyRunnerPluginInternal < ExternalProgramPlugin
|
|
270
|
+
|
|
271
|
+
=begin rdoc
|
|
272
|
+
Creates a new instance.
|
|
273
|
+
|
|
274
|
+
Before passing it to RunnerPlugin's constructor, it adds the @ruby_options@
|
|
275
|
+
project option to the plugin specification object, in the given group.
|
|
276
|
+
|
|
277
|
+
@param [PluginSpecification] pso the plugin specification object associated with
|
|
278
|
+
the plugin
|
|
279
|
+
@param [String,Symbol] group the group the @ruby_options@ option should be added
|
|
280
|
+
to. If an option called @ruby_options@ already exists in the group, it won't be
|
|
281
|
+
overwritten
|
|
282
|
+
@param [Hash] rules the rules to apply to the @ruby_options@ option
|
|
283
|
+
@param [Integer,nil] order has the same meaning as in the PSF and applies to the
|
|
284
|
+
@param line_buffered [Boolean] as in {ExternalProgramPlugin#initialize}
|
|
285
|
+
|
|
286
|
+
@option rules [<Symbol>] scope ([:global]) has the same meaning as in the PSF,
|
|
287
|
+
but cannot contain the @:all@ entry and *must* be an array.
|
|
288
|
+
@option rules [<String>] mimetypes ([]) has the same meaning as in the PSF, but
|
|
289
|
+
must be an array, even if it only contains one entry
|
|
290
|
+
@option rules [<String>] file_extension ([]) has the same meaning as in the PSF, but
|
|
291
|
+
must be an array, even if it only contains one entry
|
|
292
|
+
=end
|
|
293
|
+
def initialize pso, group, rules = {}, order = nil, line_buffered = true
|
|
294
|
+
group = group.to_sym
|
|
295
|
+
@group = group
|
|
296
|
+
default_rules = {:scope => [:global], :file_extension => [], :mimetype => []}
|
|
297
|
+
rules = default_rules.merge rules
|
|
298
|
+
ruby_options_data = {
|
|
299
|
+
:name => :ruby_options,
|
|
300
|
+
:group => group,
|
|
301
|
+
:default => Ruber[:config][:ruby, :ruby_options],
|
|
302
|
+
:scope => rules[:scope],
|
|
303
|
+
:mimetype => rules[:mimetype],
|
|
304
|
+
:file_extension => rules[:file_extension],
|
|
305
|
+
:order => order,
|
|
306
|
+
}
|
|
307
|
+
pso.project_options[[group, :ruby_options]] ||= PluginSpecificationReader::Option.new ruby_options_data
|
|
308
|
+
super pso, line_buffered
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
=begin rdoc
|
|
312
|
+
Searches for an option for the given target.
|
|
313
|
+
|
|
314
|
+
The behaviour of this method depends on what _target_ is:
|
|
315
|
+
* if it is an {AbstractProject}, the option is searched in it
|
|
316
|
+
* if it is a {Document} or a string representing a file name and belongins to
|
|
317
|
+
the current project, the option is searched in the current project
|
|
318
|
+
* if it is a {Document} but doesn't belong to the current project (or no current
|
|
319
|
+
project exists), the option is searched in the document's own project
|
|
320
|
+
* if it is a string representing a file which doesn't belong to the current project
|
|
321
|
+
(or there's no current project) the option is looked for in the global configuration
|
|
322
|
+
object.
|
|
323
|
+
|
|
324
|
+
In all cases, if the search fails, the option is looked up in the global configuration
|
|
325
|
+
object.
|
|
326
|
+
|
|
327
|
+
@param [AbstractProject, Document, String, nil] target the object to look up the
|
|
328
|
+
option for. If *nil*, the option will directly be looked up in the global configuration
|
|
329
|
+
object
|
|
330
|
+
@param [Symbol] group the group the option belongs to
|
|
331
|
+
@param [Symbol] name the name of the option
|
|
332
|
+
@param [Boolean] ignore_project if *true* the option won't be looked for in the
|
|
333
|
+
current project, even if _target_ is a {Document} or the name of a file belonging
|
|
334
|
+
to it
|
|
335
|
+
@param [Boolean] abs it has the same meaning as in {SettingsContainer#[]}
|
|
336
|
+
@raise ArgumentError if the option can be found
|
|
337
|
+
=end
|
|
338
|
+
def option_for target, group, name, ignore_project = false, abs = false
|
|
339
|
+
cont = []
|
|
340
|
+
case target
|
|
341
|
+
when AbstractProject then cont << target
|
|
342
|
+
when Document
|
|
343
|
+
cont << (ignore_project ? (target.own_project) : target.project)
|
|
344
|
+
when String
|
|
345
|
+
if !ignore_project and Ruber[:projects].project_for_file target
|
|
346
|
+
cont << Ruber[:projects].current
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
cont << Ruber[:config]
|
|
350
|
+
abs = :abs if abs
|
|
351
|
+
cont.each_with_index do |c, i|
|
|
352
|
+
begin return c[group, name, abs]
|
|
353
|
+
rescue ArgumentError
|
|
354
|
+
raise if i == cont.size - 1
|
|
355
|
+
end
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
=begin rdoc
|
|
360
|
+
Returns the name of the ruby interpreter to use for the given target
|
|
361
|
+
|
|
362
|
+
It is specialized version of {#option_for} which looks for the @ruby/ruby@ option
|
|
363
|
+
and takes into account the selected entry in the "Interpreters" submenu.
|
|
364
|
+
|
|
365
|
+
@param [Boolean] ignore_project as in {#option_for}
|
|
366
|
+
@return [String] the path of the interpreter to use
|
|
367
|
+
=end
|
|
368
|
+
def interpreter_for target, ignore_project = false
|
|
369
|
+
Ruber[:ruby_interpreters].chosen_interpreter ||
|
|
370
|
+
option_for(target, :ruby, :ruby, ignore_project)
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
=begin rdoc
|
|
374
|
+
Returns the command to use to execute ruby according to the appropriate options
|
|
375
|
+
for the given target.
|
|
376
|
+
|
|
377
|
+
To build the command, it uses the @ruby/ruby@ and the @ruby_options@ (in the group
|
|
378
|
+
specified in the constructor).
|
|
379
|
+
|
|
380
|
+
@param [AbstractProject, Document, String, nil] target as in {#option_for}
|
|
381
|
+
@param [String] dir the directory to run ruby from (it will be passed to ruby using
|
|
382
|
+
the @-C@ flag)
|
|
383
|
+
@param [Hash] opts some options to fine tune the behaviour of the method
|
|
384
|
+
|
|
385
|
+
@option opts [Boolean] default_interpreter (false) if *true*, ignores the choice
|
|
386
|
+
made by the user in the "Interpreters" submenu
|
|
387
|
+
@option opts [Boolean] ignore_project (false) as in {#option_for}
|
|
388
|
+
@option opts [String] ruby (nil) if given, use this instead of the content of the @ruby/ruby@
|
|
389
|
+
option as default interpreter
|
|
390
|
+
@option opts [<String>] ruby_options (nil) if given, use this instead of the content
|
|
391
|
+
of the @ruby_options@ option.
|
|
392
|
+
@return [<String>] an array whose first entry is the name of the ruby interpreter
|
|
393
|
+
to use and whose other elements are the options to pass to the interpreter.
|
|
394
|
+
=end
|
|
395
|
+
def ruby_command_for target, dir, opts = {}
|
|
396
|
+
ruby = Ruber[:ruby_interpreters].chosen_interpreter
|
|
397
|
+
if !ruby or opts[:default_interpreter]
|
|
398
|
+
ruby = if opts[:ruby] then opts[:ruby]
|
|
399
|
+
else option_for target, :ruby, :ruby, opts[:ignore_project]
|
|
400
|
+
end
|
|
401
|
+
end
|
|
402
|
+
ruby_options = opts[:ruby_options]
|
|
403
|
+
ruby_options ||= option_for target, @group, :ruby_options, opts[:ignore_project]
|
|
404
|
+
[ruby] + ruby_options + ['-C', dir]
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
end
|
|
410
|
+
|
|
411
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
** Form generated from reading ui file 'config_widget.ui'
|
|
3
|
+
**
|
|
4
|
+
** Created: ven ott 29 17:39:04 2010
|
|
5
|
+
** by: Qt User Interface Compiler version 4.7.0
|
|
6
|
+
**
|
|
7
|
+
** WARNING! All changes made in this file will be lost when recompiling ui file!
|
|
8
|
+
=end
|
|
9
|
+
|
|
10
|
+
class Ui_RubyRunnerConfigWidget
|
|
11
|
+
attr_reader :verticalLayout
|
|
12
|
+
attr_reader :_ruby__interpreters
|
|
13
|
+
attr_reader :groupBox
|
|
14
|
+
attr_reader :verticalLayout_2
|
|
15
|
+
attr_reader :horizontalLayout
|
|
16
|
+
attr_reader :label
|
|
17
|
+
attr_reader :_ruby__ruby
|
|
18
|
+
attr_reader :_ruby__ruby_options
|
|
19
|
+
|
|
20
|
+
def setupUi(rubyRunnerConfigWidget)
|
|
21
|
+
if rubyRunnerConfigWidget.objectName.nil?
|
|
22
|
+
rubyRunnerConfigWidget.objectName = "rubyRunnerConfigWidget"
|
|
23
|
+
end
|
|
24
|
+
rubyRunnerConfigWidget.resize(385, 306)
|
|
25
|
+
@verticalLayout = Qt::VBoxLayout.new(rubyRunnerConfigWidget)
|
|
26
|
+
@verticalLayout.objectName = "verticalLayout"
|
|
27
|
+
@_ruby__interpreters = KDE::EditListBox.new(rubyRunnerConfigWidget)
|
|
28
|
+
@_ruby__interpreters.objectName = "_ruby__interpreters"
|
|
29
|
+
|
|
30
|
+
@verticalLayout.addWidget(@_ruby__interpreters)
|
|
31
|
+
|
|
32
|
+
@groupBox = Qt::GroupBox.new(rubyRunnerConfigWidget)
|
|
33
|
+
@groupBox.objectName = "groupBox"
|
|
34
|
+
@verticalLayout_2 = Qt::VBoxLayout.new(@groupBox)
|
|
35
|
+
@verticalLayout_2.objectName = "verticalLayout_2"
|
|
36
|
+
@horizontalLayout = Qt::HBoxLayout.new()
|
|
37
|
+
@horizontalLayout.objectName = "horizontalLayout"
|
|
38
|
+
@label = Qt::Label.new(@groupBox)
|
|
39
|
+
@label.objectName = "label"
|
|
40
|
+
|
|
41
|
+
@horizontalLayout.addWidget(@label)
|
|
42
|
+
|
|
43
|
+
@_ruby__ruby = KDE::ComboBox.new(@groupBox)
|
|
44
|
+
@_ruby__ruby.objectName = "_ruby__ruby"
|
|
45
|
+
|
|
46
|
+
@horizontalLayout.addWidget(@_ruby__ruby)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@verticalLayout_2.addLayout(@horizontalLayout)
|
|
50
|
+
|
|
51
|
+
@_ruby__ruby_options = RubyOptionsWidget.new(@groupBox)
|
|
52
|
+
@_ruby__ruby_options.objectName = "_ruby__ruby_options"
|
|
53
|
+
|
|
54
|
+
@verticalLayout_2.addWidget(@_ruby__ruby_options)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
@verticalLayout.addWidget(@groupBox)
|
|
58
|
+
|
|
59
|
+
@label.buddy = @_ruby__ruby
|
|
60
|
+
|
|
61
|
+
retranslateUi(rubyRunnerConfigWidget)
|
|
62
|
+
|
|
63
|
+
Qt::MetaObject.connectSlotsByName(rubyRunnerConfigWidget)
|
|
64
|
+
end # setupUi
|
|
65
|
+
|
|
66
|
+
def setup_ui(rubyRunnerConfigWidget)
|
|
67
|
+
setupUi(rubyRunnerConfigWidget)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def retranslateUi(rubyRunnerConfigWidget)
|
|
71
|
+
rubyRunnerConfigWidget.windowTitle = Qt::Application.translate("RubyRunnerConfigWidget", "Form", nil, Qt::Application::UnicodeUTF8)
|
|
72
|
+
@_ruby__interpreters.title = Qt::Application.translate("RubyRunnerConfigWidget", "&Availlable Interpreters", nil, Qt::Application::UnicodeUTF8)
|
|
73
|
+
@_ruby__interpreters.setProperty("signal", Qt::Variant.new(Qt::Application.translate("RubyRunnerConfigWidget", "changed()", nil, Qt::Application::UnicodeUTF8)))
|
|
74
|
+
@_ruby__interpreters.setProperty("read", Qt::Variant.new(Qt::Application.translate("RubyRunnerConfigWidget", "$fill_interpreters", nil, Qt::Application::UnicodeUTF8)))
|
|
75
|
+
@_ruby__interpreters.setProperty("store", Qt::Variant.new(Qt::Application.translate("RubyRunnerConfigWidget", "items", nil, Qt::Application::UnicodeUTF8)))
|
|
76
|
+
@groupBox.title = Qt::Application.translate("RubyRunnerConfigWidget", "Interpreter", nil, Qt::Application::UnicodeUTF8)
|
|
77
|
+
@label.text = Qt::Application.translate("RubyRunnerConfigWidget", "&Default interpreter", nil, Qt::Application::UnicodeUTF8)
|
|
78
|
+
@_ruby__ruby.setProperty("read", Qt::Variant.new(Qt::Application.translate("RubyRunnerConfigWidget", "$default_interpreter=", nil, Qt::Application::UnicodeUTF8)))
|
|
79
|
+
@_ruby__ruby.setProperty("store", Qt::Variant.new(Qt::Application.translate("RubyRunnerConfigWidget", "current_text", nil, Qt::Application::UnicodeUTF8)))
|
|
80
|
+
end # retranslateUi
|
|
81
|
+
|
|
82
|
+
def retranslate_ui(rubyRunnerConfigWidget)
|
|
83
|
+
retranslateUi(rubyRunnerConfigWidget)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
module Ui
|
|
89
|
+
class RubyRunnerConfigWidget < Ui_RubyRunnerConfigWidget
|
|
90
|
+
end
|
|
91
|
+
end # module Ui
|
|
92
|
+
|