ruber 0.0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/LICENSE
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
h1. License
|
2
|
+
|
3
|
+
Ruber is released under the GPL version 2 (see the COPYING file)
|
4
|
+
|
5
|
+
The icons in the @icons@ directory have been produced modifying an
|
6
|
+
"image published on Wikimedia Commons":http://commons.wikimedia.org/wiki/File:Ruby_gem.JPG
|
7
|
+
and are released under the "Creative Commons Attribution 3.0 Unported":http://creativecommons.org/licenses/by/3.0/deed.en
|
8
|
+
license. The author of the original image is Michelle Jo
|
data/bin/ruber
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
=begin rdoc
|
4
|
+
Helper module to resolve the conflict between +Enumerable#count+ and the +count+
|
5
|
+
methods a lot of Qt/KDE classes provide.
|
6
|
+
|
7
|
+
It is essentially like +Enumerable+, but defines a <tt>count_items</tt> method
|
8
|
+
rather than a +count+ method. Qt/KDE classes can then mix-in this module instead
|
9
|
+
of +Enumerable+. The same effect could have been obtained by modifying +Enumerable+,
|
10
|
+
but that could have interferred with other libraries
|
11
|
+
=end
|
12
|
+
module QtEnumerable
|
13
|
+
|
14
|
+
include Enumerable
|
15
|
+
|
16
|
+
begin
|
17
|
+
alias :count_items :count
|
18
|
+
undef_method :count
|
19
|
+
rescue NoMethodError
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
require 'korundum4'
|
25
|
+
require 'kio'
|
26
|
+
require 'facets/kernel/require_relative'
|
27
|
+
|
28
|
+
require 'ruber/qt_sugar'
|
29
|
+
require 'ruber/kde_sugar'
|
30
|
+
require 'ruber/utils'
|
31
|
+
require 'ruber/exception_widgets'
|
32
|
+
require 'ruber/component_manager.rb'
|
33
|
+
|
34
|
+
data = KDE::AboutData.new "ruber", "", KDE::ki18n("Ruber"), "0.0.1.1",
|
35
|
+
KDE.ki18n('A Ruby IDE written in Ruby'), KDE::AboutData::License_GPL
|
36
|
+
data.add_author KDE.ki18n('Stefano Crocco'), KDE::LocalizedString.new,
|
37
|
+
Qt::ByteArray.new('stefano.crocco@alice.it')
|
38
|
+
data.bug_address = Qt::ByteArray.new "http://github.com/stcrocco/ruber/issues"
|
39
|
+
data.homepage = Qt::ByteArray.new 'http://stcrocco.github.com/ruber'
|
40
|
+
|
41
|
+
KDE::CmdLineArgs.init ARGV, data
|
42
|
+
opts = KDE::CmdLineOptions.new
|
43
|
+
opts.add("config-file <FILE>", KDE.ki18n("Use FILE instead of the default "\
|
44
|
+
"config file"), "")
|
45
|
+
opts.add("file <FILE>", KDE.ki18n("Open the file FILE. This option may be"\
|
46
|
+
" repeated more than one times and is "\
|
47
|
+
"mostly useful to open files ending in "\
|
48
|
+
".krprj as files instead of as projects"))
|
49
|
+
opts.add("+[FILES]", KDE.ki18n("Open FILES. Files with extension .krprj will "\
|
50
|
+
"be opened as projects. Only the more recent "\
|
51
|
+
"project will be used"))
|
52
|
+
KDE::CmdLineArgs.add_cmd_line_options opts
|
53
|
+
|
54
|
+
|
55
|
+
manager = Ruber::ComponentManager.new
|
56
|
+
manager.load_component 'application'
|
57
|
+
begin Ruber[:app].exec
|
58
|
+
rescue SystemExit, SignalException
|
59
|
+
raise
|
60
|
+
rescue Exception => ex
|
61
|
+
dlg = Ruber::ExceptionDialog.new ex, nil, false
|
62
|
+
dlg.exec
|
63
|
+
Qt::Internal.application_terminated = true
|
64
|
+
raise
|
65
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
:main_window:
|
2
|
+
:config_options:
|
3
|
+
General:
|
4
|
+
:default_script_directory: {:type: path, default: 'ENV["HOME"]'}
|
5
|
+
:default_project_directory: {:type: path, default: 'ENV["HOME"]'}
|
6
|
+
:output_font: {:default: 'Qt::Font.new("Courier",10)'}
|
7
|
+
auto_annotations: {type: bool, default: 'true'}
|
8
|
+
wrap_output: {type: bool, default: 'true'}
|
9
|
+
MainWindow:
|
10
|
+
:widget_size: {:key: Central widget size, :default: "Qt::Size.new"}
|
11
|
+
:window_size: {:key: Size, :default: 'Qt::Size.new(400,500)'}
|
12
|
+
:h_splitter: {:key: Horizontal splitter, :type: string list, :default: "['20', '60', '20']"}
|
13
|
+
:v_splitter: {:key: Vertical splitter, :type: string list, :default: "['80', '20']"}
|
14
|
+
:config_widgets:
|
15
|
+
- {:caption: General, :pixmap: configure, :class: KRuby::MainWindowSettingsWidget}
|
16
|
+
:application:
|
17
|
+
:config_options:
|
18
|
+
General:
|
19
|
+
:plugin_dirs: {:type: string list, :default: '[KRuby::Application::DEFAULT_PLUGIN_PATH]'}
|
20
|
+
:plugins: {:type: string list, :default: 'KRuby::Application::DEFAULT_PLUGINS'}
|
21
|
+
:auto_load_project: {:type: bool, :default: false }
|
22
|
+
:config_widgets:
|
23
|
+
- {:caption: General, :pixmap: configure, :code: "w=Qt::CheckBox.new('&Open last project at startup');w.object_name='kcfg_general_auto_load_project';w"}
|
24
|
+
:project_list:
|
25
|
+
project_options:
|
26
|
+
project_files: {default: '{:include => [], :exclude => [], :extensions => []}'}
|
27
|
+
project_widgets:
|
28
|
+
- {class: KRuby::ProjectFilesWidget, caption: 'General'}
|
29
|
+
project_extensions:
|
30
|
+
project_files_lister: {class: ProjectFilesLister}
|
31
|
+
project_session_manager: {class: KRuby::ProjectSessionManager}
|
@@ -0,0 +1,109 @@
|
|
1
|
+
<!DOCTYPE kpartgui SYSTEM 'kpartgui.dtd'>
|
2
|
+
<kpartgui version="10" name="ruber" >
|
3
|
+
<MenuBar>
|
4
|
+
<Menu name="file" >
|
5
|
+
<text>&File</text>
|
6
|
+
<Action name="file_new" />
|
7
|
+
<DefineGroup name="new_merge" />
|
8
|
+
<Separator/>
|
9
|
+
<Action name="file_open" />
|
10
|
+
<Action name="file_open_recent" />
|
11
|
+
<DefineGroup name="open_merge" />
|
12
|
+
<Separator/>
|
13
|
+
<DefineGroup name="save_merge" />
|
14
|
+
<Action name="file-save_all" />
|
15
|
+
<Separator/>
|
16
|
+
<DefineGroup name="revert_merge" />
|
17
|
+
<DefineGroup name="print_merge" />
|
18
|
+
<DefineGroup name="export_merge" />
|
19
|
+
<Separator/>
|
20
|
+
<Action name="file_close" />
|
21
|
+
<Action name="file-close_all" />
|
22
|
+
<Action name="file-close_other" />
|
23
|
+
<Separator/>
|
24
|
+
<Action name="file_quit" />
|
25
|
+
</Menu>
|
26
|
+
<Menu name="edit" >
|
27
|
+
<text>&Edit</text>
|
28
|
+
<DefineGroup name="edit_undo_merge" />
|
29
|
+
<Separator group="edit_undo_merge" />
|
30
|
+
<DefineGroup name="edit_paste_merge" />
|
31
|
+
<Separator/>
|
32
|
+
<DefineGroup name="edit_select_merge" />
|
33
|
+
<Separator/>
|
34
|
+
<DefineGroup name="edit_find_merge" />
|
35
|
+
<Separator/>
|
36
|
+
<DefineGroup name="edit_find_plugins" />
|
37
|
+
<Separator/>
|
38
|
+
</Menu>
|
39
|
+
<Menu name="documents" >
|
40
|
+
<text>&Document</text>
|
41
|
+
<Action name="go_back" />
|
42
|
+
<Action name="go_forward" />
|
43
|
+
<Separator/>
|
44
|
+
<Action name="configure_document"/>
|
45
|
+
</Menu>
|
46
|
+
<Menu name="view" >
|
47
|
+
<text>&View</text>
|
48
|
+
<Action name="view-activate_editor" />
|
49
|
+
<Menu name="tool_widgets">
|
50
|
+
<text>&Tool Widgets</text>
|
51
|
+
<Action name="view-toggle_left_tool_widget"/>
|
52
|
+
<Action name="view-toggle_right_tool_widget"/>
|
53
|
+
<Action name="view-toggle_bottom_tool_widget"/>
|
54
|
+
</Menu>
|
55
|
+
<Separator/>
|
56
|
+
<DefineGroup name="view_operations" />
|
57
|
+
</Menu>
|
58
|
+
<Menu noMerge="1" name="project" >
|
59
|
+
<text>&Project</text>
|
60
|
+
<Action name="project-new"/>
|
61
|
+
<Separator/>
|
62
|
+
<Action name="project-open" />
|
63
|
+
<Action name="project-open_recent" />
|
64
|
+
<Separator/>
|
65
|
+
<Action name="project-close"/>
|
66
|
+
<Separator/>
|
67
|
+
<Action name="project-quick_open_file" />
|
68
|
+
<Separator/>
|
69
|
+
<Action name="project-configure"/>
|
70
|
+
</Menu>
|
71
|
+
<Merge/>
|
72
|
+
<Menu name="tools" >
|
73
|
+
<text>&Tools</text>
|
74
|
+
<Action name="tools_external" />
|
75
|
+
<Separator/>
|
76
|
+
<DefineGroup name="tools_operations" />
|
77
|
+
<Action name="scripts" />
|
78
|
+
</Menu>
|
79
|
+
<Menu name="settings" >
|
80
|
+
<text>&Settings</text>
|
81
|
+
<Action name="options_configure" />
|
82
|
+
<DefineGroup name="configure_merge" />
|
83
|
+
<Separator/>
|
84
|
+
<DefineGroup name="show_merge" />
|
85
|
+
<Action name="options-choose_plugins" />
|
86
|
+
<Separator/>
|
87
|
+
<Merge name="StandardToolBarMenuHandler"/>
|
88
|
+
<Action name="settings_show_statusbar"/>
|
89
|
+
<Separator/>
|
90
|
+
<Action name="options_configure_keybinding" />
|
91
|
+
<Action name="set_configure_toolbars" />
|
92
|
+
</Menu>
|
93
|
+
<Menu name="help" >
|
94
|
+
<text>&Help</text>
|
95
|
+
<Action name="help_contents" />
|
96
|
+
<Action name="help_user_manual" />
|
97
|
+
<Action name="help_whats_this" />
|
98
|
+
<Separator/>
|
99
|
+
<Action name="help_report_bug" />
|
100
|
+
<Separator/>
|
101
|
+
<Menu name="about_plugins">
|
102
|
+
<text>About &Plugins</text>
|
103
|
+
<ActionList name="about_plugins_list"/>
|
104
|
+
</Menu>
|
105
|
+
<Action name="help_about_app" />
|
106
|
+
<Action name="help_about_kde" />
|
107
|
+
</Menu>
|
108
|
+
</MenuBar>
|
109
|
+
</kpartgui>
|
Binary file
|
Binary file
|
data/icons/ruber-16.png
ADDED
Binary file
|
data/icons/ruber-32.png
ADDED
Binary file
|
data/icons/ruber-48.png
ADDED
Binary file
|
data/icons/ruber-8.png
ADDED
Binary file
|
@@ -0,0 +1,288 @@
|
|
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 'yaml'
|
22
|
+
require 'ostruct'
|
23
|
+
require 'find'
|
24
|
+
require 'pathname'
|
25
|
+
require 'enumerator'
|
26
|
+
require 'facets/kernel/__dir__'
|
27
|
+
require 'fileutils'
|
28
|
+
|
29
|
+
require 'ruber/plugin_like'
|
30
|
+
require 'ruber/exception_widgets'
|
31
|
+
|
32
|
+
module Ruber
|
33
|
+
|
34
|
+
=begin rdoc
|
35
|
+
Returns the component providing the feature _feature_
|
36
|
+
|
37
|
+
<b>Note:</b> this method can only be used _after_ the application has been
|
38
|
+
created, otherwise +NoMethodError+ will be raised.
|
39
|
+
=end
|
40
|
+
def self.[](feature)
|
41
|
+
# This instance variable is initialized by the application's constructor
|
42
|
+
@components[feature]
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
class Application < KDE::Application
|
47
|
+
|
48
|
+
=begin rdoc
|
49
|
+
The default path where to look for plugins. It only includes the _plugins_ directory
|
50
|
+
in the Ruber installation path
|
51
|
+
=end
|
52
|
+
DEFAULT_PLUGIN_PATHS = [
|
53
|
+
File.join(KDE::Global.dirs.find_dirs( 'data', '')[0], File.join('ruber','plugins')),
|
54
|
+
File.expand_path(File.join(RUBER_LIB_DIR, '..', '..', 'plugins'))
|
55
|
+
]
|
56
|
+
=begin rdoc
|
57
|
+
The default plugins to load. They are: ruby_development, find_in_files, syntax_checker,
|
58
|
+
command and state
|
59
|
+
=end
|
60
|
+
DEFAULT_PLUGINS = %w[ruby_development find_in_files rake command syntax_checker state]
|
61
|
+
|
62
|
+
include PluginLike
|
63
|
+
|
64
|
+
slots 'load_settings()', :setup
|
65
|
+
|
66
|
+
# A hash containing the command line options
|
67
|
+
attr_reader :cmd_line_options
|
68
|
+
|
69
|
+
=begin rdoc
|
70
|
+
The status of the application. It can be: +:starting+, +:running+ or +:quitting+
|
71
|
+
=end
|
72
|
+
attr_reader :status
|
73
|
+
|
74
|
+
=begin rdoc
|
75
|
+
Creates a new application object.
|
76
|
+
|
77
|
+
Besides creating the application, this method also loads the core components
|
78
|
+
and sets up a timer which will cause the application's _setup_ method to be
|
79
|
+
called as soon as <tt>Application#exec</tt> is called.
|
80
|
+
=end
|
81
|
+
def initialize manager, pdf
|
82
|
+
super()
|
83
|
+
@components = manager
|
84
|
+
@components.parent = self
|
85
|
+
Ruber.instance_variable_set :@components, @components
|
86
|
+
initialize_plugin pdf
|
87
|
+
KDE::Global.dirs.addPrefix File.expand_path(File.join( RUBER_DATA_DIR, '..', '..', 'data'))
|
88
|
+
icon_path = KDE::Global.dirs.find_resource('icon', 'ruber')
|
89
|
+
self.window_icon = Qt::Icon.new icon_path
|
90
|
+
KDE::Global.main_component.about_data.program_icon_name = icon_path
|
91
|
+
@cmd_line_options = KDE::CmdLineArgs.parsed_args
|
92
|
+
@plugin_dirs = []
|
93
|
+
load_core_components
|
94
|
+
@status = :starting
|
95
|
+
Qt::Timer.single_shot(0, self, SLOT(:setup))
|
96
|
+
end
|
97
|
+
|
98
|
+
def quit_ruber
|
99
|
+
@status = :quitting
|
100
|
+
@components.shutdown
|
101
|
+
end
|
102
|
+
|
103
|
+
=begin rdoc
|
104
|
+
Returns *true* if the application is starting and *false* if it has already
|
105
|
+
started otherwise. The application is considered to have started after the
|
106
|
+
application's +setup+ method has been called and has returned. Before that,
|
107
|
+
it is considered to be starting.
|
108
|
+
|
109
|
+
This method is mostly useful for plugins which need to perform different actions
|
110
|
+
depending on whether they're loaded at application startup (in which case
|
111
|
+
<tt>starting?</tt> returns *true*) or later (when <tt>starting?</tt> returns
|
112
|
+
*false*)
|
113
|
+
=end
|
114
|
+
def starting?
|
115
|
+
@status == :starting
|
116
|
+
end
|
117
|
+
|
118
|
+
def running?
|
119
|
+
@status == :running
|
120
|
+
end
|
121
|
+
|
122
|
+
def quitting?
|
123
|
+
@status == :quitting
|
124
|
+
end
|
125
|
+
|
126
|
+
=begin rdoc
|
127
|
+
It is a wrapper around ComponentManager#load_plugins which allows an easier handling
|
128
|
+
of exceptions raised by the loaded plugins.
|
129
|
+
|
130
|
+
If a block is given, it is passed to ComponentManager#load_plugins, to determine
|
131
|
+
what to do if an exception is raised while loading a plugin. If no block is given
|
132
|
+
and _silent_ is *false*, then a dialog displaying the error message is shown to
|
133
|
+
the user, who has the following options: ignore the plugin which gave the error,
|
134
|
+
skip all the remaining plugins, go on ignoring other errors or aborting. If no
|
135
|
+
block is given and _silent_ is a true value, then all errors will be ignored.
|
136
|
+
|
137
|
+
_plugins_ should be an array containing the names of the plugins to load
|
138
|
+
(dependencies) will be computed automatically. _dirs_ is an array containing the
|
139
|
+
directories where to look for plugins. If *nil*, the values stored in the
|
140
|
+
"Plugin directories" entry in the configuration file will be used.
|
141
|
+
|
142
|
+
<b>Note:</b> this method doesn't attempt to handle exceptions raised while computing
|
143
|
+
or sorting dependencies.
|
144
|
+
=end
|
145
|
+
def safe_load_plugins plugins, silent = false, dirs = nil, &blk
|
146
|
+
if blk.nil? and silent then blk = proc{|_pl, _e| :silent}
|
147
|
+
elsif blk.nil?
|
148
|
+
blk = Proc.new{|pl, e| ComponentLoadingErrorDialog.new(pl.name, e, nil).exec}
|
149
|
+
end
|
150
|
+
@components.load_plugins plugins, dirs || @plugin_dirs, &blk
|
151
|
+
end
|
152
|
+
|
153
|
+
private
|
154
|
+
|
155
|
+
=begin rdoc
|
156
|
+
Applies the application's configuration settings. It also adds any plugin directory
|
157
|
+
to the load path, unless it's already there.
|
158
|
+
=end
|
159
|
+
def load_settings
|
160
|
+
@plugin_dirs = Ruber[:config][:general].plugin_dirs
|
161
|
+
new_dirs = @plugin_dirs - $:
|
162
|
+
new_dirs.each{|d| $:.unshift d}
|
163
|
+
end
|
164
|
+
|
165
|
+
=begin rdoc
|
166
|
+
Loads the plugins in the configuration file and opens the files and/or
|
167
|
+
projects listed in the command line. At the end, marks the application
|
168
|
+
as _running_.
|
169
|
+
=end
|
170
|
+
def setup
|
171
|
+
# Create $KDEHOME/share/apps/ruber/plugins if it's missing
|
172
|
+
begin FileUtils.mkdir DEFAULT_PLUGIN_PATHS[0]
|
173
|
+
rescue Errno::EEXIST
|
174
|
+
end
|
175
|
+
chosen_plugins = Ruber[:config][:general, :plugins].map(&:to_sym)
|
176
|
+
needed_plugins = []
|
177
|
+
deps_problem_msg = Proc.new do |e|
|
178
|
+
<<-EOS
|
179
|
+
The following errors have occurred while attempting to resolve the dependencies among plugins you chose:
|
180
|
+
#{e.message}
|
181
|
+
|
182
|
+
Ruber will start with no plugin loaded. Please, use the Choose Plugins menu entry in the Settings menu to solve the issue.
|
183
|
+
EOS
|
184
|
+
end
|
185
|
+
begin
|
186
|
+
availlable_plugins = ComponentManager.find_plugins @plugin_dirs, true
|
187
|
+
chosen_data = chosen_plugins.map{|i| availlable_plugins[i]}.compact
|
188
|
+
found = chosen_data.map{|i| i.name}
|
189
|
+
if found.size != chosen_plugins.size
|
190
|
+
missing = chosen_plugins - found
|
191
|
+
question = <<-EOS
|
192
|
+
Ruber couldn't find some plugins it has been configured to automatically load at startup. They are:
|
193
|
+
#{missing.join("\n")}
|
194
|
+
Do you want to start the application without them or to quit Ruber?
|
195
|
+
EOS
|
196
|
+
ans = KDE::MessageBox.question_yes_no nil, question, 'Missing plugins',
|
197
|
+
KDE::GuiItem.new('Start Ruber'), KDE::GuiItem.new('Quit')
|
198
|
+
exit if ans == KDE::MessageBox::No
|
199
|
+
chosen_plugins = found
|
200
|
+
end
|
201
|
+
needed_plugins = ComponentManager.fill_dependencies chosen_data, availlable_plugins.values
|
202
|
+
rescue ComponentManager::DependencyError => e
|
203
|
+
KDE::MessageBox.sorry nil, deps_problem_msg.call(e)
|
204
|
+
end
|
205
|
+
plugins = chosen_plugins + needed_plugins
|
206
|
+
begin
|
207
|
+
res = safe_load_plugins(plugins)
|
208
|
+
unless res
|
209
|
+
Qt::Internal.application_terminated = true
|
210
|
+
exit 1
|
211
|
+
end
|
212
|
+
rescue ComponentManager::DependencyError => e
|
213
|
+
KDE::MessageBox.error nil, deps_problem_msg.call(e)
|
214
|
+
end
|
215
|
+
if sessionRestored?
|
216
|
+
Ruber[:components].restore_session Ruber[:main_window].last_session_data
|
217
|
+
end
|
218
|
+
@status = :running
|
219
|
+
Ruber[:main_window].show
|
220
|
+
end
|
221
|
+
|
222
|
+
|
223
|
+
=begin rdoc
|
224
|
+
Loads the core components. In order, they are:
|
225
|
+
* the configuration manager
|
226
|
+
* the document keeper
|
227
|
+
* the main window
|
228
|
+
|
229
|
+
After creating the configuration manager, the <tt>register_with_config</tt>
|
230
|
+
method is called
|
231
|
+
=end
|
232
|
+
def load_core_components
|
233
|
+
begin
|
234
|
+
current = 'config'
|
235
|
+
@components.load_component 'config'
|
236
|
+
register_with_config
|
237
|
+
%w[documents projects main_window].each do |i|
|
238
|
+
current = i
|
239
|
+
@components.load_component i
|
240
|
+
end
|
241
|
+
rescue Exception => e
|
242
|
+
ComponentLoadingErrorDialog.new(current, e, nil, true).exec
|
243
|
+
Qt::Internal.application_terminated = true
|
244
|
+
exit 1
|
245
|
+
end
|
246
|
+
if sessionRestored? then Ruber[:main_window].restore 1, false
|
247
|
+
else
|
248
|
+
open_command_line_files
|
249
|
+
if Ruber[:projects].projects.empty? and Ruber[:documents].documents.empty?
|
250
|
+
Ruber[:main_window].display_doc Ruber[:documents].new_document
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
=begin rdoc
|
256
|
+
Registers the configuration options with the configuration manager, calls the
|
257
|
+
<tt>load_settings</tt> method and connects to the configuration manager's
|
258
|
+
<tt>settings_changed</tt> signal.
|
259
|
+
|
260
|
+
This tasks are performed by the <tt>PluginLike#initialize_plugin</tt> method,
|
261
|
+
but as the config manager didn't exist when that method was called, it is
|
262
|
+
necessary to to them here
|
263
|
+
=end
|
264
|
+
def register_with_config
|
265
|
+
config = Ruber[:config]
|
266
|
+
@plugin_description.config_options.each_value{|o| config.add_option o}
|
267
|
+
load_settings
|
268
|
+
connect config, SIGNAL(:settings_changed), self, SLOT(:load_settings)
|
269
|
+
end
|
270
|
+
|
271
|
+
=begin rdoc
|
272
|
+
Opens the files and/or project listed on the command line, or creates a single
|
273
|
+
empty document if neither files nor projects have been specified.
|
274
|
+
=end
|
275
|
+
def open_command_line_files
|
276
|
+
args = @cmd_line_options.files
|
277
|
+
win = Ruber[:main_window]
|
278
|
+
projects, files = args.partition{|f| File.extname(f) == '.ruprj'}
|
279
|
+
prj = win.safe_open_project projects.last unless projects.empty?
|
280
|
+
files += @cmd_line_options.getOptionList('file')
|
281
|
+
files.each do |f|
|
282
|
+
win.display_document f
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|