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.
- data/CHANGES +21 -0
- data/data/share/apps/ruber/ruberui.rc +3 -1
- data/lib/ruber/application/application.rb +22 -23
- data/lib/ruber/application/plugin.yaml +7 -2
- data/lib/ruber/{projects → application}/project_files_list.rb +0 -0
- data/lib/ruber/{projects → application}/project_files_widget.rb +0 -0
- data/lib/ruber/application/ui/project_files_rule_chooser_widget.rb +74 -0
- data/lib/ruber/{projects → application}/ui/project_files_rule_chooser_widget.ui +0 -0
- data/lib/ruber/application/ui/project_files_widget.rb +117 -0
- data/lib/ruber/{projects → application}/ui/project_files_widget.ui +0 -0
- data/lib/ruber/component_manager.rb +14 -9
- data/lib/ruber/editor/document.rb +35 -5
- data/lib/ruber/kde_sugar.rb +16 -0
- data/lib/ruber/main_window/choose_plugins_dlg.rb +7 -4
- data/lib/ruber/main_window/main_window.rb +131 -193
- data/lib/ruber/main_window/main_window_actions.rb +157 -58
- data/lib/ruber/main_window/main_window_internal.rb +145 -54
- data/lib/ruber/main_window/open_file_in_project_dlg.rb +4 -4
- data/lib/ruber/main_window/plugin.yaml +3 -6
- data/lib/ruber/main_window/ui/workspace_settings_widget.rb +2 -2
- data/lib/ruber/main_window/workspace.rb +62 -32
- data/lib/ruber/output_widget.rb +20 -16
- data/lib/ruber/pane.rb +11 -5
- data/lib/ruber/project.rb +27 -12
- data/lib/ruber/projects/ui/project_files_rule_chooser_widget.rb +2 -2
- data/lib/ruber/projects/ui/project_files_widget.rb +2 -2
- data/lib/ruber/utils.rb +37 -4
- data/lib/ruber/version.rb +1 -1
- data/lib/ruber/world/document_factory.rb +121 -0
- data/lib/ruber/world/document_list.rb +396 -0
- data/lib/ruber/world/environment.rb +470 -0
- data/lib/ruber/{main_window → world}/hint_solver.rb +1 -1
- data/lib/ruber/world/plugin.yaml +11 -0
- data/lib/ruber/world/project_factory.rb +131 -0
- data/lib/ruber/world/project_list.rb +265 -0
- data/lib/ruber/world/ui/workspace_settings_widget.rb +51 -0
- data/lib/ruber/{main_window → world}/ui/workspace_settings_widget.ui +0 -0
- data/lib/ruber/world/world.rb +307 -0
- data/plugins/auto_end/auto_end.rb +135 -9
- data/plugins/autosave/autosave.rb +4 -4
- data/plugins/find_in_files/find_in_files.rb +5 -5
- data/plugins/find_in_files/find_in_files_widgets.rb +1 -1
- data/plugins/project_browser/project_browser.rb +4 -4
- data/plugins/rake/rake.rb +4 -4
- data/plugins/rake/rake_extension.rb +1 -1
- data/plugins/rspec/rspec.rb +4 -4
- data/plugins/rspec/ruber_rspec_formatter.rb +2 -2
- data/plugins/ruby_development/ruby_development.rb +3 -3
- data/plugins/ruby_runner/ruby_runner.rb +2 -2
- data/plugins/state/plugin.yaml +6 -8
- data/plugins/state/state.rb +201 -391
- data/plugins/state/ui/config_widget.rb +5 -5
- data/plugins/state/ui/config_widget.ui +3 -3
- data/plugins/syntax_checker/syntax_checker.rb +4 -0
- data/spec/annotation_model_spec.rb +1 -1
- data/spec/auto_end_spec.rb +98 -47
- data/spec/component_manager_spec.rb +80 -21
- data/spec/document_factory_spec.rb +115 -0
- data/spec/document_list_spec.rb +560 -450
- data/spec/document_spec.rb +143 -55
- data/spec/editor_view_spec.rb +2 -2
- data/spec/environment_spec.rb +1900 -0
- data/spec/hint_solver_spec.rb +5 -5
- data/spec/kde_sugar_spec.rb +16 -0
- data/spec/output_widget_spec.rb +177 -51
- data/spec/pane_spec.rb +29 -5
- data/spec/plugin_spec.rb +1 -1
- data/spec/project_factory_spec.rb +104 -0
- data/spec/project_list_spec.rb +352 -447
- data/spec/project_spec.rb +34 -33
- data/spec/qt_sugar_spec.rb +2 -2
- data/spec/state_spec.rb +508 -811
- data/spec/utils_spec.rb +149 -98
- data/spec/workspace_spec.rb +120 -9
- data/spec/world_spec.rb +1219 -0
- metadata +23 -14
- data/lib/ruber/documents/document_list.rb +0 -412
- data/lib/ruber/documents/plugin.yaml +0 -4
- data/lib/ruber/main_window/view_manager.rb +0 -431
- data/lib/ruber/projects/plugin.yaml +0 -11
- data/lib/ruber/projects/project_list.rb +0 -314
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 9
|
9
|
+
version: 0.0.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Stefano Crocco
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-05-30 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -81,6 +81,16 @@ extra_rdoc_files: []
|
|
81
81
|
files:
|
82
82
|
- lib/ruber/kde_config_option_backend.rb
|
83
83
|
- lib/ruber/qt_sugar.rb
|
84
|
+
- lib/ruber/world/ui/workspace_settings_widget.rb
|
85
|
+
- lib/ruber/world/ui/workspace_settings_widget.ui
|
86
|
+
- lib/ruber/world/plugin.yaml
|
87
|
+
- lib/ruber/world/document_list.rb
|
88
|
+
- lib/ruber/world/hint_solver.rb
|
89
|
+
- lib/ruber/world/world.rb
|
90
|
+
- lib/ruber/world/document_factory.rb
|
91
|
+
- lib/ruber/world/environment.rb
|
92
|
+
- lib/ruber/world/project_factory.rb
|
93
|
+
- lib/ruber/world/project_list.rb
|
84
94
|
- lib/ruber/main_window/ui/new_project_widget.rb
|
85
95
|
- lib/ruber/main_window/ui/new_project_widget.ui
|
86
96
|
- lib/ruber/main_window/ui/output_color_widget.rb
|
@@ -90,7 +100,6 @@ files:
|
|
90
100
|
- lib/ruber/main_window/ui/open_file_in_project_dlg.rb
|
91
101
|
- lib/ruber/main_window/ui/open_file_in_project_dlg.ui
|
92
102
|
- lib/ruber/main_window/ui/workspace_settings_widget.rb
|
93
|
-
- lib/ruber/main_window/ui/workspace_settings_widget.ui
|
94
103
|
- lib/ruber/main_window/ui/main_window_settings_widget.rb
|
95
104
|
- lib/ruber/main_window/ui/main_window_settings_widget.ui
|
96
105
|
- lib/ruber/main_window/main_window_internal.rb
|
@@ -101,18 +110,20 @@ files:
|
|
101
110
|
- lib/ruber/main_window/main_window_actions.rb
|
102
111
|
- lib/ruber/main_window/output_color_widget.rb
|
103
112
|
- lib/ruber/main_window/save_modified_files_dlg.rb
|
104
|
-
- lib/ruber/main_window/hint_solver.rb
|
105
113
|
- lib/ruber/main_window/workspace.png
|
106
|
-
- lib/ruber/main_window/view_manager.rb
|
107
114
|
- lib/ruber/main_window/open_file_in_project_dlg.rb
|
108
115
|
- lib/ruber/main_window/choose_plugins_dlg.rb
|
116
|
+
- lib/ruber/application/ui/project_files_widget.rb
|
117
|
+
- lib/ruber/application/ui/project_files_widget.ui
|
118
|
+
- lib/ruber/application/ui/project_files_rule_chooser_widget.rb
|
119
|
+
- lib/ruber/application/ui/project_files_rule_chooser_widget.ui
|
109
120
|
- lib/ruber/application/plugin.yaml
|
121
|
+
- lib/ruber/application/project_files_list.rb
|
122
|
+
- lib/ruber/application/project_files_widget.rb
|
110
123
|
- lib/ruber/application/application.rb
|
111
124
|
- lib/ruber/exception_widgets.rb
|
112
125
|
- lib/ruber/gui_states_handler.rb
|
113
126
|
- lib/ruber/project_backend.rb
|
114
|
-
- lib/ruber/documents/plugin.yaml
|
115
|
-
- lib/ruber/documents/document_list.rb
|
116
127
|
- lib/ruber/ktexteditor_sugar.rb
|
117
128
|
- lib/ruber/plugin_specification.rb
|
118
129
|
- lib/ruber/output_widget.rb
|
@@ -134,13 +145,7 @@ files:
|
|
134
145
|
- lib/ruber/filtered_output_widget.rb
|
135
146
|
- lib/ruber/pane.rb
|
136
147
|
- lib/ruber/projects/ui/project_files_widget.rb
|
137
|
-
- lib/ruber/projects/ui/project_files_widget.ui
|
138
148
|
- lib/ruber/projects/ui/project_files_rule_chooser_widget.rb
|
139
|
-
- lib/ruber/projects/ui/project_files_rule_chooser_widget.ui
|
140
|
-
- lib/ruber/projects/plugin.yaml
|
141
|
-
- lib/ruber/projects/project_files_list.rb
|
142
|
-
- lib/ruber/projects/project_files_widget.rb
|
143
|
-
- lib/ruber/projects/project_list.rb
|
144
149
|
- lib/ruber/settings_container.rb
|
145
150
|
- lib/ruber/version.rb
|
146
151
|
- lib/ruber/plugin.rb
|
@@ -231,15 +236,19 @@ files:
|
|
231
236
|
- spec/framework.rb
|
232
237
|
- spec/ktexteditor_wrapper_spec.rb
|
233
238
|
- spec/hint_solver_spec.rb
|
239
|
+
- spec/environment_spec.rb
|
240
|
+
- spec/document_factory_spec.rb
|
234
241
|
- spec/kde_config_option_backend_spec.rb
|
235
242
|
- spec/auto_end_spec.rb
|
236
243
|
- spec/filtered_output_widget_spec.rb
|
237
244
|
- spec/settings_container_spec.rb
|
245
|
+
- spec/world_spec.rb
|
238
246
|
- spec/project_files_list_spec.rb
|
239
247
|
- spec/document_project_spec.rb
|
240
248
|
- spec/ktexteditor_sugar_spec.rb
|
241
249
|
- spec/plugin_spec.rb
|
242
250
|
- spec/document_list_spec.rb
|
251
|
+
- spec/project_factory_spec.rb
|
243
252
|
- spec/component_manager_spec.rb
|
244
253
|
- spec/annotation_model_spec.rb
|
245
254
|
- spec/kde_sugar_spec.rb
|
@@ -1,412 +0,0 @@
|
|
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 'forwardable'
|
22
|
-
require 'pathname'
|
23
|
-
require 'facets/array/only'
|
24
|
-
|
25
|
-
require 'ruber/editor/document'
|
26
|
-
require 'ruber/plugin_like'
|
27
|
-
|
28
|
-
module Ruber
|
29
|
-
|
30
|
-
=begin rdoc
|
31
|
-
List of all open documents
|
32
|
-
|
33
|
-
It contains convenience methods to iterate on the open documents and to create
|
34
|
-
them. Whenever possible, you should use them. In particular, when you need a document
|
35
|
-
associated with a given file or URL, you should always use {#document}, so that
|
36
|
-
if a document for that file is already installed, no new document will be created.
|
37
|
-
|
38
|
-
If, for any reason, you need to create a document using {Document.new}, please
|
39
|
-
don't forget to add the document to the list using {#add_document}.
|
40
|
-
=end
|
41
|
-
class DocumentList < Qt::Object
|
42
|
-
|
43
|
-
include PluginLike
|
44
|
-
|
45
|
-
include Enumerable
|
46
|
-
|
47
|
-
=begin rdoc
|
48
|
-
Signal emitted when a new document is created
|
49
|
-
|
50
|
-
@param [Document] doc the new document
|
51
|
-
=end
|
52
|
-
signals 'document_created(QObject*)'
|
53
|
-
|
54
|
-
=begin rdoc
|
55
|
-
Signal emitted before a document is closed
|
56
|
-
|
57
|
-
@param [Document] doc the document which is being closed
|
58
|
-
=end
|
59
|
-
signals 'closing_document(QObject*)'
|
60
|
-
|
61
|
-
slots 'close_document(QObject*)', 'load_settings()'
|
62
|
-
|
63
|
-
=begin rdoc
|
64
|
-
@param [ComponentManager] _manager the component manager (unused)
|
65
|
-
@param [PluginSpecification] psf the plugin specification object
|
66
|
-
=end
|
67
|
-
def initialize _manager, psf
|
68
|
-
super Ruber[:app]
|
69
|
-
initialize_plugin psf
|
70
|
-
@docs = []
|
71
|
-
end
|
72
|
-
|
73
|
-
#DOCUMENT CREATION
|
74
|
-
|
75
|
-
=begin rdoc
|
76
|
-
Creates a new empty document
|
77
|
-
|
78
|
-
The document is automatically added to the list and the {#document_created} signal
|
79
|
-
is emitted
|
80
|
-
@return [Ruber::Document] the created document
|
81
|
-
=end
|
82
|
-
def new_document
|
83
|
-
doc = Document.new Ruber[:main_window]
|
84
|
-
add_document doc
|
85
|
-
emit document_created(doc)
|
86
|
-
doc
|
87
|
-
end
|
88
|
-
|
89
|
-
=begin rdoc
|
90
|
-
The document for a given file or url
|
91
|
-
|
92
|
-
If there's no open document associated with the given file or url, depending on
|
93
|
-
the value of _create_if_needed_ a new document associated with the file or url
|
94
|
-
will be created. In this case, the {#document_created} signal will be emitted.
|
95
|
-
|
96
|
-
@param [String, KDE::Url] file the file name or URL associated with the document.
|
97
|
-
A relative file name will be expanded with respect to the current directory. A
|
98
|
-
string containing a url will be interpreted as an url, not as a filename. If you
|
99
|
-
need a document with a name which looks like an url, you can create an empty
|
100
|
-
@KDE::Url@, then using @path=@ to set its path
|
101
|
-
@param [Boolean] create_if_needed whether or not to create a document associated
|
102
|
-
with _file_ if there isn't one
|
103
|
-
@return [Document,nil] the document associated with _file_. If no such document
|
104
|
-
exists and _create_if_needed_ is *false*, *nil* will be returned
|
105
|
-
@raise [ArgumentError] if _file_ is a local file, there's
|
106
|
-
no document for it, it doesn't exist and _create_if_needed_ is *true*. Note that
|
107
|
-
this won't happen if _file_ is a remote file, even if it doesn't exist
|
108
|
-
=end
|
109
|
-
def document file, create_if_needed = true
|
110
|
-
if file.is_a? String
|
111
|
-
url = KDE::Url.new file
|
112
|
-
url.path = File.expand_path(file) if url.relative?
|
113
|
-
else url = file
|
114
|
-
end
|
115
|
-
doc = document_for_url file
|
116
|
-
return doc if doc or !create_if_needed
|
117
|
-
if !doc and create_if_needed
|
118
|
-
if url.local_file?
|
119
|
-
raise ArgumentError, "File #{url.path} doesn't exist" unless File.exist?(url.path)
|
120
|
-
end
|
121
|
-
doc = Document.new Ruber[:main_window], url
|
122
|
-
add_document doc
|
123
|
-
emit document_created(doc)
|
124
|
-
end
|
125
|
-
doc
|
126
|
-
end
|
127
|
-
|
128
|
-
=begin rdoc
|
129
|
-
@return [Array<Document>] a list of open documents
|
130
|
-
=end
|
131
|
-
def documents
|
132
|
-
@docs.dup
|
133
|
-
end
|
134
|
-
alias :to_a :documents
|
135
|
-
|
136
|
-
=begin rdoc
|
137
|
-
@return [Boolean] whether the document list is empty or not
|
138
|
-
=end
|
139
|
-
def empty?
|
140
|
-
@docs.empty?
|
141
|
-
end
|
142
|
-
|
143
|
-
=begin rdoc
|
144
|
-
@return [Integer] the number of documents in the list
|
145
|
-
=end
|
146
|
-
def size
|
147
|
-
@docs.size
|
148
|
-
end
|
149
|
-
alias :length :size
|
150
|
-
|
151
|
-
=begin rdoc
|
152
|
-
Adds a new document to the list
|
153
|
-
|
154
|
-
If you use {#new_document} and {#document} to create documents, you don't need to
|
155
|
-
call this method.
|
156
|
-
|
157
|
-
*Note:* this method doesn't check whether the document has already been added to
|
158
|
-
the list. If so, the results may cause errors. Please, always make sure the document
|
159
|
-
isn't already in the list before calling this.
|
160
|
-
|
161
|
-
@param [Document, nil] doc the document to add. If *nil*, nothing is done
|
162
|
-
@return [Document, nil] _doc_
|
163
|
-
=end
|
164
|
-
def add_document doc
|
165
|
-
if doc
|
166
|
-
connect doc, SIGNAL('closing(QObject*)'), self, SLOT('close_document(QObject*)')
|
167
|
-
@docs << doc
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
=begin rdoc
|
172
|
-
Attempts to save the given documents
|
173
|
-
|
174
|
-
What happens if a document can't be saved depends on the value of _stop_on_failure_:
|
175
|
-
if it's *false*, documents which can't be saved are skipped, while if it's true,
|
176
|
-
this method will return as soon as one document fails to save.
|
177
|
-
|
178
|
-
*Note:* by can't be saved, we mean that the user chose to save a document but,
|
179
|
-
for any reason, it couldn't be saved (for example this can happen if the user
|
180
|
-
doesn't have write permission on the file, or if the disk is full). If the user
|
181
|
-
decides not to save the file, instead, it is considered a success.
|
182
|
-
|
183
|
-
@param [Array<Document>] docs an array with the documents to save
|
184
|
-
@param [Boolean] stop_on_failure what to do when a document fails to save. If *true*,
|
185
|
-
return immediately; if *false*, attempt to save the remaining documents
|
186
|
-
@return [Array<Document>] an array with the documents which couldn't be saved. If
|
187
|
-
_stop_on_failure_ is *false*, it contains only the documents for which saving failed;
|
188
|
-
if _stop_on_failure_ is *true* it also contains the documents for which saving
|
189
|
-
wasn't even attempted. If all documents were saved successfully, the array will
|
190
|
-
be empty
|
191
|
-
=end
|
192
|
-
def save_documents docs, stop_on_failure = false
|
193
|
-
failed = []
|
194
|
-
docs.each_with_index do |d, i|
|
195
|
-
success = d.save
|
196
|
-
failed << d unless success
|
197
|
-
if !success and stop_on_failure
|
198
|
-
failed += docs[(i+1)..-1]
|
199
|
-
break
|
200
|
-
end
|
201
|
-
end
|
202
|
-
failed
|
203
|
-
end
|
204
|
-
|
205
|
-
=begin rdoc
|
206
|
-
Saves the settings for all open documents
|
207
|
-
|
208
|
-
@return [nil]
|
209
|
-
=end
|
210
|
-
def save_settings
|
211
|
-
@docs.each{|d| d.save_settings}
|
212
|
-
nil
|
213
|
-
end
|
214
|
-
|
215
|
-
#CLOSING DOCUMENTS
|
216
|
-
|
217
|
-
=begin rdoc
|
218
|
-
Removes a document from the list
|
219
|
-
|
220
|
-
The {#closing_document} signal is emitted before removing the document.
|
221
|
-
@param [Document] doc the document to remove. It must have been added to the list
|
222
|
-
using {#add_document} (which is automatically called by {#document} and {#new_document})
|
223
|
-
@return [nil]
|
224
|
-
=end
|
225
|
-
def close_document doc
|
226
|
-
@docs.delete doc
|
227
|
-
emit closing_document(doc)
|
228
|
-
nil
|
229
|
-
end
|
230
|
-
private :close_document
|
231
|
-
|
232
|
-
=begin rdoc
|
233
|
-
Closes all the documents
|
234
|
-
|
235
|
-
If there are modified files and _ask_ is *true*, the user will be asked whether
|
236
|
-
he wants to save them (see {MainWindow#save_documents}). If he chooses to abort
|
237
|
-
closing, nothing will be done
|
238
|
-
|
239
|
-
@param [Boolean] ask if *true*, in case some files are modified, the user will
|
240
|
-
be asked whether to save them. If *false*, no file will be saved
|
241
|
-
@return [Boolean] *true* if the documents were closed and *false* otherwise
|
242
|
-
=end
|
243
|
-
def close_all ask = true
|
244
|
-
docs = @docs.dup
|
245
|
-
if !ask or Ruber[:main_window].save_documents docs
|
246
|
-
docs.each {|d| d.close false}
|
247
|
-
true
|
248
|
-
else false
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
#DOCUMENT ACCESS
|
253
|
-
|
254
|
-
=begin rdoc
|
255
|
-
The document corresponding to the given key
|
256
|
-
|
257
|
-
How _key_ is interpreted depends on its class:
|
258
|
-
* if it's an @Integer@, the document in the corresponding position in the list will
|
259
|
-
be returned
|
260
|
-
* if it's a @KDE::Url@, then the document associated with that url will be returned
|
261
|
-
* if it's a @String@ starting with a @/@ (that is, an absolute path) then the
|
262
|
-
document associated with that file will be returned
|
263
|
-
* if it's a string not startng with a @/@, then the document with that
|
264
|
-
@document_name@ will be returned
|
265
|
-
@param [String,Integer,KDE::Url] key the key for the document
|
266
|
-
@return [Document,nil] the document corresponding to _key_ or *nil* if no document
|
267
|
-
corresponds to it
|
268
|
-
@raise [TypeError] if _key_ is not a @String@, @Integer@ or @KDE::Url@
|
269
|
-
=end
|
270
|
-
def [] key
|
271
|
-
case key
|
272
|
-
when String
|
273
|
-
if Pathname.new(key).absolute? then @docs.find{|d| d.path == key}
|
274
|
-
else @docs.find{|d| d.document_name == key}
|
275
|
-
end
|
276
|
-
when KDE::Url
|
277
|
-
@docs.find{|d| d.url == key}
|
278
|
-
when Integer then @docs[key]
|
279
|
-
else raise TypeError
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
=begin rdoc
|
284
|
-
Calls the block for each document
|
285
|
-
@yield [Document] each document in turn
|
286
|
-
@return [DocumentList,Enumerator] @self@ if called with a block; an @Enumerable@
|
287
|
-
otherwise
|
288
|
-
=end
|
289
|
-
def each_document
|
290
|
-
if block_given?
|
291
|
-
@docs.each{|d| yield d}
|
292
|
-
self
|
293
|
-
else self.to_enum
|
294
|
-
end
|
295
|
-
end
|
296
|
-
alias_method :each, :each_document
|
297
|
-
|
298
|
-
=begin rdoc
|
299
|
-
The document associated with a given file
|
300
|
-
|
301
|
-
@param [String] file the name of the file. If it's relative, it will be considered
|
302
|
-
relative to the current directory
|
303
|
-
@return [Document,nil] the document associated with _file_ or *nil* if no such
|
304
|
-
document exists
|
305
|
-
=end
|
306
|
-
def document_for_file file
|
307
|
-
file = File.expand_path file
|
308
|
-
@docs.find{|d| d.path == file}
|
309
|
-
end
|
310
|
-
|
311
|
-
=begin rdoc
|
312
|
-
The document associated with a given URL
|
313
|
-
|
314
|
-
@param [KDE::Url] url the url
|
315
|
-
@return [Document,nil] the document associated with _url_ or *nil* if no such
|
316
|
-
document exists
|
317
|
-
=end
|
318
|
-
def document_for_url url
|
319
|
-
@docs.find{|d| d.url == url}
|
320
|
-
end
|
321
|
-
|
322
|
-
=begin rdoc
|
323
|
-
The document with a given name
|
324
|
-
|
325
|
-
@param [String] name the name of the document
|
326
|
-
@return [Document,nil] the document with @document_name@ _name_ or *nil* if no
|
327
|
-
document with that name exists
|
328
|
-
=end
|
329
|
-
def document_with_name name
|
330
|
-
@docs.find{|d| d.document_name == name}
|
331
|
-
end
|
332
|
-
|
333
|
-
=begin rdoc
|
334
|
-
The documents which are associated with a file
|
335
|
-
|
336
|
-
_which_ can be used to restrict the list of documents to only those associated
|
337
|
-
with local or remote files:
|
338
|
-
* if _which_ is @:local@ only documents associated with local files will be returned;
|
339
|
-
* if _which_ is @:remote@ only documents associated with remoted files will be returned;
|
340
|
-
* if _which_ has any other value, both documents associated with local and with
|
341
|
-
remote files will be returned
|
342
|
-
@param [Object] which which kind of documents should be included in the list
|
343
|
-
@return [Array<Document>] a list of documents associated with files, and restricted
|
344
|
-
according to the value of _which_
|
345
|
-
=end
|
346
|
-
def documents_with_file which = :any
|
347
|
-
@docs.select do |d|
|
348
|
-
if d.has_file?
|
349
|
-
case which
|
350
|
-
when :local then d.url.local_file?
|
351
|
-
when :remote then !d.url.local_file?
|
352
|
-
else true
|
353
|
-
end
|
354
|
-
end
|
355
|
-
end
|
356
|
-
end
|
357
|
-
|
358
|
-
#DOCUMENT QUERIES
|
359
|
-
|
360
|
-
=begin rdoc
|
361
|
-
Whether there's a document associated with a given file
|
362
|
-
|
363
|
-
@param [String] file the name of the file (absolute or relative to the current
|
364
|
-
directory)
|
365
|
-
@return [Boolean] *true* if there's a document associated with _file_ and *false*
|
366
|
-
otherwise
|
367
|
-
=end
|
368
|
-
def document_for_file? file
|
369
|
-
file = File.expand_path file
|
370
|
-
@docs.any?{|d| d.path == file}
|
371
|
-
end
|
372
|
-
|
373
|
-
=begin rdoc
|
374
|
-
Whether there's a document associated with a given URL
|
375
|
-
|
376
|
-
@param [@KDE::Url@] url the url
|
377
|
-
@return [Boolean] *true* if there's a document associated with _url_ and *false*
|
378
|
-
otherwise
|
379
|
-
=end
|
380
|
-
def document_for_url? url
|
381
|
-
@docs.any?{|d| d.url == url}
|
382
|
-
end
|
383
|
-
|
384
|
-
=begin rdoc
|
385
|
-
Whether there's a document with a given name
|
386
|
-
|
387
|
-
@param [String] name of the document
|
388
|
-
@return [Boolean] *true* if there's a document associated with _name_ and *false*
|
389
|
-
otherwise
|
390
|
-
=end
|
391
|
-
def document_with_name? name
|
392
|
-
@docs.any?{|d| d.document_name == name}
|
393
|
-
end
|
394
|
-
|
395
|
-
=begin rdoc
|
396
|
-
Override of {PluginLike#query_close}
|
397
|
-
|
398
|
-
It first calls the {DocumentProject#query_close query_close} of each document's
|
399
|
-
own project, returning *false* as soon as one of them returns *false*, then
|
400
|
-
attempts to save each document
|
401
|
-
|
402
|
-
@return [Boolean] *true* if it is all right to go on closing Ruber and *false*
|
403
|
-
otherwise
|
404
|
-
=end
|
405
|
-
def query_close
|
406
|
-
@docs.each{|d| return false unless d.own_project.query_close}
|
407
|
-
Ruber[:main_window].save_documents
|
408
|
-
end
|
409
|
-
|
410
|
-
end
|
411
|
-
|
412
|
-
end
|