rugui 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/LICENSE +165 -0
  2. data/README +67 -0
  3. data/README.rdoc +67 -0
  4. data/Rakefile +56 -0
  5. data/VERSION.yml +4 -0
  6. data/bin/rugui +16 -0
  7. data/lib/rugui/base_controller.rb +194 -0
  8. data/lib/rugui/base_model.rb +22 -0
  9. data/lib/rugui/base_object.rb +73 -0
  10. data/lib/rugui/base_view.rb +302 -0
  11. data/lib/rugui/base_view_helper.rb +23 -0
  12. data/lib/rugui/configuration.rb +136 -0
  13. data/lib/rugui/framework_adapters/GTK.rb +233 -0
  14. data/lib/rugui/framework_adapters/Qt4.rb +171 -0
  15. data/lib/rugui/framework_adapters/base_framework_adapter.rb +90 -0
  16. data/lib/rugui/framework_adapters/framework_adapter_support.rb +35 -0
  17. data/lib/rugui/gem_builder.rb +21 -0
  18. data/lib/rugui/gem_dependency.rb +282 -0
  19. data/lib/rugui/initialize_hooks.rb +36 -0
  20. data/lib/rugui/initializer.rb +162 -0
  21. data/lib/rugui/log_support.rb +118 -0
  22. data/lib/rugui/observable_property_proxy.rb +73 -0
  23. data/lib/rugui/observable_property_support.rb +251 -0
  24. data/lib/rugui/plugin/loader.rb +77 -0
  25. data/lib/rugui/property_observer.rb +58 -0
  26. data/lib/rugui/signal_support.rb +57 -0
  27. data/lib/rugui/tasks/gems_application.rake +71 -0
  28. data/lib/rugui/tasks/rugui.rb +8 -0
  29. data/lib/rugui/tasks/rugui_framework.rb +4 -0
  30. data/lib/rugui/tasks/runner_application.rake +4 -0
  31. data/lib/rugui/tasks/spec_application.rake +64 -0
  32. data/lib/rugui/tasks/spec_framework.rake +27 -0
  33. data/lib/rugui/tasks/test_application.rake +77 -0
  34. data/lib/rugui/vendor_gem_source_index.rb +140 -0
  35. data/lib/rugui/version.rb +9 -0
  36. data/lib/rugui.rb +37 -0
  37. data/spec/framework/base_controller_spec.rb +48 -0
  38. data/spec/framework/base_model_spec.rb +13 -0
  39. data/spec/framework/base_view_helper_spec.rb +13 -0
  40. data/spec/framework/base_view_spec.rb +92 -0
  41. data/spec/framework/log_support_spec.rb +16 -0
  42. data/spec/framework/observable_property_proxy_spec.rb +67 -0
  43. data/spec/framework/observable_property_support_spec.rb +283 -0
  44. data/spec/framework/property_observer_spec.rb +88 -0
  45. data/spec/helpers/controllers.rb +29 -0
  46. data/spec/helpers/initialize_hooks_helper.rb +18 -0
  47. data/spec/helpers/models.rb +9 -0
  48. data/spec/helpers/observables.rb +210 -0
  49. data/spec/helpers/view_helpers.rb +9 -0
  50. data/spec/helpers/views.rb +72 -0
  51. data/spec/rcov.opts +1 -0
  52. data/spec/resource_files/my_other_view.glade +46 -0
  53. data/spec/resource_files/my_view.glade +46 -0
  54. data/spec/spec.opts +4 -0
  55. data/spec/spec_helper.rb +15 -0
  56. metadata +149 -0
@@ -0,0 +1,210 @@
1
+ # Defines some observables and custom types used in specs.
2
+
3
+ class FakeObservable < RuGUI::BaseObject
4
+ attr_accessor :property_changed_message
5
+
6
+ def framework_adapter
7
+ framework_adapter_for('BaseController')
8
+ end
9
+
10
+ def property_changed(property, new_value, old_value)
11
+ self.property_changed_message = "#{property} changed from #{old_value} to #{new_value}"
12
+ end
13
+ end
14
+
15
+ class AnotherFakeObserver < RuGUI::BaseObject
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
+
26
+ def property_updated(observable, property, new_value, old_value)
27
+
28
+ @property_updated_message = "#{observable} property #{property} changed from #{value_to_s(old_value)} to #{value_to_s(new_value)}"
29
+ end
30
+ end
31
+
32
+ class AnotherFakeObservable < RuGUI::BaseObject
33
+ include RuGUI::ObservablePropertySupport
34
+
35
+ observable_property :my_observable_property
36
+ observable_property :my_array_observable_property, :initial_value => []
37
+ observable_property :my_hash_observable_property, :initial_value => {}
38
+ observable_property :initialized_observable_property, :initial_value => "some_initial_value"
39
+ observable_property :resetable_observable_property, :reset_value => "some_reset_value"
40
+ observable_property :initialized_and_resetable_observable_property, :initial_value => "some_initial_value", :reset_value => "some_reset_value"
41
+ observable_property :core_observable_property, :core => true, :initial_value => "some_initial_value"
42
+
43
+ def to_s
44
+ self.class.name
45
+ end
46
+ end
47
+
48
+ class SomeOtherFakeObservable < RuGUI::BaseObject
49
+ include RuGUI::ObservablePropertySupport
50
+
51
+ observable_property :another_observable_property, :initial_value => "some_other_initial_value"
52
+ observable_property :first_core_observable_property, :core => true, :initial_value => "first"
53
+ observable_property :second_core_observable_property, :core => true, :initial_value => "second"
54
+
55
+ def to_s
56
+ self.class.name
57
+ end
58
+ end
59
+
60
+ class CustomTypeFakeObservable < RuGUI::BaseObject
61
+ include RuGUI::ObservablePropertySupport
62
+
63
+ observable_property :custom_type_observable_property, :core => true, :initial_value => AnotherFakeObservable.new
64
+
65
+ def to_s
66
+ self.class.name
67
+ end
68
+ end
69
+
70
+ class ResetPreventedFakeObservable < RuGUI::BaseObject
71
+ include RuGUI::ObservablePropertySupport
72
+
73
+ observable_property :reset_prevented_observable_property, :prevent_reset => true
74
+ observable_property :reset_prevented_with_reset_value_observable_property, :reset_value => 'foo', :prevent_reset => true
75
+
76
+ def to_s
77
+ self.class.name
78
+ end
79
+ end
80
+
81
+ class BooleanPropertiesFakeObservable < RuGUI::BaseObject
82
+ include RuGUI::ObservablePropertySupport
83
+
84
+ observable_property :boolean_observable_property, :boolean => true
85
+ observable_property :non_boolean_observable_property
86
+
87
+ def to_s
88
+ self.class.name
89
+ end
90
+ end
91
+
92
+ class ParentFakeObservable < RuGUI::BaseObject
93
+ include RuGUI::ObservablePropertySupport
94
+
95
+ observable_property :my_own_observable_property
96
+ observable_property :child_observable_property
97
+
98
+ def to_s
99
+ self.class.name
100
+ end
101
+ end
102
+
103
+ class ChildFakeObservable < RuGUI::BaseObject
104
+ include RuGUI::ObservablePropertySupport
105
+
106
+ observable_property :my_observable_property, :core => true
107
+
108
+ def to_s
109
+ self.class.name
110
+ end
111
+ end
112
+
113
+ class FakeObservableForPropertyObserverTest < RuGUI::BaseObject
114
+ include RuGUI::ObservablePropertySupport
115
+
116
+ observable_property :my_observable_property
117
+
118
+ def to_s
119
+ self.class.name
120
+ end
121
+ end
122
+
123
+ class FakeNamedObservableTest < RuGUI::BaseObject
124
+ include RuGUI::ObservablePropertySupport
125
+
126
+ observable_property :my_observable_property
127
+
128
+ def to_s
129
+ self.class.name
130
+ end
131
+ end
132
+
133
+ class FakeObserverForPropertyObserverTest < RuGUI::BaseObject
134
+ include RuGUI::PropertyObserver
135
+
136
+ attr_accessor :property_updated_message
137
+ attr_accessor :class_specific_method_called_message
138
+ attr_accessor :instance_specific_method_called_message
139
+ attr_accessor :instance_specific_method_called_counter
140
+ attr_accessor :observable
141
+ attr_accessor :named_observable
142
+ attr_accessor :fake_named_observable_test
143
+
144
+ attr_accessor :property_changed_counter
145
+
146
+ def initialize
147
+ @observable = FakeObservableForPropertyObserverTest.new
148
+ @observable.register_observer(self)
149
+
150
+ @named_observable = FakeObservableForPropertyObserverTest.new
151
+ @named_observable.register_observer(self, 'named_observable')
152
+
153
+ @fake_named_observable_test = FakeNamedObservableTest.new
154
+ @fake_named_observable_test.register_observer(self, 'fake_named_observable_test')
155
+
156
+ @property_changed_counter = 0
157
+ end
158
+
159
+ def framework_adapter
160
+ framework_adapter_for('BaseController')
161
+ end
162
+
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
+ def property_my_observable_property_changed(observable, new_value, old_value)
172
+ @property_updated_message = "#{observable} property my_observable_property changed from #{value_to_s(old_value)} to #{value_to_s(new_value)}"
173
+ end
174
+
175
+ def property_fake_observable_for_property_observer_test_my_observable_property_changed(observable, new_value, old_value)
176
+ @class_specific_method_called_message = "Property my_observable_property changed, called from class specific method"
177
+ end
178
+
179
+ def property_named_observable_my_observable_property_changed(observable, new_value, old_value)
180
+ @instance_specific_method_called_message = "Property my_observable_property changed, called from named instance specific method"
181
+ end
182
+
183
+ def property_fake_named_observable_test_my_observable_property_changed(observable, new_value, old_value)
184
+ @property_changed_counter += 1
185
+ end
186
+ end
187
+
188
+ class CustomType < RuGUI::BaseObject
189
+ attr_accessor :custom_property
190
+
191
+ def custom_method
192
+ "foo"
193
+ end
194
+
195
+ def custom_method_with_parameters(first_param, second_param, *args)
196
+ "#{first_param}, #{second_param}, #{args.join(', ')}"
197
+ end
198
+
199
+ def change_custom_property(new_value)
200
+ @custom_property = new_value
201
+ end
202
+
203
+ def ==(obj)
204
+ obj.is_a?(CustomType) and obj.custom_property == self.custom_property
205
+ end
206
+
207
+ def to_s
208
+ self.custom_property
209
+ end
210
+ end
@@ -0,0 +1,9 @@
1
+ # Defines some view helpers used in specs.
2
+
3
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'initialize_hooks_helper')
4
+
5
+ class MyViewHelper < RuGUI::BaseViewHelper
6
+ include InitializeHooksHelper
7
+
8
+ observable_property :message, :initial_value => "Some label in the middle"
9
+ end
@@ -0,0 +1,72 @@
1
+ # Defines some views used in specs.
2
+
3
+ require File.join(File.expand_path(File.dirname(__FILE__)), 'initialize_hooks_helper')
4
+
5
+ class MyView < RuGUI::BaseView
6
+ include InitializeHooksHelper
7
+
8
+ use_builder
9
+ builder_file File.join(File.dirname(__FILE__), '..', 'resource_files', 'my_view.glade')
10
+ root :top_window
11
+
12
+ attr_accessor :message
13
+
14
+ def setup_view_helpers
15
+ register_helper :my_view_helper, :my_other_view_helper_instance
16
+ end
17
+
18
+ def on_button_above_clicked(widget)
19
+ @message = "#{self.class} button above clicked."
20
+ end
21
+
22
+ def on_button_below_clicked(widget)
23
+ @message = "#{self.class} button below clicked."
24
+ end
25
+
26
+ def on_top_window_delete_event(widget, event)
27
+ @message = "#{self.class} top window deleted."
28
+ end
29
+
30
+ def property_message_changed(observable, new_value, old_value)
31
+ @message = "#{observable.class.name} property message changed from #{old_value} to #{new_value}"
32
+ end
33
+
34
+ def property_my_other_view_helper_instance_message_changed(observable, new_value, old_value)
35
+ @message = "Property message of my_other_view_helper_instance changed from #{old_value} to #{new_value}"
36
+ end
37
+ end
38
+
39
+ class MyChildView < MyView
40
+ root :vertical_container
41
+
42
+ def on_button_above_clicked(widget)
43
+ @message = "#{self.class} button above clicked."
44
+ end
45
+
46
+ def on_button_below_clicked(widget)
47
+ @message = "#{self.class} button below clicked."
48
+ end
49
+ end
50
+
51
+ class MyOtherView < RuGUI::BaseView
52
+ use_builder
53
+ builder_file File.join(File.dirname(__FILE__), '..', 'resource_files', 'my_other_view.glade')
54
+ root :top_window
55
+
56
+ attr_accessor :message
57
+
58
+ def on_button_right_clicked(widget)
59
+ @message = "#{self.class} button right clicked."
60
+ end
61
+
62
+ def on_button_left_clicked(widget)
63
+ @message = "#{self.class} button left clicked."
64
+ end
65
+
66
+ def on_top_window_delete_event(widget, event)
67
+ @message = "#{self.class} top window deleted."
68
+ end
69
+ end
70
+
71
+ class NoBuilderView < RuGUI::BaseView
72
+ end
data/spec/rcov.opts ADDED
@@ -0,0 +1 @@
1
+ --exclude "spec/*,gems/*"
@@ -0,0 +1,46 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
3
+ <!--Generated with glade3 3.4.5 on Thu Aug 28 14:02:01 2008 -->
4
+ <glade-interface>
5
+ <widget class="GtkWindow" id="top_window">
6
+ <property name="visible">True</property>
7
+ <signal name="delete_event" handler="on_top_window_delete_event"/>
8
+ <child>
9
+ <widget class="GtkHBox" id="horizontal_container">
10
+ <property name="visible">True</property>
11
+ <child>
12
+ <widget class="GtkButton" id="button_left">
13
+ <property name="visible">True</property>
14
+ <property name="can_focus">True</property>
15
+ <property name="receives_default">True</property>
16
+ <property name="label" translatable="yes">Button left</property>
17
+ <property name="response_id">0</property>
18
+ <signal name="clicked" handler="on_button_left_clicked"/>
19
+ </widget>
20
+ </child>
21
+ <child>
22
+ <widget class="GtkLabel" id="label">
23
+ <property name="visible">True</property>
24
+ <property name="label" translatable="yes">A label in the middle</property>
25
+ </widget>
26
+ <packing>
27
+ <property name="position">1</property>
28
+ </packing>
29
+ </child>
30
+ <child>
31
+ <widget class="GtkButton" id="button_right">
32
+ <property name="visible">True</property>
33
+ <property name="can_focus">True</property>
34
+ <property name="receives_default">True</property>
35
+ <property name="label" translatable="yes">Button right</property>
36
+ <property name="response_id">0</property>
37
+ <signal name="clicked" handler="on_button_right_clicked"/>
38
+ </widget>
39
+ <packing>
40
+ <property name="position">2</property>
41
+ </packing>
42
+ </child>
43
+ </widget>
44
+ </child>
45
+ </widget>
46
+ </glade-interface>
@@ -0,0 +1,46 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
3
+ <!--Generated with glade3 3.4.5 on Thu Aug 28 14:02:07 2008 -->
4
+ <glade-interface>
5
+ <widget class="GtkWindow" id="top_window">
6
+ <property name="visible">True</property>
7
+ <signal name="delete_event" handler="on_top_window_delete_event"/>
8
+ <child>
9
+ <widget class="GtkVBox" id="vertical_container">
10
+ <property name="visible">True</property>
11
+ <child>
12
+ <widget class="GtkButton" id="button_above">
13
+ <property name="visible">True</property>
14
+ <property name="can_focus">True</property>
15
+ <property name="receives_default">True</property>
16
+ <property name="label" translatable="yes">Button above</property>
17
+ <property name="response_id">0</property>
18
+ <signal name="clicked" handler="on_button_above_clicked"/>
19
+ </widget>
20
+ </child>
21
+ <child>
22
+ <widget class="GtkLabel" id="label">
23
+ <property name="visible">True</property>
24
+ <property name="label" translatable="yes">Some label in the middle</property>
25
+ </widget>
26
+ <packing>
27
+ <property name="position">1</property>
28
+ </packing>
29
+ </child>
30
+ <child>
31
+ <widget class="GtkButton" id="button_below">
32
+ <property name="visible">True</property>
33
+ <property name="can_focus">True</property>
34
+ <property name="receives_default">True</property>
35
+ <property name="label" translatable="yes">Button below</property>
36
+ <property name="response_id">0</property>
37
+ <signal name="clicked" handler="on_button_below_clicked"/>
38
+ </widget>
39
+ <packing>
40
+ <property name="position">2</property>
41
+ </packing>
42
+ </child>
43
+ </widget>
44
+ </child>
45
+ </widget>
46
+ </glade-interface>
data/spec/spec.opts ADDED
@@ -0,0 +1,4 @@
1
+ --colour
2
+ --format progress
3
+ --loadby mtime
4
+ --reverse
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'spec'
3
+
4
+ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
5
+
6
+ require 'rugui'
7
+ require 'rugui/initializer'
8
+
9
+ APPLICATION_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(APPLICATION_ROOT)
10
+
11
+ RuGUI::Initializer.run { |config| config.logger[:level] = :error }
12
+
13
+ Spec::Runner.configure do |config|
14
+ # No configuration here yet.
15
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rugui
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Vicente Mundim
8
+ - Felipe Mesquita
9
+ - Claudio Escudero
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2009-04-23 00:00:00 -03:00
15
+ default_executable: rugui
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: activesupport
19
+ type: :runtime
20
+ version_requirement:
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 2.1.1
26
+ version:
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubigen
29
+ type: :runtime
30
+ version_requirement:
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 1.5.1
36
+ version:
37
+ description: A simple MVC framework for RubyGTK.
38
+ email:
39
+ - vicente.mundim@intelitiva.com
40
+ - felipe.mesquita@intelitiva.com
41
+ - claudio.escudero@intelitiva.com
42
+ executables:
43
+ - rugui
44
+ extensions: []
45
+
46
+ extra_rdoc_files:
47
+ - LICENSE
48
+ - README
49
+ - README.rdoc
50
+ files:
51
+ - LICENSE
52
+ - README.rdoc
53
+ - Rakefile
54
+ - VERSION.yml
55
+ - bin/rugui
56
+ - lib/rugui.rb
57
+ - lib/rugui/base_controller.rb
58
+ - lib/rugui/base_model.rb
59
+ - lib/rugui/base_object.rb
60
+ - lib/rugui/base_view.rb
61
+ - lib/rugui/base_view_helper.rb
62
+ - lib/rugui/configuration.rb
63
+ - lib/rugui/framework_adapters/GTK.rb
64
+ - lib/rugui/framework_adapters/Qt4.rb
65
+ - lib/rugui/framework_adapters/base_framework_adapter.rb
66
+ - lib/rugui/framework_adapters/framework_adapter_support.rb
67
+ - lib/rugui/gem_builder.rb
68
+ - lib/rugui/gem_dependency.rb
69
+ - lib/rugui/initialize_hooks.rb
70
+ - lib/rugui/initializer.rb
71
+ - lib/rugui/log_support.rb
72
+ - lib/rugui/observable_property_proxy.rb
73
+ - lib/rugui/observable_property_support.rb
74
+ - lib/rugui/plugin/loader.rb
75
+ - lib/rugui/property_observer.rb
76
+ - lib/rugui/signal_support.rb
77
+ - lib/rugui/tasks/gems_application.rake
78
+ - lib/rugui/tasks/rugui.rb
79
+ - lib/rugui/tasks/rugui_framework.rb
80
+ - lib/rugui/tasks/runner_application.rake
81
+ - lib/rugui/tasks/spec_application.rake
82
+ - lib/rugui/tasks/spec_framework.rake
83
+ - lib/rugui/tasks/test_application.rake
84
+ - lib/rugui/vendor_gem_source_index.rb
85
+ - lib/rugui/version.rb
86
+ - spec/framework/base_controller_spec.rb
87
+ - spec/framework/base_model_spec.rb
88
+ - spec/framework/base_view_helper_spec.rb
89
+ - spec/framework/base_view_spec.rb
90
+ - spec/framework/log_support_spec.rb
91
+ - spec/framework/observable_property_proxy_spec.rb
92
+ - spec/framework/observable_property_support_spec.rb
93
+ - spec/framework/property_observer_spec.rb
94
+ - spec/helpers/controllers.rb
95
+ - spec/helpers/initialize_hooks_helper.rb
96
+ - spec/helpers/models.rb
97
+ - spec/helpers/observables.rb
98
+ - spec/helpers/view_helpers.rb
99
+ - spec/helpers/views.rb
100
+ - spec/rcov.opts
101
+ - spec/resource_files/my_other_view.glade
102
+ - spec/resource_files/my_view.glade
103
+ - spec/spec.opts
104
+ - spec/spec_helper.rb
105
+ - README
106
+ has_rdoc: true
107
+ homepage: http://rugui.org
108
+ licenses: []
109
+
110
+ post_install_message:
111
+ rdoc_options:
112
+ - --charset=UTF-8
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: "0"
120
+ version:
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: "0"
126
+ version:
127
+ requirements: []
128
+
129
+ rubyforge_project: rugui
130
+ rubygems_version: 1.3.2
131
+ signing_key:
132
+ specification_version: 3
133
+ summary: A simple MVC framework for RubyGTK.
134
+ test_files:
135
+ - spec/framework/base_model_spec.rb
136
+ - spec/framework/property_observer_spec.rb
137
+ - spec/framework/observable_property_proxy_spec.rb
138
+ - spec/framework/observable_property_support_spec.rb
139
+ - spec/framework/base_view_spec.rb
140
+ - spec/framework/base_view_helper_spec.rb
141
+ - spec/framework/log_support_spec.rb
142
+ - spec/framework/base_controller_spec.rb
143
+ - spec/spec_helper.rb
144
+ - spec/helpers/initialize_hooks_helper.rb
145
+ - spec/helpers/models.rb
146
+ - spec/helpers/view_helpers.rb
147
+ - spec/helpers/observables.rb
148
+ - spec/helpers/controllers.rb
149
+ - spec/helpers/views.rb