ruber 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/CHANGES +42 -1
  2. data/lib/ruber/application/application.rb +25 -5
  3. data/lib/ruber/application/plugin.yaml +2 -10
  4. data/lib/ruber/component_manager.rb +2 -2
  5. data/lib/ruber/document_project.rb +5 -3
  6. data/lib/ruber/editor/document.rb +5 -4
  7. data/lib/ruber/editor/ktexteditor_wrapper.rb +1 -1
  8. data/lib/ruber/exception_widgets.rb +1 -1
  9. data/lib/ruber/main_window/main_window.rb +4 -3
  10. data/lib/ruber/main_window/main_window_actions.rb +2 -2
  11. data/lib/ruber/main_window/main_window_internal.rb +1 -1
  12. data/lib/ruber/output_widget.rb +17 -5
  13. data/lib/ruber/project.rb +34 -3
  14. data/lib/ruber/project_dir_scanner.rb +171 -0
  15. data/lib/ruber/settings_container.rb +7 -7
  16. data/lib/ruber/settings_dialog.rb +24 -24
  17. data/lib/ruber/version.rb +1 -1
  18. data/lib/ruber/world/environment.rb +1 -0
  19. data/lib/ruber/world/plugin.yaml +7 -2
  20. data/lib/ruber/{application → world}/project_files_widget.rb +0 -0
  21. data/lib/ruber/{application → world}/ui/project_files_rule_chooser_widget.rb +2 -2
  22. data/lib/ruber/{application → world}/ui/project_files_rule_chooser_widget.ui +0 -0
  23. data/lib/ruber/{application → world}/ui/project_files_widget.rb +2 -2
  24. data/lib/ruber/{application → world}/ui/project_files_widget.ui +0 -0
  25. data/plugins/auto_end/auto_end.rb +21 -18
  26. data/plugins/autosave/autosave.rb +1 -1
  27. data/plugins/find_in_files/find_in_files.rb +1 -1
  28. data/plugins/irb/irb.png +0 -0
  29. data/plugins/irb/irb.rb +142 -0
  30. data/plugins/irb/irb.svg +240 -0
  31. data/plugins/irb/irb_controller.rb +541 -0
  32. data/plugins/irb/irbrc.rb +21 -0
  33. data/plugins/irb/plugin.yaml +19 -0
  34. data/plugins/irb/ui/irb_config_widget.rb +151 -0
  35. data/plugins/irb/ui/irb_config_widget.ui +123 -0
  36. data/plugins/irb/ui/irb_tool_widget.rb +97 -0
  37. data/plugins/irb/ui/irb_tool_widget.ui +86 -0
  38. data/plugins/project_browser/project_browser.rb +1 -1
  39. data/plugins/rspec/plugin.yaml +6 -3
  40. data/plugins/rspec/rspec.rb +172 -473
  41. data/plugins/rspec/tool_widget.rb +462 -0
  42. data/plugins/rspec/ui/rspec_project_widget.rb +58 -38
  43. data/plugins/rspec/ui/rspec_project_widget.ui +68 -64
  44. data/plugins/ruberri/class_formatter.rb +126 -0
  45. data/plugins/ruberri/method_formatter.rb +90 -0
  46. data/plugins/ruberri/plugin.yaml +13 -0
  47. data/plugins/ruberri/ruberri.rb +226 -0
  48. data/plugins/ruberri/search.rb +111 -0
  49. data/plugins/ruberri/ui/tool_widget.rb +73 -0
  50. data/plugins/ruberri/ui/tool_widget.ui +49 -0
  51. data/plugins/ruby_runner/ruby_runner.rb +2 -2
  52. data/plugins/ruby_syntax_checker/plugin.yaml +11 -0
  53. data/plugins/ruby_syntax_checker/ruby_syntax_checker.rb +147 -0
  54. data/plugins/syntax_checker/plugin.yaml +10 -6
  55. data/plugins/syntax_checker/syntax_checker.rb +216 -520
  56. data/plugins/syntax_checker/ui/config_widget.rb +61 -0
  57. data/plugins/syntax_checker/ui/config_widget.ui +44 -0
  58. data/plugins/yaml_syntax_checker/plugin.yaml +11 -0
  59. data/plugins/yaml_syntax_checker/yaml_syntax_checker.rb +62 -0
  60. data/ruber.desktop +0 -0
  61. data/spec/auto_end_spec.rb +224 -186
  62. data/spec/document_project_spec.rb +9 -1
  63. data/spec/document_spec.rb +9 -0
  64. data/spec/environment_spec.rb +12 -0
  65. data/spec/output_widget_spec.rb +69 -2
  66. data/spec/project_dir_scanner_spec.rb +195 -0
  67. data/spec/project_spec.rb +43 -73
  68. data/spec/ruby_syntax_checker_spec.rb +361 -0
  69. data/spec/syntax_checker_spec.rb +1132 -0
  70. data/spec/yaml_syntax_checker_spec.rb +130 -0
  71. metadata +232 -225
  72. data/lib/ruber/application/project_files_list.rb +0 -320
  73. data/spec/project_files_list_spec.rb +0 -411
@@ -0,0 +1,90 @@
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
+ require 'rdoc/ri/driver'
22
+ require 'rdoc/ri/store'
23
+ require 'rdoc/markup/document'
24
+ require 'rdoc/markup/to_html'
25
+
26
+ module Ruber
27
+
28
+ module RI
29
+
30
+ class MethodFormatter
31
+
32
+ def initialize method, store, store_type
33
+ @store = RDoc::RI::Store.new store, store_type
34
+ cls= method.split(/(?:::)|#/, 2)[0]
35
+ @method = @store.load_method cls, method
36
+ end
37
+
38
+ def to_html
39
+ title = "#{@method.full_name}"
40
+ title << " (from #{@store.friendly_path})" unless @store.friendly_path =~ /ruby core/
41
+ parts = [RDoc::Markup::Heading.new(1, title)]
42
+ parts << format_aliases
43
+ parts << format_arglists
44
+ parts << @method.comment
45
+ parts.compact!
46
+ doc = RDoc::Markup::Document.new
47
+ last = parts.count - 1
48
+ parts.each_with_index do |prt, i|
49
+ if prt.is_a? Array then prt.each{|x| doc << x}
50
+ else doc << prt
51
+ end
52
+ doc << RDoc::Markup::Rule.new(1) unless i == last
53
+ end
54
+ formatter = RDoc::Markup::ToHtml.new
55
+ doc.accept formatter
56
+ end
57
+
58
+ private
59
+
60
+ def format_arglists
61
+ return unless @method.arglists
62
+ res = []
63
+ arglists = @method.arglists.chomp.split("\n")
64
+ arglists.each do |l|
65
+ res << RDoc::Markup::Verbatim.new(l)
66
+ end
67
+ res
68
+ end
69
+
70
+ def format_aliases
71
+ return if @method.aliases.empty?
72
+ res = [RDoc::Markup::Heading.new(1, 'Also known as')]
73
+ items = @method.aliases.map do |a|
74
+ RDoc::Markup::ListItem.new nil, RDoc::Markup::Paragraph.new(a)
75
+ end
76
+ list = RDoc::Markup::List.new :BULLET, *items
77
+ res << list
78
+ res
79
+ end
80
+
81
+ end
82
+
83
+ end
84
+
85
+ end
86
+
87
+ if $0 == __FILE__
88
+ mth, store, store_type = *ARGV
89
+ puts Ruber::RI::MethodFormatter.new(mth, store, store_type.to_sym).to_html
90
+ end
@@ -0,0 +1,13 @@
1
+ name: ruberri
2
+ version: 0.0.1
3
+ about:
4
+ authors: [Stefano Crocco, stefano.crocco@alice.it]
5
+ license: gpl
6
+ description: Search the ri documentation from within Ruber
7
+ bug_address: http://github.com/stcrocco/ruber/issues
8
+ icon: help-contents
9
+ human_name: RI
10
+ deps: [ruby_development]
11
+ class: Ruber::RI::Plugin
12
+ require: ruberri
13
+ tool_widgets: {:class: Ruber::RI::ToolWidget, :caption: RI, :position: :bottom, :name: ri_widget, var_name: tool_widget}
@@ -0,0 +1,226 @@
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
+ require_relative 'ui/tool_widget'
22
+
23
+ require 'rdoc/ri/driver'
24
+ require 'rdoc/ri/store'
25
+ require 'open3'
26
+ require 'yaml'
27
+
28
+ module Ruber
29
+
30
+ module RI
31
+
32
+ class Plugin < Ruber::Plugin
33
+
34
+ def search text
35
+ cmd = [ruby, File.join(File.dirname(__FILE__), 'search.rb'), text]
36
+ list = nil
37
+ err = nil
38
+ status = nil
39
+ Open3.popen3(*cmd) do |stdin, stdout, stderr, thr|
40
+ list = stdout.read
41
+ err = stderr.read
42
+ status = thr.value
43
+ end
44
+ if status.success?
45
+ display_search_result YAML.load(list)
46
+ else
47
+ text = <<-EOS
48
+ <h1>Error</h1>
49
+ <p>It was impossible to search the RI database. The reported error was:</p>
50
+ <verbatim>
51
+ #{err}
52
+ </verbatim>
53
+ EOS
54
+ @tool_widget.content = text
55
+ end
56
+
57
+ end
58
+
59
+ private
60
+
61
+ def ruby
62
+ Ruber[:ruby_development].interpreter_for Ruber[:world].active_document
63
+ end
64
+
65
+ def display_search_result found
66
+ if found[:list] and found[:list].count > 1
67
+ if found[:type] == :class then content = format_class_list found[:list]
68
+ else content = format_method_list found[:list]
69
+ end
70
+ @tool_widget.content = content
71
+ elsif found[:list] and found[:list].count == 1
72
+ obj = found[:list][0]
73
+ display found[:type], obj[:store], obj[:store_type], obj[:name]
74
+ else @tool_widget.content = '<h1>Nothing found</h1>'
75
+ end
76
+ end
77
+
78
+ def display_url url
79
+ scheme = url.scheme
80
+ store, type, name = url.path.split('$', 3)
81
+ display scheme.to_sym, store, type.to_sym, name
82
+ end
83
+ slots 'display_url(QUrl)'
84
+
85
+ def display type, store, store_type, name
86
+ if type == :method
87
+ @tool_widget.content = format_method name, store, store_type
88
+ else
89
+ @tool_widget.content = format_class name, store, store_type
90
+ end
91
+ end
92
+
93
+ def format_class_list classes
94
+ res = "<h1>Results from RI</h1>"
95
+ classes.each do |data|
96
+ encoded_name = Qt::Url.to_percent_encoding data[:name]
97
+ url = "class://#{data[:store]}$#{data[:store_type]}$#{encoded_name}"
98
+ res << %[<p><a href="#{url}">#{data[:name]} &ndash; from #{data[:friendly_store]}</a></p>]
99
+ end
100
+ res
101
+ end
102
+
103
+ def format_method_list methods
104
+ res = "<h1>Results from RI</h1>"
105
+ methods.each do |data|
106
+ encoded_name = Qt::Url.to_percent_encoding(data[:name])
107
+ url = "method://#{data[:store]}$#{data[:store_type]}$#{encoded_name}"
108
+ res << %[<p><a href="#{url}">#{data[:name]} &ndash; from #{data[:friendly_store]}</a></p>]
109
+ end
110
+ res
111
+ end
112
+
113
+ def format_class cls, store, store_type
114
+ cmd = [ruby, File.join(File.dirname(__FILE__), 'class_formatter.rb'), cls, store, store_type.to_s]
115
+ html = nil
116
+ err = nil
117
+ status = nil
118
+ Open3.popen3(*cmd) do |stdin, stdout, stderr, thr|
119
+ html = stdout.read
120
+ err = stderr.read
121
+ status = thr.value
122
+ end
123
+ if status.success?
124
+ @tool_widget.content = html
125
+ else
126
+ text = <<-EOS
127
+ <h1>Error</h1>
128
+ <p>It was impossible to loop #{cls} up in the RI database. The reported error was:</p>
129
+ <verbatim>
130
+ #{err}
131
+ </verbatim>
132
+ EOS
133
+ end
134
+
135
+ end
136
+
137
+ def format_method method, store, store_type
138
+ cmd = [ruby, File.join(File.dirname(__FILE__), 'method_formatter.rb'), method, store, store_type.to_s]
139
+ html = nil
140
+ err = nil
141
+ status = nil
142
+ Open3.popen3(*cmd) do |stdin, stdout, stderr, thr|
143
+ html = stdout.read
144
+ err = stderr.read
145
+ status = thr.value
146
+ end
147
+ if status.success?
148
+ @tool_widget.content = html
149
+ else
150
+ text = <<-EOS
151
+ <h1>Error</h1>
152
+ <p>It was impossible to look #{method} up the RI database. The reported error was:</p>
153
+ <verbatim>
154
+ #{err}
155
+ </verbatim>
156
+ EOS
157
+ end
158
+ end
159
+
160
+ def find_classes drv, name
161
+ begin cls = drv.expand_class(Regexp.quote(name))
162
+ rescue RDoc::RI::Driver::NotFoundError
163
+ return
164
+ end
165
+ stores = drv.classes[cls]
166
+ return unless stores
167
+ classes = []
168
+ stores.each do |s|
169
+ classes << [s.load_class(cls), s]
170
+ end
171
+ classes
172
+ end
173
+
174
+ def find_methods drv, name
175
+ found = drv.load_methods_matching name
176
+ return nil if found.empty?
177
+ filtered = drv.filter_methods found, name
178
+ methods = []
179
+ filtered.each do |store, mthds|
180
+ mthds.each{|m| methods << [m, store]}
181
+ end
182
+ methods.empty? ? nil : methods
183
+ end
184
+
185
+ end
186
+
187
+ class ToolWidget < Qt::Widget
188
+
189
+ def initialize parent = nil
190
+ super
191
+ @ui = Ui::RIToolWidget.new
192
+ @ui.setup_ui self
193
+ connect @ui.search_term, SIGNAL(:returnPressed), @ui.search, SIGNAL(:clicked)
194
+ connect @ui.search, SIGNAL(:clicked), self, SLOT(:start_search)
195
+ @ui.content.open_links = false
196
+ connect @ui.content, SIGNAL('anchorClicked(QUrl)'), Ruber[:ruberri], SLOT('display_url(QUrl)')
197
+ end
198
+
199
+ def content
200
+ @ui.content.to_html
201
+ end
202
+
203
+ def content= txt
204
+ @ui.content.text = txt
205
+ end
206
+
207
+ def set_focus reason = Qt::OtherFocusReason
208
+ super
209
+ @ui.search_term.set_focus
210
+ end
211
+
212
+ private
213
+
214
+ def start_search
215
+ text = @ui.search_term.text
216
+ unless text.empty?
217
+ Ruber[:ruberri].search text
218
+ end
219
+ end
220
+ slots :start_search
221
+
222
+ end
223
+
224
+ end
225
+
226
+ end
@@ -0,0 +1,111 @@
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
+ require 'yaml'
22
+ require 'rdoc/ri/driver'
23
+
24
+ module Ruber
25
+
26
+ module RI
27
+
28
+ class Search
29
+
30
+ def search text
31
+ drv = RDoc::RI::Driver.new
32
+ classes = find_classes drv, text
33
+ methods = find_methods drv, text
34
+ if classes then content = prepare_class_list classes
35
+ elsif methods then content = prepare_method_list methods
36
+ elsif !(hash = drv.classes).empty?
37
+ regexp = /::#{Regexp.quote text}$/
38
+ list = []
39
+ hash.each_key do |cls|
40
+ list << find_classes(drv, cls) if cls =~ regexp
41
+ end
42
+ content = prepare_class_list list
43
+ else content = {}
44
+ end
45
+ content
46
+ end
47
+
48
+ def prepare_class_list classes
49
+ found = {:type => :class}
50
+ list = []
51
+ classes.each do |cls, store|
52
+ data = {
53
+ :store => store.path,
54
+ :friendly_store => store.friendly_path,
55
+ :store_type => store.type,
56
+ :name => cls.full_name
57
+ }
58
+ list << data
59
+ end
60
+ found[:list] = list
61
+ found
62
+ end
63
+
64
+ def prepare_method_list methods
65
+ found = {:type => :method}
66
+ list = []
67
+ methods.each do |mth, store|
68
+ data = {
69
+ :store => store.path,
70
+ :friendly_store => store.friendly_path,
71
+ :store_type => store.type,
72
+ :name => mth.full_name
73
+ }
74
+ list << data
75
+ end
76
+ found[:list] = list
77
+ found
78
+ end
79
+
80
+ def find_classes drv, name
81
+ begin cls = drv.expand_class(Regexp.quote(name))
82
+ rescue RDoc::RI::Driver::NotFoundError
83
+ return
84
+ end
85
+ stores = drv.classes[cls]
86
+ return unless stores
87
+ classes = []
88
+ stores.each do |s|
89
+ classes << [s.load_class(cls), s]
90
+ end
91
+ classes
92
+ end
93
+
94
+ def find_methods drv, name
95
+ found = drv.load_methods_matching name
96
+ return nil if found.empty?
97
+ filtered = drv.filter_methods found, name
98
+ methods = []
99
+ filtered.each do |store, mthds|
100
+ mthds.each{|m| methods << [m, store]}
101
+ end
102
+ methods.empty? ? nil : methods
103
+ end
104
+
105
+ end
106
+
107
+ end
108
+
109
+ end
110
+
111
+ puts YAML.dump(Ruber::RI::Search.new.search(ARGV[0] || ''))
@@ -0,0 +1,73 @@
1
+ =begin
2
+ ** Form generated from reading ui file 'tool_widget.ui'
3
+ **
4
+ ** Created: gio ago 11 14:56:44 2011
5
+ ** by: Qt User Interface Compiler version 4.7.3
6
+ **
7
+ ** WARNING! All changes made in this file will be lost when recompiling ui file!
8
+ =end
9
+
10
+ class Ui_RIToolWidget
11
+ attr_reader :gridLayout
12
+ attr_reader :label
13
+ attr_reader :search_term
14
+ attr_reader :search
15
+ attr_reader :content
16
+
17
+ def setupUi(rIToolWidget)
18
+ if rIToolWidget.objectName.nil?
19
+ rIToolWidget.objectName = "rIToolWidget"
20
+ end
21
+ rIToolWidget.resize(676, 300)
22
+ @gridLayout = Qt::GridLayout.new(rIToolWidget)
23
+ @gridLayout.objectName = "gridLayout"
24
+ @label = Qt::Label.new(rIToolWidget)
25
+ @label.objectName = "label"
26
+
27
+ @gridLayout.addWidget(@label, 0, 0, 1, 1)
28
+
29
+ @search_term = KDE::LineEdit.new(rIToolWidget)
30
+ @search_term.objectName = "search_term"
31
+
32
+ @gridLayout.addWidget(@search_term, 0, 1, 1, 1)
33
+
34
+ @search = Qt::PushButton.new(rIToolWidget)
35
+ @search.objectName = "search"
36
+
37
+ @gridLayout.addWidget(@search, 0, 2, 1, 1)
38
+
39
+ @content = Qt::TextBrowser.new(rIToolWidget)
40
+ @content.objectName = "content"
41
+
42
+ @gridLayout.addWidget(@content, 1, 0, 1, 3)
43
+
44
+ @label.buddy = @search_term
45
+ Qt::Widget.setTabOrder(@search_term, @search)
46
+ Qt::Widget.setTabOrder(@search, @content)
47
+
48
+ retranslateUi(rIToolWidget)
49
+
50
+ Qt::MetaObject.connectSlotsByName(rIToolWidget)
51
+ end # setupUi
52
+
53
+ def setup_ui(rIToolWidget)
54
+ setupUi(rIToolWidget)
55
+ end
56
+
57
+ def retranslateUi(rIToolWidget)
58
+ rIToolWidget.windowTitle = Qt::Application.translate("RIToolWidget", "Form", nil, Qt::Application::UnicodeUTF8)
59
+ @label.text = Qt::Application.translate("RIToolWidget", "Find", nil, Qt::Application::UnicodeUTF8)
60
+ @search.text = Qt::Application.translate("RIToolWidget", "&Search", nil, Qt::Application::UnicodeUTF8)
61
+ end # retranslateUi
62
+
63
+ def retranslate_ui(rIToolWidget)
64
+ retranslateUi(rIToolWidget)
65
+ end
66
+
67
+ end
68
+
69
+ module Ui
70
+ class RIToolWidget < Ui_RIToolWidget
71
+ end
72
+ end # module Ui
73
+