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
|
@@ -0,0 +1,106 @@
|
|
|
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 'facets/kernel/constant'
|
|
24
|
+
|
|
25
|
+
require 'ruber/plugin_specification_reader'
|
|
26
|
+
|
|
27
|
+
module Ruber
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class PluginSpecification < OpenStruct
|
|
31
|
+
|
|
32
|
+
class PSFError < StandardError
|
|
33
|
+
attr_accessor :file
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class << self
|
|
37
|
+
alias_method :intro, :new
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.full file, dir = nil
|
|
41
|
+
res = self.new file, dir
|
|
42
|
+
res.complete_processing
|
|
43
|
+
res
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
attr_reader :directory
|
|
47
|
+
def initialize arg, dir = nil
|
|
48
|
+
super()
|
|
49
|
+
@directory = if dir then dir
|
|
50
|
+
elsif arg.is_a? String then File.dirname arg
|
|
51
|
+
else File.expand_path Dir.pwd
|
|
52
|
+
end
|
|
53
|
+
@intro_only = true
|
|
54
|
+
@reader = PluginSpecificationReader.new self
|
|
55
|
+
@data = arg.is_a?(Hash) ? arg : YAML.load( File.read(arg) )
|
|
56
|
+
@reader.process_pdf_intro @data
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def intro_only?
|
|
60
|
+
@intro_only
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def has_config_options?
|
|
64
|
+
raise "Ruber::PluginSpecification#has_config_options? can only be called on a full "\
|
|
65
|
+
"Ruber::PluginSpecification" if @intro_only
|
|
66
|
+
!config_options.empty?
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def has_tool_widgets?
|
|
70
|
+
raise "Ruber::PluginSpecification#has_tool_widgets? can only be called on a full "\
|
|
71
|
+
"Ruber::PluginSpecification" if @intro_only
|
|
72
|
+
!tool_widgets.empty?
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def has_config_widgets?
|
|
76
|
+
raise "Ruber::PluginSpecification#has_config_widgets? can only be called on a full "\
|
|
77
|
+
"Ruber::PluginSpecification" if @intro_only
|
|
78
|
+
!config_widgets.empty?
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def has_project_options?
|
|
82
|
+
raise "Ruber::PluginSpecification#has_project_options? can only be called on a full "\
|
|
83
|
+
"Ruber::PluginSpecification" if @intro_only
|
|
84
|
+
!project_options.empty?
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def has_project_widgets?
|
|
88
|
+
raise "Ruber::PluginSpecification#has_project_widgets? can only be called on a full "\
|
|
89
|
+
"Ruber::PluginSpecification" if @intro_only
|
|
90
|
+
!project_widgets.empty?
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def has_extensions?
|
|
94
|
+
raise "Ruber::PluginSpecification#has_extensions? can only be called on a full "\
|
|
95
|
+
"Ruber::PluginSpecification" if @intro_only
|
|
96
|
+
!extensions.empty?
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def complete_processing
|
|
100
|
+
@reader.process_pdf @data
|
|
101
|
+
@intro_only = false
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
@@ -0,0 +1,451 @@
|
|
|
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 'facets/ostruct'
|
|
22
|
+
|
|
23
|
+
module Ruber
|
|
24
|
+
|
|
25
|
+
class PluginSpecificationReader
|
|
26
|
+
|
|
27
|
+
=begin rdoc
|
|
28
|
+
Class used to contain the information about an option. It behaves as a regular
|
|
29
|
+
+OpenStruct+, except for the +default+ and the <tt>to_os</tt> methods.
|
|
30
|
+
=end
|
|
31
|
+
class Option < OpenStruct
|
|
32
|
+
|
|
33
|
+
=begin rdoc
|
|
34
|
+
Returns the default value of the option, computed basing on the value stored in
|
|
35
|
+
the +default+ entry in the option description in the PDF. In particular:
|
|
36
|
+
* if the value is not a string, it is returned unchanged
|
|
37
|
+
* if the value is a string and the <tt>eval_default</tt> attribute has been set
|
|
38
|
+
to *false* in the PDF, it is returned unchanged
|
|
39
|
+
* if it is a string, it is evaluated in the bindings _bind_ (using +eval+) and
|
|
40
|
+
the corresponding value is returned. If +eval+ raises +SyntaxError+, +NoMethodError+
|
|
41
|
+
or +NameError+ then the string is returned unchanged (of course, the exception
|
|
42
|
+
isn't propagated).
|
|
43
|
+
=end
|
|
44
|
+
def default bind = TOPLEVEL_BINDING
|
|
45
|
+
val = super()
|
|
46
|
+
if val.is_a? String and self.eval_default
|
|
47
|
+
begin eval val, bind
|
|
48
|
+
rescue NoMethodError, SyntaxError, NameError, ArgumentError
|
|
49
|
+
val
|
|
50
|
+
end
|
|
51
|
+
else val
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def compute_default bind = TOPLEVEL_BINDING
|
|
56
|
+
val = super()
|
|
57
|
+
if val.is_a? String and self.eval_default
|
|
58
|
+
begin eval val, bind
|
|
59
|
+
rescue NoMethodError, SyntaxError, NameError, ArgumentError
|
|
60
|
+
val
|
|
61
|
+
end
|
|
62
|
+
else val
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
=begin rdoc
|
|
67
|
+
Returns an +OpenStruct+ with the same contents as *self*, except for the +default+
|
|
68
|
+
attribute, which is obtained using the +default+ method using the bindings _bind_.
|
|
69
|
+
=end
|
|
70
|
+
def to_os bind = TOPLEVEL_BINDING
|
|
71
|
+
hash = to_h
|
|
72
|
+
hash[:default] = default bind
|
|
73
|
+
OpenStruct.new hash
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
=begin rdoc
|
|
79
|
+
A list of valid licences
|
|
80
|
+
=end
|
|
81
|
+
LICENSES = [:unknown, :gpl, :gpl2, :lgpl, :lgpl2, :bsd, :artistic, :qpl, :qpl1, :gpl3, :lgpl3]
|
|
82
|
+
|
|
83
|
+
def initialize info
|
|
84
|
+
@plugin_info = info
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def process_pdf hash
|
|
88
|
+
@plugin_info.name = read_name hash
|
|
89
|
+
@plugin_info.about = read_about hash
|
|
90
|
+
@plugin_info.version = read_version hash
|
|
91
|
+
@plugin_info.required = read_required hash
|
|
92
|
+
@plugin_info.required.each{|f| require File.join(@plugin_info.directory, f)}
|
|
93
|
+
@plugin_info.class_obj = read_class hash
|
|
94
|
+
@plugin_info.features = read_features hash
|
|
95
|
+
@plugin_info.deps = read_deps hash
|
|
96
|
+
@plugin_info.runtime_deps = read_runtime_deps hash
|
|
97
|
+
@plugin_info.ui_file = read_ui_file hash
|
|
98
|
+
@plugin_info.tool_widgets = read_tool_widgets hash
|
|
99
|
+
@plugin_info.config_widgets = read_config_widgets hash
|
|
100
|
+
@plugin_info.config_options = read_config_options hash
|
|
101
|
+
@plugin_info.project_options = read_project_options hash
|
|
102
|
+
@plugin_info.project_widgets = read_project_widgets hash
|
|
103
|
+
@plugin_info.extensions = read_extensions hash
|
|
104
|
+
@plugin_info.actions = read_actions hash
|
|
105
|
+
@plugin_info
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def process_pdf_intro hash, component = false
|
|
109
|
+
@plugin_info.name = read_name hash, component
|
|
110
|
+
@plugin_info.about = read_about hash
|
|
111
|
+
@plugin_info.version = read_version hash
|
|
112
|
+
@plugin_info.required = read_required hash
|
|
113
|
+
@plugin_info.features = read_features hash
|
|
114
|
+
@plugin_info.deps = read_deps hash
|
|
115
|
+
@plugin_info.runtime_deps = read_runtime_deps hash
|
|
116
|
+
@plugin_info
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
private
|
|
120
|
+
|
|
121
|
+
def has_key? hash, key
|
|
122
|
+
hash.has_key?(key) or hash.has_key?(key.to_sym)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def get_value hash, key, default, required = false
|
|
126
|
+
hash.fetch(key) do |k|
|
|
127
|
+
if required
|
|
128
|
+
hash.fetch(key.to_s){raise PluginSpecification::PSFError,
|
|
129
|
+
"The required '#{key}' entry is missing from the PDF"}
|
|
130
|
+
else hash.fetch(key.to_s, default)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def get_maybe_array hash, key, conversion = nil, required = false
|
|
136
|
+
res = get_value( hash, key, [], required).to_array
|
|
137
|
+
res = res.map{|i| i.send conversion} if conversion
|
|
138
|
+
res
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def read_name hash, component = false
|
|
143
|
+
res = get_value(hash, :name, nil, !component)
|
|
144
|
+
res ? res.to_sym : res
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def read_description hash
|
|
149
|
+
get_value(hash, :description, '').to_s
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def read_class hash, component = false
|
|
154
|
+
res = get_value(hash, :class, 'Ruber::Plugin')
|
|
155
|
+
res ? constant(res.to_s) : nil
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def read_required hash
|
|
160
|
+
get_maybe_array hash, :require, :to_s
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def read_features hash
|
|
165
|
+
res = get_maybe_array hash, :features, :to_sym
|
|
166
|
+
name = get_value(hash, :name, nil)
|
|
167
|
+
res.unshift name.to_sym if name
|
|
168
|
+
res
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def read_deps hash
|
|
173
|
+
get_maybe_array hash, :deps, :to_sym
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def read_runtime_deps hash
|
|
178
|
+
get_maybe_array hash, :runtime_deps, :to_sym
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def read_ui_file hash
|
|
183
|
+
get_value( hash, :ui_file, '').to_s
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def read_widget hash, required = []
|
|
188
|
+
res = {}
|
|
189
|
+
res[:caption] = get_value(hash, :caption, nil)
|
|
190
|
+
pixmap = get_value(hash, :pixmap, @plugin_info.about.icon)
|
|
191
|
+
if required.include? :pixmap and pixmap.empty?
|
|
192
|
+
raise PluginSpecification::PSFError, "The :pixmap entry must be present in the widget description"
|
|
193
|
+
end
|
|
194
|
+
res[:pixmap] = pixmap_file pixmap
|
|
195
|
+
cls = get_value(hash, :class, nil)
|
|
196
|
+
res[:class_obj] = cls ? constant(cls) : nil
|
|
197
|
+
res[:code] = get_value(hash, :code, nil)
|
|
198
|
+
res[:required] = get_maybe_array hash, :required
|
|
199
|
+
raise PluginSpecification::PSFError, "A widget description can't contain both the :class and "\
|
|
200
|
+
"the :code entries" if res[:class_obj] and res[:code]
|
|
201
|
+
raise PluginSpecification::PSFError, "Either the :class or the :code entry must be present in "\
|
|
202
|
+
"the widget description" unless res[:class_obj] or res[:code]
|
|
203
|
+
if required.include? :caption and !res[:caption]
|
|
204
|
+
raise PluginSpecification::PSFError, "The :caption entry must be present in the widget description"
|
|
205
|
+
elsif !res[:caption] then res[:caption] = ''
|
|
206
|
+
end
|
|
207
|
+
OpenStruct.new(res)
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def read_tool_widgets hash
|
|
212
|
+
res = get_value(hash, :tool_widgets, [])
|
|
213
|
+
res.to_array.map do |a|
|
|
214
|
+
o = read_widget a, [:pixmap, :caption]
|
|
215
|
+
o.position = get_value(a, :position, :bottom).to_sym
|
|
216
|
+
o.name = get_value(a, :name, o.caption).to_s
|
|
217
|
+
o.var_name = get_value(a, :var_name, 'widget')
|
|
218
|
+
o.var_name = o.var_name.to_s if o.var_name
|
|
219
|
+
o
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def read_config_widgets hash
|
|
225
|
+
res = get_value(hash, :config_widgets, [])
|
|
226
|
+
res = res.to_array
|
|
227
|
+
res.map{|h| read_widget h, [:caption]}
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
def read_config_options hash
|
|
232
|
+
hash = get_value(hash, :config_options, {})
|
|
233
|
+
hash.inject({}) do |res, i|
|
|
234
|
+
g, h = i
|
|
235
|
+
g = g.to_sym
|
|
236
|
+
h.each_pair{ |n, o| res[[g, n.to_sym]] = read_option g, n.to_sym, o}
|
|
237
|
+
res
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def read_project_options hash
|
|
243
|
+
hash = get_value(hash, :project_options, {})
|
|
244
|
+
hash.inject({}) do |res, i|
|
|
245
|
+
g, h = i
|
|
246
|
+
g = g.to_sym
|
|
247
|
+
h.each_pair do |n, o|
|
|
248
|
+
op = read_option g, n.to_sym, o
|
|
249
|
+
rules = read_rules o
|
|
250
|
+
op = Option.new op.instance_variable_get(:@table).merge(rules)
|
|
251
|
+
op.type = get_value(o, :type, :global).to_sym
|
|
252
|
+
res[[g, n.to_sym]] = op
|
|
253
|
+
end
|
|
254
|
+
res
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
def read_option group, name, hash
|
|
259
|
+
res = {:name => name.to_sym, :group => group.to_sym}
|
|
260
|
+
default = get_value(hash, :default, nil)
|
|
261
|
+
res[:relative_path] = get_value(hash, :relative_path, false)
|
|
262
|
+
res[:eval_default] = get_value(hash, :eval_default, true)
|
|
263
|
+
res[:default] = get_value(hash, :default, '')
|
|
264
|
+
res[:order] = get_value(hash, :order, nil)
|
|
265
|
+
d res if res.keys.any?{|k| k.nil?}
|
|
266
|
+
Option.new res
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
def read_project_widgets hash
|
|
271
|
+
res = get_value(hash, :project_widgets, []).to_array
|
|
272
|
+
res = res.map do |h|
|
|
273
|
+
w = read_widget h, [:caption]
|
|
274
|
+
rules = read_rules h
|
|
275
|
+
w = Option.new w.instance_variable_get(:@table).merge(rules)
|
|
276
|
+
w
|
|
277
|
+
end
|
|
278
|
+
res
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def read_extensions hash
|
|
283
|
+
hash = get_value(hash, :extensions, {})
|
|
284
|
+
hash.inject({}) do |res, i|
|
|
285
|
+
name, h= i[0].to_sym, i[1]
|
|
286
|
+
ext = read_extension name, h
|
|
287
|
+
# ext.scope = Array(get_value(h, :scope, [:global, :document])).map{|i| i.to_sym}
|
|
288
|
+
res[name] = ext
|
|
289
|
+
res
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
def read_extension name, data
|
|
294
|
+
if data.is_a? Array
|
|
295
|
+
data.inject([]){|res, i| res << read_extension(name, i)}
|
|
296
|
+
else
|
|
297
|
+
res = {:name => name}
|
|
298
|
+
res[:class_obj] = eval get_value(data, :class, nil, true)
|
|
299
|
+
res.merge! read_rules(data)
|
|
300
|
+
OpenStruct.new res
|
|
301
|
+
end
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
def read_actions hash
|
|
305
|
+
res = {}
|
|
306
|
+
hash = get_value(hash, :actions, {})
|
|
307
|
+
hash.each_pair do |name, data|
|
|
308
|
+
name = name.to_s
|
|
309
|
+
res[name] = read_action name.to_s, data
|
|
310
|
+
end
|
|
311
|
+
res
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
def read_action name, hash
|
|
315
|
+
res = {}
|
|
316
|
+
res[:name] = name
|
|
317
|
+
unless res[:name]
|
|
318
|
+
raise PluginSpecification::PSFError, "The required 'name' entry is missing from the PDF"
|
|
319
|
+
end
|
|
320
|
+
res[:text] = get_value hash, :text, ''
|
|
321
|
+
short = get_value hash, :shortcut, nil
|
|
322
|
+
res[:shortcut] = short ? KDE::Shortcut.new(short) : nil
|
|
323
|
+
res[:help] = get_value hash, :help, ''
|
|
324
|
+
res[:icon] = pixmap_file get_value(hash, :icon, nil)
|
|
325
|
+
cls = get_value(hash, :class, nil)
|
|
326
|
+
std_action = get_value hash, :standard_action, nil
|
|
327
|
+
if !cls and std_action
|
|
328
|
+
res[:standard_action] = std_action.to_sym
|
|
329
|
+
else res[:action_class] = constant(cls || 'KDE::Action')
|
|
330
|
+
end
|
|
331
|
+
# res[:delayed] = get_value hash, :delayed, false
|
|
332
|
+
res[:receiver] = get_value hash, :receiver, 'self'
|
|
333
|
+
res[:signal] = get_value hash, :signal, 'triggered(bool)'
|
|
334
|
+
res[:slot] = get_value hash, :slot, nil
|
|
335
|
+
res[:states] = get_value hash, :states, []
|
|
336
|
+
res[:state] = get_value hash, :state, nil if res[:states].empty?
|
|
337
|
+
OpenStruct.new res
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
=begin rdoc
|
|
341
|
+
Finds the absolute file for the pixmap file _pixmap_. In particular, if a file
|
|
342
|
+
called _pixmap_ exists in the plugin directory, the full path of that file is returned.
|
|
343
|
+
If such a file doesn't exist, then <tt>KDE::IconLoader</tt> is used to find the
|
|
344
|
+
path. If <tt>KDE::IconLoader</tt> also fails, an empty string is returned.
|
|
345
|
+
|
|
346
|
+
If the application hasn't been created yet, this method always returns the absolute path
|
|
347
|
+
of the file as if it were in the plugin directory (this happens because <tt>KDE::IconLoader</tt>
|
|
348
|
+
can't be used if the application hasn't been created)
|
|
349
|
+
=end
|
|
350
|
+
def pixmap_file pixmap
|
|
351
|
+
if pixmap
|
|
352
|
+
pix_file = File.join( @plugin_info.directory || Dir.pwd, pixmap)
|
|
353
|
+
if File.exist?( pix_file ) or !KDE::Application.instance then pix_file
|
|
354
|
+
else KDE::IconLoader.pixmap_path(pixmap) || ''
|
|
355
|
+
end
|
|
356
|
+
else ''
|
|
357
|
+
end
|
|
358
|
+
end
|
|
359
|
+
|
|
360
|
+
def read_human_name hash
|
|
361
|
+
res = get_value hash, :human_name, nil
|
|
362
|
+
res || @plugin_info.name.to_s.sub('_', ' ').capitalize
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
def read_authors hash
|
|
366
|
+
res = get_value hash, :authors, []
|
|
367
|
+
res = if res.is_a? Array and (res.empty? or res[0].is_a? Array) then res
|
|
368
|
+
elsif res.is_a? Array then [res]
|
|
369
|
+
else raise PluginSpecification::PSFError, 'The "authors" entry in the PDF should be an array'
|
|
370
|
+
end
|
|
371
|
+
res.each{|a| a << '' if a.size == 1}
|
|
372
|
+
res
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
def read_license hash
|
|
376
|
+
res = get_value hash, :license, :unknown
|
|
377
|
+
if LICENSES.include? res.to_sym then res.to_sym
|
|
378
|
+
elsif res.is_a? String then res
|
|
379
|
+
else raise PluginSpecification::PSFError, "Invalid licese type :#{res}"
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
def read_version hash
|
|
384
|
+
get_value hash, :version, '0.0.0'
|
|
385
|
+
end
|
|
386
|
+
|
|
387
|
+
def read_bug_address hash
|
|
388
|
+
get_value hash, :bug_address, ''
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
def read_copyright hash
|
|
392
|
+
get_value hash, :copyright, ''
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
def read_homepage hash
|
|
396
|
+
res = get_value hash, :homepage, ''
|
|
397
|
+
unless res.empty? or res.match(%r{^http://})
|
|
398
|
+
res = 'http://'+res
|
|
399
|
+
end
|
|
400
|
+
res
|
|
401
|
+
end
|
|
402
|
+
|
|
403
|
+
def read_icon hash
|
|
404
|
+
res = get_value(hash, :icon, nil)
|
|
405
|
+
res ? pixmap_file(res) : ''
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
def read_rules hash
|
|
409
|
+
res = {}
|
|
410
|
+
scope = Array(get_value hash, :scope, [:global]).map &:to_sym
|
|
411
|
+
scope = [:global, :document] if scope == [:all]
|
|
412
|
+
res[:scope] = scope
|
|
413
|
+
res[:mimetype] = Array(get_value(hash, :mimetype, []))
|
|
414
|
+
res[:file_extension] = Array(get_value(hash, :file_extension, []))
|
|
415
|
+
res
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
def read_about hash
|
|
419
|
+
res = {}
|
|
420
|
+
hash = get_value hash, :about, {}
|
|
421
|
+
res[:human_name] = read_human_name hash
|
|
422
|
+
res[:authors] = read_authors hash
|
|
423
|
+
res[:license] = read_license hash
|
|
424
|
+
res[:bug_address] = read_bug_address hash
|
|
425
|
+
res[:copyright] = read_copyright hash
|
|
426
|
+
res[:homepage] = read_homepage hash
|
|
427
|
+
res[:description] = read_description hash
|
|
428
|
+
res[:icon] = read_icon hash
|
|
429
|
+
# Sometimes, an exception is raised because sometimes, when loading plugins,
|
|
430
|
+
# I get an exception where OpenStruct complains because of a nil key. It
|
|
431
|
+
# happens randomly, however. Let's see whether this removes the error and
|
|
432
|
+
# makes clearer why it's happening
|
|
433
|
+
if res.has_key? nil
|
|
434
|
+
deleted_value = res.delete nil
|
|
435
|
+
msg = <<-EOS
|
|
436
|
+
This is information for Ruber developers only. Unless you aren't one of them, you can close and ignore this message box.
|
|
437
|
+
|
|
438
|
+
One of the entries of the about hash in the PSF was nil. The corresponding value was: #{deleted_value.inspect}"
|
|
439
|
+
EOS
|
|
440
|
+
KDE::MessageBox.information nil, deleted_value.inspect
|
|
441
|
+
end
|
|
442
|
+
begin OpenStruct.new res
|
|
443
|
+
rescue Exception
|
|
444
|
+
puts "The following exception occurred while reading the About data for #{@plugin_info.plugin_name}.\nThe contents of the hash was: #{res.inspect}"
|
|
445
|
+
raise
|
|
446
|
+
end
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
end
|