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,401 @@
|
|
|
1
|
+
require 'spec/common'
|
|
2
|
+
|
|
3
|
+
require 'ruber/plugin_specification'
|
|
4
|
+
require 'ruber/plugin'
|
|
5
|
+
require 'ruber/plugin_specification_reader'
|
|
6
|
+
|
|
7
|
+
describe 'Ruber::PluginSpecification.new' do
|
|
8
|
+
|
|
9
|
+
it 'should accept a file name and return a PluginSpecification which only contains the pdf intro' do
|
|
10
|
+
reader = flexmock('reader')
|
|
11
|
+
reader.should_ignore_missing
|
|
12
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test}")
|
|
13
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
14
|
+
res = Ruber::PluginSpecification.new 'file'
|
|
15
|
+
res.should be_instance_of(Ruber::PluginSpecification)
|
|
16
|
+
res.should be_intro_only
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should accept a hash and return PluginSpecification which only contains the pdf intro' do
|
|
20
|
+
reader = flexmock('reader')
|
|
21
|
+
reader.should_ignore_missing
|
|
22
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
23
|
+
res = Ruber::PluginSpecification.new( {} )
|
|
24
|
+
res.should be_instance_of(Ruber::PluginSpecification)
|
|
25
|
+
res.should be_intro_only
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
it 'should set the "directory" attribute to second argument, if isn\'t nil' do
|
|
29
|
+
reader = flexmock('reader')
|
|
30
|
+
reader.should_ignore_missing
|
|
31
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test}")
|
|
32
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
33
|
+
res = Ruber::PluginSpecification.new 'file', '/home/stefano/xyz/abc'
|
|
34
|
+
res.directory.should == '/home/stefano/xyz/abc'
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should set the "directory" attribute to the directory of the file passed as argument, if the first argument is a string and the second is nil' do
|
|
38
|
+
reader = flexmock('reader')
|
|
39
|
+
reader.should_ignore_missing
|
|
40
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test}")
|
|
41
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
42
|
+
res = Ruber::PluginSpecification.new '/home/stefano/xyz/abc/plugin.yaml'
|
|
43
|
+
res.directory.should == '/home/stefano/xyz/abc'
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'should set the "directory" attribute to the current directory if the first argument is a hash and the second is nil' do
|
|
47
|
+
reader = flexmock('reader')
|
|
48
|
+
reader.should_ignore_missing
|
|
49
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
50
|
+
res = Ruber::PluginSpecification.new( {} )
|
|
51
|
+
res.directory.should == File.expand_path( Dir.pwd )
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it 'should return a PluginSpecification containing the data in the file' do
|
|
55
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test, about: {:description: desc}}")
|
|
56
|
+
res = Ruber::PluginSpecification.new 'file'
|
|
57
|
+
res.name.should == :test
|
|
58
|
+
res.about.description.should == 'desc'
|
|
59
|
+
res.tool_widgets.should be_nil
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it 'should raise PSFError if the :name entry is missing from the pdf' do
|
|
63
|
+
flexmock(File).should_receive(:exist?).and_return true
|
|
64
|
+
flexmock(File).should_receive(:read).and_return("description: desc}")
|
|
65
|
+
lambda{Ruber::PluginSpecification.new 'file'}.should raise_error(Ruber::PluginSpecification::PSFError, "The required 'name' entry is missing from the PDF")
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'should raise SystemCallError if the file doesn\'t exist' do
|
|
69
|
+
lambda{Ruber::PluginSpecification.new 'file'}.should raise_error(SystemCallError)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it 'should raise ArgumentError if the file isn\'t a valid YAML file' do
|
|
73
|
+
flexmock(File).should_receive(:exist?).and_return true
|
|
74
|
+
flexmock(File).should_receive(:read).and_return("{:name: test, :description: desc")
|
|
75
|
+
lambda{Ruber::PluginSpecification.new 'file'}.should raise_error(ArgumentError)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it 'should raise Ruber::PluginSpecification::PdfError if the file isn\'t a valid PDF' do
|
|
79
|
+
flexmock(File).should_receive(:exist?).and_return true
|
|
80
|
+
flexmock(File).should_receive(:read).and_return("{:description: desc}")
|
|
81
|
+
lambda{Ruber::PluginSpecification.new 'file'}.should raise_error(Ruber::PluginSpecification::PSFError)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe 'Ruber::PluginSpecification.intro' do
|
|
87
|
+
|
|
88
|
+
it 'should accept a file name and return a PluginSpecification which only contains the pdf intro' do
|
|
89
|
+
reader = flexmock('reader')
|
|
90
|
+
reader.should_ignore_missing
|
|
91
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test}")
|
|
92
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
93
|
+
res = Ruber::PluginSpecification.intro 'file'
|
|
94
|
+
res.should be_instance_of(Ruber::PluginSpecification)
|
|
95
|
+
res.should be_intro_only
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'should accept a hash a PluginSpecification which only contains the pdf intro' do
|
|
99
|
+
reader = flexmock('reader')
|
|
100
|
+
reader.should_ignore_missing
|
|
101
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
102
|
+
res = Ruber::PluginSpecification.intro( {} )
|
|
103
|
+
res.should be_instance_of(Ruber::PluginSpecification)
|
|
104
|
+
res.should be_intro_only
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
it 'should return a PluginSpecification containing the data in the file' do
|
|
108
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test, about: {:description: desc}}")
|
|
109
|
+
res = Ruber::PluginSpecification.intro 'file'
|
|
110
|
+
res.name.should == :test
|
|
111
|
+
res.about.description.should == 'desc'
|
|
112
|
+
res.tool_widgets.should be_nil
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it 'should set the "directory" attribute to second argument, if isn\'t nil' do
|
|
116
|
+
reader = flexmock('reader')
|
|
117
|
+
reader.should_ignore_missing
|
|
118
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test}")
|
|
119
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
120
|
+
res = Ruber::PluginSpecification.intro 'file', '/home/stefano/xyz/abc'
|
|
121
|
+
res.directory.should == '/home/stefano/xyz/abc'
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it 'should set the "directory" attribute to the directory of the file passed as argument, if the first argument is a string and the second is nil' do
|
|
125
|
+
reader = flexmock('reader')
|
|
126
|
+
reader.should_ignore_missing
|
|
127
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test}")
|
|
128
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
129
|
+
res = Ruber::PluginSpecification.intro '/home/stefano/xyz/abc/plugin.yaml'
|
|
130
|
+
res.directory.should == '/home/stefano/xyz/abc'
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it 'should set the "directory" attribute to the current directory if the first argument is a hash and the second is nil' do
|
|
134
|
+
reader = flexmock('reader')
|
|
135
|
+
reader.should_ignore_missing
|
|
136
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
137
|
+
res = Ruber::PluginSpecification.intro( {} )
|
|
138
|
+
res.directory.should == File.expand_path( Dir.pwd )
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it 'should raise SystemCallError if the file doesn\'t exist' do
|
|
142
|
+
lambda{Ruber::PluginSpecification.intro 'file'}.should raise_error(SystemCallError)
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
it 'should raise ArgumentError if the file isn\'t a valid YAML file' do
|
|
146
|
+
flexmock(File).should_receive(:exist?).and_return true
|
|
147
|
+
flexmock(File).should_receive(:read).and_return("{:name: test, :description: desc")
|
|
148
|
+
lambda{Ruber::PluginSpecification.intro 'file'}.should raise_error(ArgumentError)
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it 'should raise Ruber::PluginSpecification::PdfError if the file isn\'t a valid PDF' do
|
|
152
|
+
flexmock(File).should_receive(:exist?).and_return true
|
|
153
|
+
flexmock(File).should_receive(:read).and_return("{:description: desc}")
|
|
154
|
+
lambda{Ruber::PluginSpecification.intro 'file'}.should raise_error(Ruber::PluginSpecification::PSFError)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
describe 'Ruber::PluginSpecification.full' do
|
|
160
|
+
|
|
161
|
+
it 'should accept a file name and return a PluginSpecification which contains all the contents of the pdf' do
|
|
162
|
+
reader = flexmock('reader')
|
|
163
|
+
reader.should_ignore_missing
|
|
164
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test}")
|
|
165
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
166
|
+
res = Ruber::PluginSpecification.full 'file'
|
|
167
|
+
res.should be_instance_of(Ruber::PluginSpecification)
|
|
168
|
+
res.should_not be_intro_only
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it 'should accept a hash a PluginSpecification which only contains the pdf intro' do
|
|
172
|
+
reader = flexmock('reader')
|
|
173
|
+
reader.should_ignore_missing
|
|
174
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
175
|
+
res = Ruber::PluginSpecification.full( {} )
|
|
176
|
+
res.should be_instance_of(Ruber::PluginSpecification)
|
|
177
|
+
res.should_not be_intro_only
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
it 'should return a PluginSpecification containing all the data in the file' do
|
|
181
|
+
Object.const_set(:C, Class.new)
|
|
182
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test, :description: desc, class: C, project_options: {g1: {o1: {default: 5}}}}")
|
|
183
|
+
res = Ruber::PluginSpecification.full 'file'
|
|
184
|
+
res.name.should == :test
|
|
185
|
+
res.project_options[[:g1, :o1]].should have_entries(:name => :o1, :default => 5)
|
|
186
|
+
Object.send(:remove_const, :C)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it 'should set the "directory" attribute to second argument, if isn\'t nil' do
|
|
190
|
+
reader = flexmock('reader')
|
|
191
|
+
reader.should_ignore_missing
|
|
192
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test}")
|
|
193
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
194
|
+
res = Ruber::PluginSpecification.full 'file', '/home/stefano/xyz/abc'
|
|
195
|
+
res.directory.should == '/home/stefano/xyz/abc'
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
it 'should set the "directory" attribute to the directory of the file passed as argument, if the first argument is a string and the second is nil' do
|
|
199
|
+
reader = flexmock('reader')
|
|
200
|
+
reader.should_ignore_missing
|
|
201
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test}")
|
|
202
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
203
|
+
res = Ruber::PluginSpecification.full '/home/stefano/xyz/abc/plugin.yaml'
|
|
204
|
+
res.directory.should == '/home/stefano/xyz/abc'
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
it 'should set the "directory" attribute to the current directory if the first argument is a hash and the second is nil' do
|
|
208
|
+
reader = flexmock('reader')
|
|
209
|
+
reader.should_ignore_missing
|
|
210
|
+
flexmock(Ruber::PluginSpecificationReader).should_receive(:new).and_return(reader)
|
|
211
|
+
res = Ruber::PluginSpecification.full( {} )
|
|
212
|
+
res.directory.should == File.expand_path( Dir.pwd )
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
it 'should raise SystemCallError if the file doesn\'t exist' do
|
|
216
|
+
lambda{Ruber::PluginSpecification.full 'file'}.should raise_error(SystemCallError)
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
it 'should raise ArgumentError if the file isn\'t a valid YAML file' do
|
|
220
|
+
flexmock(File).should_receive(:exist?).and_return true
|
|
221
|
+
flexmock(File).should_receive(:read).and_return("{:name: test, :description: desc")
|
|
222
|
+
lambda{Ruber::PluginSpecification.full 'file'}.should raise_error(ArgumentError)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
it 'should raise Ruber::PluginSpecification::PdfError if the file isn\'t a valid PDF' do
|
|
226
|
+
flexmock(File).should_receive(:exist?).and_return true
|
|
227
|
+
flexmock(File).should_receive(:read).and_return("{:description: desc}")
|
|
228
|
+
lambda{Ruber::PluginSpecification.full 'file'}.should raise_error(Ruber::PluginSpecification::PSFError)
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
describe 'Ruber::PluginSpecification#complete_processing' do
|
|
234
|
+
|
|
235
|
+
before :all do
|
|
236
|
+
Object.const_set(:C, Class.new)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
after :all do
|
|
240
|
+
Object.send(:remove_const, :C)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
it 'should make the object not contain only the pdf introduction' do
|
|
244
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test, :description: desc, class: C}")
|
|
245
|
+
info = Ruber::PluginSpecification.new 'file'
|
|
246
|
+
info.complete_processing
|
|
247
|
+
info.should_not be_intro_only
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
it 'should contain all the information in the pdf' do
|
|
251
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test, :description: desc, :project_options: {:g1: {o1: {default: 1}}}, class: 'C'}")
|
|
252
|
+
info = Ruber::PluginSpecification.new 'file'
|
|
253
|
+
info.complete_processing
|
|
254
|
+
info.project_options[[:g1, :o1]].should have_entries(:name => :o1, :default => 1, :group => :g1)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
it 'should not access the file' do
|
|
258
|
+
flexmock(File).should_receive(:read).and_return("{:name: :test, :description: desc, class: C}").once
|
|
259
|
+
info = Ruber::PluginSpecification.new 'file'
|
|
260
|
+
info.complete_processing
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
describe 'Ruber::PluginSpecification#has_config_options?' do
|
|
266
|
+
|
|
267
|
+
before do
|
|
268
|
+
flexmock(File).should_receive(:read).and_return('{name: x}')
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
it 'should raise RuntimeError with message "Ruber::PluginSpecification#has_config_options? can only be called on a full Ruber::PluginSpecification"' do
|
|
272
|
+
lambda{Ruber::PluginSpecification.intro('file').has_config_options?}.should raise_error(RuntimeError,"Ruber::PluginSpecification#has_config_options? can only be called on a full Ruber::PluginSpecification")
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
it 'should return true if the config_options entry isn\'t empty' do
|
|
276
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
277
|
+
info.config_options = {:o1 => OpenStruct.new}
|
|
278
|
+
info.should have_config_options
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
it 'should return false if the config_options entry is empty' do
|
|
282
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
283
|
+
info.should_not have_config_options
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
describe 'Ruber::PluginSpecification#has_config_widgets?' do
|
|
289
|
+
|
|
290
|
+
before do
|
|
291
|
+
flexmock(File).should_receive(:read).and_return('{name: x}')
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
it 'should raise RuntimeError with message "Ruber::PluginSpecification#has_config_widgets? can only be called on a full Ruber::PluginSpecification"' do
|
|
295
|
+
lambda{Ruber::PluginSpecification.intro('file').has_config_widgets?}.should raise_error(RuntimeError,"Ruber::PluginSpecification#has_config_widgets? can only be called on a full Ruber::PluginSpecification")
|
|
296
|
+
end
|
|
297
|
+
|
|
298
|
+
it 'should return true if the config_widgets entry isn\'t empty' do
|
|
299
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
300
|
+
info.config_widgets = [OpenStruct.new]
|
|
301
|
+
info.should have_config_widgets
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
it 'should return false if the config_widgets entry is empty' do
|
|
305
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
306
|
+
info.should_not have_config_widgets
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
describe 'Ruber::PluginSpecification#has_tool_widgets?' do
|
|
312
|
+
|
|
313
|
+
before do
|
|
314
|
+
flexmock(File).should_receive(:read).and_return('{name: x}')
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
it 'should raise RuntimeError with message "Ruber::PluginSpecification#has_tool_widgets? can only be called on a full Ruber::PluginSpecification"' do
|
|
318
|
+
lambda{Ruber::PluginSpecification.intro('file').has_tool_widgets?}.should raise_error(RuntimeError,"Ruber::PluginSpecification#has_tool_widgets? can only be called on a full Ruber::PluginSpecification")
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
it 'should return true if the tool_widgets entry isn\'t empty' do
|
|
322
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
323
|
+
info.tool_widgets = [OpenStruct.new]
|
|
324
|
+
info.should have_tool_widgets
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
it 'should return false if the tool_widgets entry is empty' do
|
|
328
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
329
|
+
info.should_not have_tool_widgets
|
|
330
|
+
end
|
|
331
|
+
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
describe 'Ruber::PluginSpecification#has_project_options?' do
|
|
335
|
+
|
|
336
|
+
before do
|
|
337
|
+
flexmock(File).should_receive(:read).and_return('{name: x}')
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
it 'should raise RuntimeError with message "Ruber::PluginSpecification#has_project_options? can only be called on a full Ruber::PluginSpecification"' do
|
|
341
|
+
lambda{Ruber::PluginSpecification.intro('file').has_project_options?}.should raise_error(RuntimeError,"Ruber::PluginSpecification#has_project_options? can only be called on a full Ruber::PluginSpecification")
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
it 'should return true if the project_options entry isn\'t empty' do
|
|
345
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
346
|
+
info.project_options = {:o1 => OpenStruct.new({:name => :o1})}
|
|
347
|
+
info.should have_project_options
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
it 'should return false if the project_options entry is empty' do
|
|
351
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
352
|
+
info.should_not have_project_options
|
|
353
|
+
end
|
|
354
|
+
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
describe 'Ruber::PluginSpecification#has_project_widgets?' do
|
|
358
|
+
|
|
359
|
+
before do
|
|
360
|
+
flexmock(File).should_receive(:read).and_return('{name: x}')
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
it 'should raise RuntimeError with message "Ruber::PluginSpecification#has_project_widgets? can only be called on a full Ruber::PluginSpecification"' do
|
|
364
|
+
lambda{Ruber::PluginSpecification.intro('file').has_project_widgets?}.should raise_error(RuntimeError,"Ruber::PluginSpecification#has_project_widgets? can only be called on a full Ruber::PluginSpecification")
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
it 'should return true if the project_widgets entry isn\'t empty' do
|
|
368
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
369
|
+
info.project_widgets = [OpenStruct.new({:caption => :o1})]
|
|
370
|
+
info.should have_project_widgets
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
it 'should return false if the project_widgets entry is empty' do
|
|
374
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
375
|
+
info.should_not have_project_widgets
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
describe 'Ruber::PluginSpecification#has_extensions?' do
|
|
381
|
+
|
|
382
|
+
before do
|
|
383
|
+
flexmock(File).should_receive(:read).and_return('{name: x}')
|
|
384
|
+
end
|
|
385
|
+
|
|
386
|
+
it 'should raise RuntimeError with message "Ruber::PluginSpecification#has_extensions? can only be called on a full Ruber::PluginSpecification"' do
|
|
387
|
+
lambda{Ruber::PluginSpecification.intro('file').has_extensions?}.should raise_error(RuntimeError,"Ruber::PluginSpecification#has_extensions? can only be called on a full Ruber::PluginSpecification")
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
it 'should return true if the project_extensions entry isn\'t empty' do
|
|
391
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
392
|
+
info.extensions = {:e1 => OpenStruct.new({:name => :e1})}
|
|
393
|
+
info.should have_extensions
|
|
394
|
+
end
|
|
395
|
+
|
|
396
|
+
it 'should return false if the project_extensions entry is empty' do
|
|
397
|
+
info = Ruber::PluginSpecification.full 'file'
|
|
398
|
+
info.should_not have_extensions
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
end
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
require 'spec/common'
|
|
2
|
+
|
|
3
|
+
require 'ruber/project_backend'
|
|
4
|
+
|
|
5
|
+
describe Ruber::ProjectBackend do
|
|
6
|
+
|
|
7
|
+
before do
|
|
8
|
+
@dir = make_dir_tree []
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
after do
|
|
12
|
+
FileUtils.rm_rf @dir
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe 'when created' do
|
|
16
|
+
|
|
17
|
+
it 'takes the path of the main project file as argument' do
|
|
18
|
+
lambda{Ruber::ProjectBackend.new File.join(@dir, 'Test.ruprj')}.should_not raise_error
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'it creates three YamlSettingsBackend: the first corresponds to the argument, the other two correspond to files obtained by appending .ruusr and .ruses to the argument if the argument doesn\'t have extension .ruprj' do
|
|
22
|
+
base = File.join @dir, 'Test.xyz'
|
|
23
|
+
back = Ruber::ProjectBackend.new base
|
|
24
|
+
backends = back.instance_variable_get(:@backends)
|
|
25
|
+
backends[:global].file.should == base
|
|
26
|
+
backends[:user].file.should == base+'.ruusr'
|
|
27
|
+
backends[:session].file.should == base+'.ruses'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'uses the argment as it is for the global backend and removes its extension before appending .ruusr and .ruses if the argument has extension .ruprj' do
|
|
31
|
+
base = File.join @dir, 'Test.ruprj'
|
|
32
|
+
file = base + '.ruprj'
|
|
33
|
+
back = Ruber::ProjectBackend.new file
|
|
34
|
+
backends = back.instance_variable_get(:@backends)
|
|
35
|
+
backends[:global].file.should == file
|
|
36
|
+
backends[:user].file.should == base+'.ruusr'
|
|
37
|
+
backends[:session].file.should == base+'.ruses'
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it 'raises YamlSettingsBackend::InvalidSettingsFile if that exception is raised when creating the backend for the global options' do
|
|
42
|
+
base = File.join @dir, 'Test.ruprj'
|
|
43
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.and_raise Ruber::YamlSettingsBackend::InvalidSettingsFile, "The file #{base+'.ruprj'} isn\'t a valid option file"
|
|
44
|
+
lambda{Ruber::ProjectBackend.new base}.should raise_error( Ruber::YamlSettingsBackend::InvalidSettingsFile, "The file #{base+'.ruprj'} isn\'t a valid option file")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'raises YamlSettingsBackend::InvalidSettingsFile if that exception is raised when creating the backend for the user options' do
|
|
48
|
+
file = File.join @dir, 'Test.ruprj'
|
|
49
|
+
base = File.join @dir, 'Test'
|
|
50
|
+
global = Ruber::YamlSettingsBackend.new base
|
|
51
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.with(base).and_return(global)
|
|
52
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.with(base + '.ruusr').and_raise Ruber::YamlSettingsBackend::InvalidSettingsFile, "The file #{base+'.ruusr'} isn\'t a valid option file"
|
|
53
|
+
lambda{Ruber::ProjectBackend.new base}.should raise_error( Ruber::YamlSettingsBackend::InvalidSettingsFile, "The file #{base+'.ruusr'} isn\'t a valid option file")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'doesn\'t raise an exception if the backend for the session raises YamlSettingsBackend::InvalidSettingsFile' do
|
|
57
|
+
file = File.join @dir, 'Test.ruprj'
|
|
58
|
+
base = File.join @dir, 'Test'
|
|
59
|
+
global = Ruber::YamlSettingsBackend.new base
|
|
60
|
+
usr = Ruber::YamlSettingsBackend.new base + '.ruusr'
|
|
61
|
+
dummy = Ruber::YamlSettingsBackend.new ''
|
|
62
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.with(base).and_return(global)
|
|
63
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.with(base + '.ruusr').and_return(usr)
|
|
64
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.with('').and_return(dummy)
|
|
65
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.with(base + '.ruses').and_raise Ruber::YamlSettingsBackend::InvalidSettingsFile
|
|
66
|
+
lambda{Ruber::ProjectBackend.new base}.should_not raise_error
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'emits a warning and use a dummy session backend if the session backend raises YamlSettingsBackend::InvalidSettingsFile' do
|
|
70
|
+
|
|
71
|
+
class Ruber::ProjectBackend
|
|
72
|
+
alias_method :old_warn, :warn
|
|
73
|
+
def warn arg
|
|
74
|
+
@warning = arg
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
file= File.join @dir, 'Test.ruprj'
|
|
79
|
+
base = File.join @dir, 'Test'
|
|
80
|
+
global = Ruber::YamlSettingsBackend.new file
|
|
81
|
+
usr = Ruber::YamlSettingsBackend.new base + '.ruusr'
|
|
82
|
+
dummy = Ruber::YamlSettingsBackend.new ''
|
|
83
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.with(file).and_return(global)
|
|
84
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.with(base + '.ruusr').and_return(usr)
|
|
85
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.with(base + '.ruses').and_raise Ruber::YamlSettingsBackend::InvalidSettingsFile
|
|
86
|
+
flexmock(Ruber::YamlSettingsBackend).should_receive(:new).once.with('').and_return(dummy)
|
|
87
|
+
back = Ruber::ProjectBackend.new file
|
|
88
|
+
back.instance_variable_get(:@warning).should == "The file #{base + '.ruses'} already exists but it's not a valid session file. Session options won't be saved"
|
|
89
|
+
back.instance_variable_get(:@backends)[:session].file.should == ''
|
|
90
|
+
|
|
91
|
+
class Ruber::ProjectBackend
|
|
92
|
+
alias_method :warn, :old_warn
|
|
93
|
+
remove_method :old_warn
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe '#file' do
|
|
101
|
+
|
|
102
|
+
it 'returns the file corresponding to the global backend' do
|
|
103
|
+
base = File.join @dir, 'Test.ruprj'
|
|
104
|
+
back = Ruber::ProjectBackend.new base
|
|
105
|
+
back.file.should == back.instance_variable_get(:@backends)[:global].file
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
describe '#[]' do
|
|
111
|
+
|
|
112
|
+
before do
|
|
113
|
+
@back = Ruber::ProjectBackend.new File.join(@dir, 'Test.ruprj')
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'calls the #[] method of the global backend if the option is of type global' do
|
|
117
|
+
opt = OS.new(:name => :o, :group => :g, :default => 'x', :type => :global)
|
|
118
|
+
flexmock(@back.instance_variable_get(:@backends)[:global]).should_receive(:[]).with(opt).once.and_return 'y'
|
|
119
|
+
@back[opt].should == 'y'
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it 'calls the #[] method of the user backend if the option is of type user' do
|
|
123
|
+
opt = OS.new(:name => :o, :group => :g, :default => 'x', :type => :user)
|
|
124
|
+
flexmock(@back.instance_variable_get(:@backends)[:user]).should_receive(:[]).with(opt).once.and_return 'y'
|
|
125
|
+
@back[opt].should == 'y'
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it 'calls the #[] method of the session backend if the option is of type session' do
|
|
129
|
+
opt = OS.new(:name => :o, :group => :g, :default => 'x', :type => :session)
|
|
130
|
+
flexmock(@back.instance_variable_get(:@backends)[:session]).should_receive(:[]).with(opt).once.and_return 'y'
|
|
131
|
+
@back[opt].should == 'y'
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
describe '#write' do
|
|
137
|
+
|
|
138
|
+
before do
|
|
139
|
+
@back = Ruber::ProjectBackend.new File.join(@dir, 'Test.ruprj')
|
|
140
|
+
@global_options = {
|
|
141
|
+
OS.new(:name => :o1, :group => :G1, :default => 3, :type => :global) => -1,
|
|
142
|
+
OS.new(:name => :o3, :group => :G1, :default => 'a', :type => :global) => 'b'
|
|
143
|
+
}
|
|
144
|
+
@user_options = {
|
|
145
|
+
OS.new(:name => :o2, :group => :G1, :default => 'xyz', :type => :user) => 'abc',
|
|
146
|
+
OS.new(:name => :o4, :group => :G1, :default => /x/, :type => :user) => /y/
|
|
147
|
+
}
|
|
148
|
+
@session_options = {
|
|
149
|
+
OS.new(:name => :o1, :group => :G2, :default => :a, :type => :session) => :b,
|
|
150
|
+
OS.new(:name => :o5, :group => :G2, :default => [1, 2], :type => :session) => [1,2,3]
|
|
151
|
+
}
|
|
152
|
+
@options = @global_options.merge(@user_options).merge(@session_options)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it 'calls the write method of all backends, passing to each a hash with the options of the corresponding type' do
|
|
156
|
+
backs = @back.instance_variable_get(:@backends)
|
|
157
|
+
flexmock(backs[:global]).should_receive(:write).once.with(@global_options)
|
|
158
|
+
flexmock(backs[:user]).should_receive(:write).once.with(@user_options)
|
|
159
|
+
flexmock(backs[:session]).should_receive(:write).once.with(@session_options)
|
|
160
|
+
@back.write @options
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
it 'doesn\'t attempt to call the write method of the session backend if it\'s dummy' do
|
|
164
|
+
dummy = Ruber::YamlSettingsBackend.new ''
|
|
165
|
+
@back.instance_variable_get(:@backends)[:session] = dummy
|
|
166
|
+
flexmock(dummy).should_receive(:write).never
|
|
167
|
+
@back.write @options
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
end
|