rugui 1.6.0 → 2.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +48 -23
- data/Rakefile +3 -10
- data/bin/rugui +4 -1
- data/lib/rugui/base_view.rb +5 -5
- data/lib/rugui/configuration.rb +1 -29
- data/lib/rugui/entity_registration_support.rb +17 -2
- data/lib/rugui/framework_adapters/GTK.rb +15 -32
- data/lib/rugui/framework_adapters/Qt4.rb +22 -3
- data/lib/rugui/generators/rugui/rugui_generator.rb +3 -9
- data/lib/rugui/generators/rugui/templates/Gemfile.tt +20 -0
- data/lib/rugui/generators/rugui/templates/Rakefile +0 -4
- data/lib/rugui/generators/rugui/templates/app/main.rb +1 -1
- data/lib/rugui/generators/rugui/templates/config/boot.rb +5 -78
- data/lib/rugui/generators/rugui/templates/config/environment.rb.tt +7 -7
- data/lib/rugui/generators/rugui/templates/framework_specific/gtk/app/resources/xml/main_view.xml +43 -0
- data/lib/rugui/generators/rugui/templates/spec/spec_helper.rb +0 -2
- data/lib/rugui/initializer.rb +3 -60
- data/lib/rugui/observable_property_support.rb +5 -1
- data/lib/rugui/property_changed_support.rb +1 -1
- data/lib/rugui/signal_support.rb +2 -2
- data/lib/rugui/tasks/rugui.rb +1 -1
- data/lib/rugui/tasks/runner_application.rake +1 -1
- data/lib/rugui/tasks/spec_application.rake +5 -44
- data/lib/rugui/tasks/spec_framework.rake +3 -25
- data/lib/rugui/version.rb +1 -7
- data/lib/rugui.rb +0 -3
- data/spec/framework/base_controller_spec.rb +7 -14
- data/spec/framework/base_model_spec.rb +1 -3
- data/spec/framework/base_view_helper_spec.rb +1 -3
- data/spec/framework/base_view_spec.rb +2 -5
- data/spec/framework/log_support_spec.rb +2 -2
- data/spec/framework/observable_property_proxy_spec.rb +13 -14
- data/spec/framework/observable_property_support_spec.rb +8 -10
- data/spec/framework/property_observer_spec.rb +20 -22
- data/spec/helpers/controllers.rb +3 -3
- data/spec/helpers/helper_manager.rb +9 -0
- data/spec/helpers/observables.rb +40 -52
- data/spec/helpers/views.rb +15 -15
- data/spec/resource_files/my_other_view.xml +53 -0
- data/spec/resource_files/my_view.xml +53 -0
- data/spec/spec_helper.rb +9 -3
- metadata +98 -84
- data/lib/rugui/gem_builder.rb +0 -21
- data/lib/rugui/gem_dependency.rb +0 -282
- data/lib/rugui/generators/rugui/templates/framework_specific/gtk/app/resources/glade/main_view.glade +0 -33
- data/lib/rugui/generators/rugui/templates/spec/rcov.opts +0 -1
- data/lib/rugui/generators/rugui/templates/spec/spec.opts +0 -4
- data/lib/rugui/generators/rugui/templates/test/test_helper.rb +0 -12
- data/lib/rugui/plugin/loader.rb +0 -77
- data/lib/rugui/tasks/gems_application.rake +0 -71
- data/lib/rugui/tasks/test_application.rake +0 -77
- data/lib/rugui/vendor_gem_source_index.rb +0 -140
- data/spec/rcov.opts +0 -1
- data/spec/spec.opts +0 -5
data/spec/helpers/observables.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Defines some observables and custom types used in specs.
|
2
2
|
|
3
3
|
class FakeObservable < RuGUI::BaseObject
|
4
|
-
attr_accessor :property_changed_message
|
4
|
+
attr_accessor :property_changed_message
|
5
5
|
|
6
6
|
def framework_adapter
|
7
7
|
framework_adapter_for('BaseController')
|
@@ -14,24 +14,16 @@ end
|
|
14
14
|
|
15
15
|
class AnotherFakeObserver < RuGUI::BaseObject
|
16
16
|
attr_accessor :property_updated_message
|
17
|
-
|
18
|
-
def value_to_s(value)
|
19
|
-
if value.is_a?(Hash)
|
20
|
-
value.keys.sort
|
21
|
-
else
|
22
|
-
value
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
17
|
+
|
26
18
|
def property_updated(observable, property, new_value, old_value)
|
27
|
-
|
28
|
-
@property_updated_message = "#{observable} property #{property} changed from #{
|
19
|
+
|
20
|
+
@property_updated_message = "#{observable} property #{property} changed from #{old_value.inspect} to #{new_value.inspect}"
|
29
21
|
end
|
30
22
|
end
|
31
23
|
|
32
24
|
class AnotherFakeObservable < RuGUI::BaseObject
|
33
25
|
include RuGUI::ObservablePropertySupport
|
34
|
-
|
26
|
+
|
35
27
|
observable_property :my_observable_property
|
36
28
|
observable_property :my_array_observable_property, :initial_value => []
|
37
29
|
observable_property :my_hash_observable_property, :initial_value => {}
|
@@ -39,19 +31,23 @@ class AnotherFakeObservable < RuGUI::BaseObject
|
|
39
31
|
observable_property :resetable_observable_property, :reset_value => "some_reset_value"
|
40
32
|
observable_property :initialized_and_resetable_observable_property, :initial_value => "some_initial_value", :reset_value => "some_reset_value"
|
41
33
|
observable_property :core_observable_property, :core => true, :initial_value => "some_initial_value"
|
42
|
-
|
34
|
+
|
43
35
|
def to_s
|
44
36
|
self.class.name
|
45
37
|
end
|
38
|
+
|
39
|
+
def inspect
|
40
|
+
to_s
|
41
|
+
end
|
46
42
|
end
|
47
43
|
|
48
44
|
class SomeOtherFakeObservable < RuGUI::BaseObject
|
49
45
|
include RuGUI::ObservablePropertySupport
|
50
|
-
|
46
|
+
|
51
47
|
observable_property :another_observable_property, :initial_value => "some_other_initial_value"
|
52
48
|
observable_property :first_core_observable_property, :core => true, :initial_value => "first"
|
53
49
|
observable_property :second_core_observable_property, :core => true, :initial_value => "second"
|
54
|
-
|
50
|
+
|
55
51
|
def to_s
|
56
52
|
self.class.name
|
57
53
|
end
|
@@ -59,9 +55,9 @@ end
|
|
59
55
|
|
60
56
|
class CustomTypeFakeObservable < RuGUI::BaseObject
|
61
57
|
include RuGUI::ObservablePropertySupport
|
62
|
-
|
58
|
+
|
63
59
|
observable_property :custom_type_observable_property, :core => true, :initial_value => AnotherFakeObservable.new
|
64
|
-
|
60
|
+
|
65
61
|
def to_s
|
66
62
|
self.class.name
|
67
63
|
end
|
@@ -69,10 +65,10 @@ end
|
|
69
65
|
|
70
66
|
class ResetPreventedFakeObservable < RuGUI::BaseObject
|
71
67
|
include RuGUI::ObservablePropertySupport
|
72
|
-
|
68
|
+
|
73
69
|
observable_property :reset_prevented_observable_property, :prevent_reset => true
|
74
70
|
observable_property :reset_prevented_with_reset_value_observable_property, :reset_value => 'foo', :prevent_reset => true
|
75
|
-
|
71
|
+
|
76
72
|
def to_s
|
77
73
|
self.class.name
|
78
74
|
end
|
@@ -80,10 +76,10 @@ end
|
|
80
76
|
|
81
77
|
class BooleanPropertiesFakeObservable < RuGUI::BaseObject
|
82
78
|
include RuGUI::ObservablePropertySupport
|
83
|
-
|
79
|
+
|
84
80
|
observable_property :boolean_observable_property, :boolean => true
|
85
81
|
observable_property :non_boolean_observable_property
|
86
|
-
|
82
|
+
|
87
83
|
def to_s
|
88
84
|
self.class.name
|
89
85
|
end
|
@@ -91,10 +87,10 @@ end
|
|
91
87
|
|
92
88
|
class ParentFakeObservable < RuGUI::BaseObject
|
93
89
|
include RuGUI::ObservablePropertySupport
|
94
|
-
|
90
|
+
|
95
91
|
observable_property :my_own_observable_property
|
96
92
|
observable_property :child_observable_property
|
97
|
-
|
93
|
+
|
98
94
|
def to_s
|
99
95
|
self.class.name
|
100
96
|
end
|
@@ -102,9 +98,9 @@ end
|
|
102
98
|
|
103
99
|
class ChildFakeObservable < RuGUI::BaseObject
|
104
100
|
include RuGUI::ObservablePropertySupport
|
105
|
-
|
101
|
+
|
106
102
|
observable_property :my_observable_property, :core => true
|
107
|
-
|
103
|
+
|
108
104
|
def to_s
|
109
105
|
self.class.name
|
110
106
|
end
|
@@ -112,9 +108,9 @@ end
|
|
112
108
|
|
113
109
|
class FakeObservableForPropertyObserverTest < RuGUI::BaseObject
|
114
110
|
include RuGUI::ObservablePropertySupport
|
115
|
-
|
111
|
+
|
116
112
|
observable_property :my_observable_property
|
117
|
-
|
113
|
+
|
118
114
|
def to_s
|
119
115
|
self.class.name
|
120
116
|
end
|
@@ -122,9 +118,9 @@ end
|
|
122
118
|
|
123
119
|
class FakeNamedObservableTest < RuGUI::BaseObject
|
124
120
|
include RuGUI::ObservablePropertySupport
|
125
|
-
|
121
|
+
|
126
122
|
observable_property :my_observable_property
|
127
|
-
|
123
|
+
|
128
124
|
def to_s
|
129
125
|
self.class.name
|
130
126
|
end
|
@@ -132,7 +128,7 @@ end
|
|
132
128
|
|
133
129
|
class FakeObserverForPropertyObserverTest < RuGUI::BaseObject
|
134
130
|
include RuGUI::PropertyObserver
|
135
|
-
|
131
|
+
|
136
132
|
attr_accessor :property_updated_message
|
137
133
|
attr_accessor :class_specific_method_called_message
|
138
134
|
attr_accessor :instance_specific_method_called_message
|
@@ -140,19 +136,19 @@ class FakeObserverForPropertyObserverTest < RuGUI::BaseObject
|
|
140
136
|
attr_accessor :observable
|
141
137
|
attr_accessor :named_observable
|
142
138
|
attr_accessor :fake_named_observable_test
|
143
|
-
|
139
|
+
|
144
140
|
attr_accessor :property_changed_counter
|
145
|
-
|
141
|
+
|
146
142
|
def initialize
|
147
143
|
@observable = FakeObservableForPropertyObserverTest.new
|
148
144
|
@observable.register_observer(self)
|
149
|
-
|
145
|
+
|
150
146
|
@named_observable = FakeObservableForPropertyObserverTest.new
|
151
147
|
@named_observable.register_observer(self, 'named_observable')
|
152
|
-
|
148
|
+
|
153
149
|
@fake_named_observable_test = FakeNamedObservableTest.new
|
154
150
|
@fake_named_observable_test.register_observer(self, 'fake_named_observable_test')
|
155
|
-
|
151
|
+
|
156
152
|
@property_changed_counter = 0
|
157
153
|
end
|
158
154
|
|
@@ -160,26 +156,18 @@ class FakeObserverForPropertyObserverTest < RuGUI::BaseObject
|
|
160
156
|
framework_adapter_for('BaseController')
|
161
157
|
end
|
162
158
|
|
163
|
-
def value_to_s(value)
|
164
|
-
if value.is_a?(Hash)
|
165
|
-
value.keys.sort
|
166
|
-
else
|
167
|
-
value
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
159
|
def property_my_observable_property_changed(observable, new_value, old_value)
|
172
|
-
@property_updated_message = "#{observable} property my_observable_property changed from #{
|
160
|
+
@property_updated_message = "#{observable} property my_observable_property changed from #{old_value.inspect} to #{new_value.inspect}"
|
173
161
|
end
|
174
|
-
|
162
|
+
|
175
163
|
def property_fake_observable_for_property_observer_test_my_observable_property_changed(observable, new_value, old_value)
|
176
164
|
@class_specific_method_called_message = "Property my_observable_property changed, called from class specific method"
|
177
165
|
end
|
178
|
-
|
166
|
+
|
179
167
|
def property_named_observable_my_observable_property_changed(observable, new_value, old_value)
|
180
168
|
@instance_specific_method_called_message = "Property my_observable_property changed, called from named instance specific method"
|
181
169
|
end
|
182
|
-
|
170
|
+
|
183
171
|
def property_fake_named_observable_test_my_observable_property_changed(observable, new_value, old_value)
|
184
172
|
@property_changed_counter += 1
|
185
173
|
end
|
@@ -191,19 +179,19 @@ class CustomType < RuGUI::BaseObject
|
|
191
179
|
def custom_method
|
192
180
|
"foo"
|
193
181
|
end
|
194
|
-
|
182
|
+
|
195
183
|
def custom_method_with_parameters(first_param, second_param, *args)
|
196
184
|
"#{first_param}, #{second_param}, #{args.join(', ')}"
|
197
185
|
end
|
198
|
-
|
186
|
+
|
199
187
|
def change_custom_property(new_value)
|
200
188
|
@custom_property = new_value
|
201
189
|
end
|
202
|
-
|
190
|
+
|
203
191
|
def ==(obj)
|
204
192
|
obj.is_a?(CustomType) and obj.custom_property == self.custom_property
|
205
193
|
end
|
206
|
-
|
194
|
+
|
207
195
|
def to_s
|
208
196
|
self.custom_property
|
209
197
|
end
|
data/spec/helpers/views.rb
CHANGED
@@ -6,31 +6,31 @@ class MyView < RuGUI::BaseView
|
|
6
6
|
include InitializeHooksHelper
|
7
7
|
|
8
8
|
use_builder
|
9
|
-
builder_file File.join(File.dirname(__FILE__), '..', 'resource_files', 'my_view.
|
9
|
+
builder_file File.join(File.dirname(__FILE__), '..', 'resource_files', 'my_view.xml')
|
10
10
|
root :top_window
|
11
|
-
|
11
|
+
|
12
12
|
attr_accessor :message
|
13
|
-
|
13
|
+
|
14
14
|
def setup_view_helpers
|
15
15
|
register_helper :my_view_helper, :my_other_view_helper_instance
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def on_button_above_clicked(widget)
|
19
19
|
@message = "#{self.class} button above clicked."
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def on_button_below_clicked(widget)
|
23
23
|
@message = "#{self.class} button below clicked."
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def on_top_window_delete_event(widget, event)
|
27
27
|
@message = "#{self.class} top window deleted."
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
def property_message_changed(observable, new_value, old_value)
|
31
31
|
@message = "#{observable.class.name} property message changed from #{old_value} to #{new_value}"
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def property_my_other_view_helper_instance_message_changed(observable, new_value, old_value)
|
35
35
|
@message = "Property message of my_other_view_helper_instance changed from #{old_value} to #{new_value}"
|
36
36
|
end
|
@@ -38,11 +38,11 @@ end
|
|
38
38
|
|
39
39
|
class MyChildView < MyView
|
40
40
|
root :vertical_container
|
41
|
-
|
41
|
+
|
42
42
|
def on_button_above_clicked(widget)
|
43
43
|
@message = "#{self.class} button above clicked."
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
def on_button_below_clicked(widget)
|
47
47
|
@message = "#{self.class} button below clicked."
|
48
48
|
end
|
@@ -50,19 +50,19 @@ end
|
|
50
50
|
|
51
51
|
class MyOtherView < RuGUI::BaseView
|
52
52
|
use_builder
|
53
|
-
builder_file File.join(File.dirname(__FILE__), '..', 'resource_files', 'my_other_view.
|
53
|
+
builder_file File.join(File.dirname(__FILE__), '..', 'resource_files', 'my_other_view.xml')
|
54
54
|
root :top_window
|
55
|
-
|
55
|
+
|
56
56
|
attr_accessor :message
|
57
|
-
|
57
|
+
|
58
58
|
def on_button_right_clicked(widget)
|
59
59
|
@message = "#{self.class} button right clicked."
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
def on_button_left_clicked(widget)
|
63
63
|
@message = "#{self.class} button left clicked."
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
def on_top_window_delete_event(widget, event)
|
67
67
|
@message = "#{self.class} top window deleted."
|
68
68
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<interface>
|
3
|
+
<!-- interface-requires gtk+ 2.6 -->
|
4
|
+
<!-- interface-naming-policy toplevel-contextual -->
|
5
|
+
<object class="GtkWindow" id="top_window">
|
6
|
+
<property name="can_focus">False</property>
|
7
|
+
<signal name="delete-event" handler="on_top_window_delete_event" swapped="no"/>
|
8
|
+
<child>
|
9
|
+
<object class="GtkHBox" id="horizontal_container">
|
10
|
+
<property name="visible">True</property>
|
11
|
+
<property name="can_focus">False</property>
|
12
|
+
<child>
|
13
|
+
<object class="GtkButton" id="button_left">
|
14
|
+
<property name="visible">True</property>
|
15
|
+
<property name="can_focus">True</property>
|
16
|
+
<property name="receives_default">True</property>
|
17
|
+
<signal name="clicked" handler="on_button_left_clicked" swapped="no"/>
|
18
|
+
</object>
|
19
|
+
<packing>
|
20
|
+
<property name="expand">True</property>
|
21
|
+
<property name="fill">True</property>
|
22
|
+
<property name="position">0</property>
|
23
|
+
</packing>
|
24
|
+
</child>
|
25
|
+
<child>
|
26
|
+
<object class="GtkLabel" id="label">
|
27
|
+
<property name="visible">True</property>
|
28
|
+
<property name="can_focus">False</property>
|
29
|
+
<property name="label" translatable="yes">A label in the middle</property>
|
30
|
+
</object>
|
31
|
+
<packing>
|
32
|
+
<property name="expand">True</property>
|
33
|
+
<property name="fill">True</property>
|
34
|
+
<property name="position">1</property>
|
35
|
+
</packing>
|
36
|
+
</child>
|
37
|
+
<child>
|
38
|
+
<object class="GtkButton" id="button_right">
|
39
|
+
<property name="visible">True</property>
|
40
|
+
<property name="can_focus">True</property>
|
41
|
+
<property name="receives_default">True</property>
|
42
|
+
<signal name="clicked" handler="on_button_right_clicked" swapped="no"/>
|
43
|
+
</object>
|
44
|
+
<packing>
|
45
|
+
<property name="expand">True</property>
|
46
|
+
<property name="fill">True</property>
|
47
|
+
<property name="position">2</property>
|
48
|
+
</packing>
|
49
|
+
</child>
|
50
|
+
</object>
|
51
|
+
</child>
|
52
|
+
</object>
|
53
|
+
</interface>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<interface>
|
3
|
+
<!-- interface-requires gtk+ 2.6 -->
|
4
|
+
<!-- interface-naming-policy toplevel-contextual -->
|
5
|
+
<object class="GtkWindow" id="top_window">
|
6
|
+
<property name="can_focus">False</property>
|
7
|
+
<signal name="delete-event" handler="on_top_window_delete_event" swapped="no"/>
|
8
|
+
<child>
|
9
|
+
<object class="GtkVBox" id="vertical_container">
|
10
|
+
<property name="visible">True</property>
|
11
|
+
<property name="can_focus">False</property>
|
12
|
+
<child>
|
13
|
+
<object class="GtkButton" id="button_above">
|
14
|
+
<property name="visible">True</property>
|
15
|
+
<property name="can_focus">True</property>
|
16
|
+
<property name="receives_default">True</property>
|
17
|
+
<signal name="clicked" handler="on_button_above_clicked" swapped="no"/>
|
18
|
+
</object>
|
19
|
+
<packing>
|
20
|
+
<property name="expand">True</property>
|
21
|
+
<property name="fill">True</property>
|
22
|
+
<property name="position">0</property>
|
23
|
+
</packing>
|
24
|
+
</child>
|
25
|
+
<child>
|
26
|
+
<object class="GtkLabel" id="label">
|
27
|
+
<property name="visible">True</property>
|
28
|
+
<property name="can_focus">False</property>
|
29
|
+
<property name="label" translatable="yes">Some label in the middle</property>
|
30
|
+
</object>
|
31
|
+
<packing>
|
32
|
+
<property name="expand">True</property>
|
33
|
+
<property name="fill">True</property>
|
34
|
+
<property name="position">1</property>
|
35
|
+
</packing>
|
36
|
+
</child>
|
37
|
+
<child>
|
38
|
+
<object class="GtkButton" id="button_below">
|
39
|
+
<property name="visible">True</property>
|
40
|
+
<property name="can_focus">True</property>
|
41
|
+
<property name="receives_default">True</property>
|
42
|
+
<signal name="clicked" handler="on_button_below_clicked" swapped="no"/>
|
43
|
+
</object>
|
44
|
+
<packing>
|
45
|
+
<property name="expand">True</property>
|
46
|
+
<property name="fill">True</property>
|
47
|
+
<property name="position">2</property>
|
48
|
+
</packing>
|
49
|
+
</child>
|
50
|
+
</object>
|
51
|
+
</child>
|
52
|
+
</object>
|
53
|
+
</interface>
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'bundler/setup'
|
2
|
+
|
3
|
+
Bundler.require(:default, :test)
|
3
4
|
|
4
5
|
$:.unshift File.join(File.dirname(__FILE__),'..','lib')
|
5
6
|
|
@@ -10,6 +11,11 @@ APPLICATION_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(APPLICATION_RO
|
|
10
11
|
|
11
12
|
RuGUI::Initializer.run { |config| config.logger[:level] = :error }
|
12
13
|
|
13
|
-
|
14
|
+
Dir["spec/helpers/**/*.rb"].each { |file| load file }
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
14
17
|
# No configuration here yet.
|
18
|
+
config.before(:each) do
|
19
|
+
HelperManager.clear!
|
20
|
+
end
|
15
21
|
end
|