ruber 0.0.8 → 0.0.9

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.
Files changed (81) hide show
  1. data/CHANGES +21 -0
  2. data/data/share/apps/ruber/ruberui.rc +3 -1
  3. data/lib/ruber/application/application.rb +22 -23
  4. data/lib/ruber/application/plugin.yaml +7 -2
  5. data/lib/ruber/{projects → application}/project_files_list.rb +0 -0
  6. data/lib/ruber/{projects → application}/project_files_widget.rb +0 -0
  7. data/lib/ruber/application/ui/project_files_rule_chooser_widget.rb +74 -0
  8. data/lib/ruber/{projects → application}/ui/project_files_rule_chooser_widget.ui +0 -0
  9. data/lib/ruber/application/ui/project_files_widget.rb +117 -0
  10. data/lib/ruber/{projects → application}/ui/project_files_widget.ui +0 -0
  11. data/lib/ruber/component_manager.rb +14 -9
  12. data/lib/ruber/editor/document.rb +35 -5
  13. data/lib/ruber/kde_sugar.rb +16 -0
  14. data/lib/ruber/main_window/choose_plugins_dlg.rb +7 -4
  15. data/lib/ruber/main_window/main_window.rb +131 -193
  16. data/lib/ruber/main_window/main_window_actions.rb +157 -58
  17. data/lib/ruber/main_window/main_window_internal.rb +145 -54
  18. data/lib/ruber/main_window/open_file_in_project_dlg.rb +4 -4
  19. data/lib/ruber/main_window/plugin.yaml +3 -6
  20. data/lib/ruber/main_window/ui/workspace_settings_widget.rb +2 -2
  21. data/lib/ruber/main_window/workspace.rb +62 -32
  22. data/lib/ruber/output_widget.rb +20 -16
  23. data/lib/ruber/pane.rb +11 -5
  24. data/lib/ruber/project.rb +27 -12
  25. data/lib/ruber/projects/ui/project_files_rule_chooser_widget.rb +2 -2
  26. data/lib/ruber/projects/ui/project_files_widget.rb +2 -2
  27. data/lib/ruber/utils.rb +37 -4
  28. data/lib/ruber/version.rb +1 -1
  29. data/lib/ruber/world/document_factory.rb +121 -0
  30. data/lib/ruber/world/document_list.rb +396 -0
  31. data/lib/ruber/world/environment.rb +470 -0
  32. data/lib/ruber/{main_window → world}/hint_solver.rb +1 -1
  33. data/lib/ruber/world/plugin.yaml +11 -0
  34. data/lib/ruber/world/project_factory.rb +131 -0
  35. data/lib/ruber/world/project_list.rb +265 -0
  36. data/lib/ruber/world/ui/workspace_settings_widget.rb +51 -0
  37. data/lib/ruber/{main_window → world}/ui/workspace_settings_widget.ui +0 -0
  38. data/lib/ruber/world/world.rb +307 -0
  39. data/plugins/auto_end/auto_end.rb +135 -9
  40. data/plugins/autosave/autosave.rb +4 -4
  41. data/plugins/find_in_files/find_in_files.rb +5 -5
  42. data/plugins/find_in_files/find_in_files_widgets.rb +1 -1
  43. data/plugins/project_browser/project_browser.rb +4 -4
  44. data/plugins/rake/rake.rb +4 -4
  45. data/plugins/rake/rake_extension.rb +1 -1
  46. data/plugins/rspec/rspec.rb +4 -4
  47. data/plugins/rspec/ruber_rspec_formatter.rb +2 -2
  48. data/plugins/ruby_development/ruby_development.rb +3 -3
  49. data/plugins/ruby_runner/ruby_runner.rb +2 -2
  50. data/plugins/state/plugin.yaml +6 -8
  51. data/plugins/state/state.rb +201 -391
  52. data/plugins/state/ui/config_widget.rb +5 -5
  53. data/plugins/state/ui/config_widget.ui +3 -3
  54. data/plugins/syntax_checker/syntax_checker.rb +4 -0
  55. data/spec/annotation_model_spec.rb +1 -1
  56. data/spec/auto_end_spec.rb +98 -47
  57. data/spec/component_manager_spec.rb +80 -21
  58. data/spec/document_factory_spec.rb +115 -0
  59. data/spec/document_list_spec.rb +560 -450
  60. data/spec/document_spec.rb +143 -55
  61. data/spec/editor_view_spec.rb +2 -2
  62. data/spec/environment_spec.rb +1900 -0
  63. data/spec/hint_solver_spec.rb +5 -5
  64. data/spec/kde_sugar_spec.rb +16 -0
  65. data/spec/output_widget_spec.rb +177 -51
  66. data/spec/pane_spec.rb +29 -5
  67. data/spec/plugin_spec.rb +1 -1
  68. data/spec/project_factory_spec.rb +104 -0
  69. data/spec/project_list_spec.rb +352 -447
  70. data/spec/project_spec.rb +34 -33
  71. data/spec/qt_sugar_spec.rb +2 -2
  72. data/spec/state_spec.rb +508 -811
  73. data/spec/utils_spec.rb +149 -98
  74. data/spec/workspace_spec.rb +120 -9
  75. data/spec/world_spec.rb +1219 -0
  76. metadata +23 -14
  77. data/lib/ruber/documents/document_list.rb +0 -412
  78. data/lib/ruber/documents/plugin.yaml +0 -4
  79. data/lib/ruber/main_window/view_manager.rb +0 -431
  80. data/lib/ruber/projects/plugin.yaml +0 -11
  81. data/lib/ruber/projects/project_list.rb +0 -314
@@ -23,7 +23,7 @@ require 'ruber/editor/editor_view'
23
23
 
24
24
  module Ruber
25
25
 
26
- class MainWindow
26
+ module World
27
27
 
28
28
  =begin rdoc
29
29
  Helper class used by {MainWindow#editor_for} and friends to find out which editor
@@ -0,0 +1,11 @@
1
+ name: world
2
+ description: Container for all the environments
3
+ require: [world, environment]
4
+ class: Ruber::World::World
5
+ config_options:
6
+ workspace:
7
+ close_buttons: {default: 'true', type: bool}
8
+ config_widgets:
9
+ - {caption: Workspace, pixmap: workspace.png, class: Ruber::World::WorkspaceSettingsWidget}
10
+ extensions:
11
+ environment: {class: Ruber::World::Environment, scope: global}
@@ -0,0 +1,131 @@
1
+ =begin
2
+ Copyright (C) 2011 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
+ module Ruber
22
+
23
+ module World
24
+
25
+ =begin rdoc
26
+ Class whose task is to ensure that there's only one project open for any given
27
+ project file.
28
+
29
+ To create a new project, call the {#project} method instead of using {Project}.new.
30
+ If a project for the given file already exists, it'll be returned, otherwise a
31
+ new project will be created.
32
+ =end
33
+ class ProjectFactory < Qt::Object
34
+
35
+ =begin rdoc
36
+ Exception raised when the name requested for a project file is different for the
37
+ name contained in the project itself
38
+ =end
39
+ class MismatchingNameError < StandardError
40
+
41
+ =begin rdoc
42
+ @return [String] the project file
43
+ =end
44
+ attr_reader :file
45
+
46
+ =begin rdoc
47
+ @return [String] the requested project name
48
+ =end
49
+ attr_reader :requested_name
50
+
51
+ =begin rdoc
52
+ @return [String] the project name contained in the project file
53
+ =end
54
+ attr_reader :actual_name
55
+
56
+ =begin rdoc
57
+ @param [String] file the project file
58
+ @param [String] requested_name the name requested for the project
59
+ @param [String] actual_name the project name contained in the project
60
+ =end
61
+ def initialize file, requested_name, actual_name
62
+ @file = file
63
+ @requested_name = requested_name
64
+ @actual_name = actual_name
65
+ super "A project associated with #{file} exists, but the corresponding project name is #{actual_name} instead of #{requested_name}"
66
+ end
67
+ end
68
+
69
+ =begin rdoc
70
+ Signal emitted when a new project object is created
71
+
72
+ The signal is emitted when a new project object is created, either from an existing project
73
+ file or for a new project file.
74
+ @param [Project] prj the project object
75
+ =end
76
+ signals 'project_created(QObject*)'
77
+
78
+ =begin rdoc
79
+ @param [Qt::Object,nil] parent the parent object
80
+ =end
81
+ def initialize parent = nil
82
+ super
83
+ @projects = {}
84
+ end
85
+
86
+ =begin rdoc
87
+ Retrieves the project associated with a given project file
88
+
89
+ If a project associated with the project file _file_ already exists, that project
90
+ is returned. Otherwise, a new project is created. In this case, the {#project_created}
91
+ signal is emitted
92
+
93
+ @param (see Ruber::Project#initialize)
94
+ @return [Project] a project associated with _file_
95
+ @raise [MismatchingNameError] if _name_ is specified, a project associated with
96
+ _file_ already exists but _name_ and the name of the existing project are different
97
+ =end
98
+ def project file, name = nil
99
+ prj = @projects[file]
100
+ if prj
101
+ if name and prj.project_name != name
102
+ raise MismatchingNameError.new file, name, prj.project_name
103
+ end
104
+ prj
105
+ else
106
+ prj = Project.new file, name
107
+ connect prj, SIGNAL('closing(QObject*)'), self, SLOT('project_closing(QObject*)')
108
+ @projects[prj.project_file] = prj
109
+ emit project_created prj
110
+ prj
111
+ end
112
+ end
113
+
114
+ private
115
+
116
+ =begin rdoc
117
+ Method called whenever a project is closed
118
+
119
+ It ensures that the list of open projects is up to date
120
+ @return [nil]
121
+ =end
122
+ def project_closing prj
123
+ @projects.delete prj.project_file
124
+ nil
125
+ end
126
+ slots 'project_closing(QObject*)'
127
+
128
+ end
129
+ end
130
+
131
+ end
@@ -0,0 +1,265 @@
1
+ =begin
2
+ Copyright (C) 2011 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
+ module Ruber
22
+
23
+ module World
24
+
25
+ =begin rdoc
26
+ A list of projects
27
+
28
+ It's an immutable @Enumerable@ class with some convenience methods for dealing
29
+ with projects.
30
+
31
+ The projects in the list are set in the constructor and can't be changed later.
32
+
33
+ The order of projects won't be kept.
34
+
35
+ @note This list can't contain more than one project with the same project file.
36
+ =end
37
+ class ProjectList
38
+
39
+ include Enumerable
40
+
41
+ =begin rdoc
42
+ @param [Array<Project>, ProjectList] prjs the projects to insert in the
43
+ list when created. If it's a {ProjectList}, changes to _prjs_ will be
44
+ reflected by the newly created object. This won't happen if _prjs_ is an array.
45
+
46
+ If the list contains multiple projects with the same project file, only the last
47
+ one will be inserted in the list
48
+ =end
49
+ def initialize prjs
50
+ if prjs.is_a? ProjectList then @projects = prjs.project_hash
51
+ else @projects = Hash[prjs.map{|prj| [prj.project_file, prj]}]
52
+ end
53
+ end
54
+
55
+ =begin rdoc
56
+ Iterates on the projects
57
+
58
+ @overload each{|prj| }
59
+ Calls the block once for each project in the list (the order is arbitrary)
60
+ @yieldparam [Project] prj the projects in the list
61
+ @return [ProjectList] *self*
62
+ @overload each
63
+ @return [Enumerator] an enumerator which iterates on the projects
64
+ @return [ProjectList,Enumerator]
65
+ =end
66
+ def each &blk
67
+ if block_given?
68
+ @projects.each_value &blk
69
+ self
70
+ else to_enum
71
+ end
72
+ end
73
+
74
+ =begin rdoc
75
+ Whether or not the list is empty
76
+ @return [Boolean] *true* if the list is empty and *false* otherwise
77
+ =end
78
+ def empty?
79
+ @projects.empty?
80
+ end
81
+
82
+ =begin rdoc
83
+ @return [Integer] the number of projects in the list
84
+ =end
85
+ def size
86
+ @projects.size
87
+ end
88
+
89
+ =begin rdoc
90
+ Comparison operator
91
+
92
+ @param [Object] other the object to compare *self* with
93
+ @return [Boolean] *true* if _other_ is either an @Array@ or a {ProjectList}
94
+ containing the same elements as *self* and *false* otherwise
95
+ =end
96
+ def == other
97
+ case other
98
+ when ProjectList then @projects == other.project_hash
99
+ when Array
100
+ @projects.values.sort_by(&:object_id) == other.sort_by(&:object_id)
101
+ else false
102
+ end
103
+ end
104
+
105
+ =begin rdoc
106
+ Comparison operator used by Hash
107
+
108
+ @param [Object] other the object to compare *self* with
109
+ @return [Boolean] *true* if _other_ is a {ProjectList} containing the
110
+ same elements as *self* and *false* otherwise
111
+ =end
112
+ def eql? other
113
+ other.is_a?(ProjectList) ? @projects.eql?(other.project_hash) : false
114
+ end
115
+
116
+ =begin rdoc
117
+ Override of @Object#hash@
118
+
119
+ @return [Integer] the hash value for *self*
120
+ =end
121
+ def hash
122
+ @projects.hash
123
+ end
124
+
125
+ =begin rdoc
126
+ Element access
127
+
128
+ @overload [] filename
129
+ Retrieves the project for the given project file
130
+ @param [String] filename the absolute path of the project file. It must start
131
+ with a slash
132
+ @return [Project,nil] the project having _filename_ as project file or *nil* if
133
+ no project having that project file is in the list
134
+ @overload [] name
135
+ Retrieves the project having the given project name
136
+ @param [String] name the project name. It must not start with a slash
137
+ @return [Project,nil] the project having the given project name or *nil* if no
138
+ such project exists in the list. If there is more than one document with the
139
+ same project name, one of them is returned
140
+ @return [Project,nil]
141
+ =end
142
+ def [] arg
143
+ if arg.start_with? '/' then @projects[arg]
144
+ else
145
+ prj = @projects.find{|i| i[1].project_name == arg}
146
+ prj ? prj[1] : nil
147
+ end
148
+ end
149
+
150
+ protected
151
+
152
+ =begin rdoc
153
+ @return [Hash{String=>Project}] the internal hash used to keep trace of the projects
154
+ =end
155
+ def project_hash
156
+ @projects
157
+ end
158
+
159
+ end
160
+
161
+ =begin rdoc
162
+ A {ProjectList} which allows to change the contents of the list.
163
+ =end
164
+ class MutableProjectList < ProjectList
165
+
166
+ =begin rdoc
167
+ @param [Array<Project>, ProjectList] prjs the projects to insert in the
168
+ list when created. Further changes to _prjs_ won't change the new instance and
169
+ vice versa
170
+ =end
171
+ def initialize prjs = []
172
+ @projects = Hash[prjs.map{|prj| [prj.project_name, prj]}]
173
+ end
174
+
175
+ =begin rdoc
176
+ Override of @Object#dup@
177
+ @return [MutableProjectList] a duplicate of *self*
178
+ =end
179
+ def dup
180
+ self.class.new self
181
+ end
182
+
183
+ =begin rdoc
184
+ Override of @Object#clone@
185
+ @return [MutableProjectList] a duplicate of *self*
186
+ =end
187
+ def clone
188
+ res = self.class.new self
189
+ if frozen?
190
+ res.freeze
191
+ res.project_hash.freeze
192
+ end
193
+ res
194
+ end
195
+
196
+ =begin rdoc
197
+ Adds projects to the list
198
+
199
+ @param [Array<Project,Array<Project>>] projects the projects to add. If it contains
200
+ nested arrays, they'll be flattened. If the list contains multiple projects with
201
+ the same project file, only the last one will be kept (if a project with the same
202
+ project name was already in the list, it'll be overwritten)
203
+ @return [MutableProjectList] *self*
204
+ =end
205
+ def add *projects
206
+ projects.flatten.each do |prj|
207
+ @projects[prj.project_file] = prj
208
+ end
209
+ end
210
+
211
+ =begin rdoc
212
+ Adds the projects contained in another list to this list
213
+
214
+ @param [Array<Project>, ProjectList] other the list whose contents should
215
+ be added to this list contents
216
+ @return [MutableProjectList] *self*
217
+ =end
218
+ def merge! prjs
219
+ if prjs.is_a? ProjectList then @projects.merge! prjs.project_hash
220
+ else
221
+ @projects.merge! Hash[prjs.map{|prj| [prj.project_file, prj]}]
222
+ end
223
+ self
224
+ end
225
+
226
+ =begin rdoc
227
+ Removes a project from the list
228
+
229
+ If the given project isn't in the list, nothing is done
230
+
231
+ @param [Project] doc the project to remove
232
+ @return [Project,nil] the removed project or *nil* if no project was removed
233
+ =end
234
+ def remove prj
235
+ @projects.delete prj.project_file
236
+ end
237
+
238
+ =begin rdoc
239
+ Removes all the elements from the list
240
+
241
+ @return [MutableProjectList] *self*
242
+ =end
243
+ def clear
244
+ @projects.clear
245
+ self
246
+ end
247
+
248
+ =begin rdoc
249
+ Removes from the list all the projects for which the block returns true
250
+
251
+ @yieldparam [Project] prj the projects in the list
252
+ @yieldreturn [Boolean] *true* for projects which should be removed from the list
253
+ and *false* otherwise
254
+ @return [MutableProjectList] *self*
255
+ =end
256
+ def delete_if &blk
257
+ @projects.delete_if{|_, prj| blk.call prj}
258
+ self
259
+ end
260
+
261
+ end
262
+
263
+ end
264
+
265
+ end
@@ -0,0 +1,51 @@
1
+ =begin
2
+ ** Form generated from reading ui file 'workspace_settings_widget.ui'
3
+ **
4
+ ** Created: gio apr 21 20:42:42 2011
5
+ ** by: Qt User Interface Compiler version 4.7.2
6
+ **
7
+ ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
+ =end
9
+
10
+ class Ui_WorkspaceSettingsWidgetBase
11
+ attr_reader :verticalLayout
12
+ attr_reader :_workspace__close_buttons
13
+
14
+ def setupUi(workspaceSettingsWidgetBase)
15
+ if workspaceSettingsWidgetBase.objectName.nil?
16
+ workspaceSettingsWidgetBase.objectName = "workspaceSettingsWidgetBase"
17
+ end
18
+ workspaceSettingsWidgetBase.resize(400, 35)
19
+ @verticalLayout = Qt::VBoxLayout.new(workspaceSettingsWidgetBase)
20
+ @verticalLayout.objectName = "verticalLayout"
21
+ @_workspace__close_buttons = Qt::CheckBox.new(workspaceSettingsWidgetBase)
22
+ @_workspace__close_buttons.objectName = "_workspace__close_buttons"
23
+
24
+ @verticalLayout.addWidget(@_workspace__close_buttons)
25
+
26
+
27
+ retranslateUi(workspaceSettingsWidgetBase)
28
+
29
+ Qt::MetaObject.connectSlotsByName(workspaceSettingsWidgetBase)
30
+ end # setupUi
31
+
32
+ def setup_ui(workspaceSettingsWidgetBase)
33
+ setupUi(workspaceSettingsWidgetBase)
34
+ end
35
+
36
+ def retranslateUi(workspaceSettingsWidgetBase)
37
+ workspaceSettingsWidgetBase.windowTitle = Qt::Application.translate("WorkspaceSettingsWidgetBase", "Form", nil, Qt::Application::UnicodeUTF8)
38
+ @_workspace__close_buttons.text = Qt::Application.translate("WorkspaceSettingsWidgetBase", "&Display close buttons on tabs", nil, Qt::Application::UnicodeUTF8)
39
+ end # retranslateUi
40
+
41
+ def retranslate_ui(workspaceSettingsWidgetBase)
42
+ retranslateUi(workspaceSettingsWidgetBase)
43
+ end
44
+
45
+ end
46
+
47
+ module Ui
48
+ class WorkspaceSettingsWidgetBase < Ui_WorkspaceSettingsWidgetBase
49
+ end
50
+ end # module Ui
51
+