cura 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +15 -0
  3. data/Gemfile.lock +122 -0
  4. data/LICENSE +20 -0
  5. data/README.md +159 -0
  6. data/Rakefile +42 -0
  7. data/cura.gemspec +23 -0
  8. data/examples/box_model/bin/box_model +11 -0
  9. data/examples/box_model/debug.log +0 -0
  10. data/examples/box_model/lib/box_model.rb +21 -0
  11. data/examples/box_model/lib/box_model/application.rb +24 -0
  12. data/examples/hello_world/bin/hello_world +10 -0
  13. data/examples/hello_world/lib/hello_world.rb +201 -0
  14. data/examples/mruby-examples/README.md +10 -0
  15. data/examples/mruby-examples/include/cura_examples.h +6 -0
  16. data/examples/mruby-examples/mrbgem.rake +14 -0
  17. data/examples/mruby-examples/src/gem_init.c +34 -0
  18. data/examples/mruby-examples/tools/hello_world/hello_world.c +6 -0
  19. data/examples/todo_list/app.log +9 -0
  20. data/examples/todo_list/bin/todo_list +26 -0
  21. data/examples/todo_list/data.db +0 -0
  22. data/examples/todo_list/debug.log +0 -0
  23. data/examples/todo_list/lib/todo_list.rb +28 -0
  24. data/examples/todo_list/lib/todo_list/application.rb +54 -0
  25. data/examples/todo_list/lib/todo_list/component/header.rb +27 -0
  26. data/examples/todo_list/lib/todo_list/component/list.rb +50 -0
  27. data/examples/todo_list/lib/todo_list/component/list_item.rb +28 -0
  28. data/examples/todo_list/lib/todo_list/component/list_items.rb +97 -0
  29. data/examples/todo_list/lib/todo_list/component/lists.rb +89 -0
  30. data/examples/todo_list/lib/todo_list/database.rb +50 -0
  31. data/examples/todo_list/lib/todo_list/model/list.rb +9 -0
  32. data/examples/todo_list/lib/todo_list/model/list_item.rb +9 -0
  33. data/examples/todo_list/profile.html +11354 -0
  34. data/lib/cura.rb +13 -0
  35. data/lib/cura/adapter.rb +67 -0
  36. data/lib/cura/application.rb +245 -0
  37. data/lib/cura/attributes/has_ancestry.rb +40 -0
  38. data/lib/cura/attributes/has_application.rb +31 -0
  39. data/lib/cura/attributes/has_attributes.rb +89 -0
  40. data/lib/cura/attributes/has_children.rb +113 -0
  41. data/lib/cura/attributes/has_colors.rb +66 -0
  42. data/lib/cura/attributes/has_coordinates.rb +49 -0
  43. data/lib/cura/attributes/has_dimensions.rb +63 -0
  44. data/lib/cura/attributes/has_events.rb +89 -0
  45. data/lib/cura/attributes/has_focusability.rb +37 -0
  46. data/lib/cura/attributes/has_initialize.rb +15 -0
  47. data/lib/cura/attributes/has_offsets.rb +82 -0
  48. data/lib/cura/attributes/has_orientation.rb +53 -0
  49. data/lib/cura/attributes/has_relative_coordinates.rb +39 -0
  50. data/lib/cura/attributes/has_root.rb +104 -0
  51. data/lib/cura/attributes/has_side_attributes.rb +95 -0
  52. data/lib/cura/attributes/has_windows.rb +70 -0
  53. data/lib/cura/borders.rb +16 -0
  54. data/lib/cura/color.rb +330 -0
  55. data/lib/cura/component/base.rb +180 -0
  56. data/lib/cura/component/button.rb +57 -0
  57. data/lib/cura/component/group.rb +77 -0
  58. data/lib/cura/component/label.rb +224 -0
  59. data/lib/cura/component/listbox.rb +152 -0
  60. data/lib/cura/component/pack.rb +144 -0
  61. data/lib/cura/component/scrollbar.rb +184 -0
  62. data/lib/cura/component/textbox.rb +118 -0
  63. data/lib/cura/cursor.rb +77 -0
  64. data/lib/cura/error/base.rb +10 -0
  65. data/lib/cura/error/invalid_adapter.rb +18 -0
  66. data/lib/cura/error/invalid_application.rb +18 -0
  67. data/lib/cura/error/invalid_color.rb +18 -0
  68. data/lib/cura/error/invalid_component.rb +18 -0
  69. data/lib/cura/error/invalid_middleware.rb +18 -0
  70. data/lib/cura/event.rb +38 -0
  71. data/lib/cura/event/base.rb +108 -0
  72. data/lib/cura/event/click.rb +14 -0
  73. data/lib/cura/event/dispatcher.rb +122 -0
  74. data/lib/cura/event/focus.rb +14 -0
  75. data/lib/cura/event/handler.rb +74 -0
  76. data/lib/cura/event/key_down.rb +68 -0
  77. data/lib/cura/event/middleware/aimer/base.rb +38 -0
  78. data/lib/cura/event/middleware/aimer/dispatcher_target.rb +24 -0
  79. data/lib/cura/event/middleware/aimer/mouse_focus.rb +48 -0
  80. data/lib/cura/event/middleware/aimer/target_option.rb +38 -0
  81. data/lib/cura/event/middleware/base.rb +21 -0
  82. data/lib/cura/event/middleware/dispatch.rb +20 -0
  83. data/lib/cura/event/middleware/translator/base.rb +37 -0
  84. data/lib/cura/event/middleware/translator/mouse_click.rb +44 -0
  85. data/lib/cura/event/mouse.rb +34 -0
  86. data/lib/cura/event/mouse_button.rb +103 -0
  87. data/lib/cura/event/mouse_wheel_down.rb +14 -0
  88. data/lib/cura/event/mouse_wheel_up.rb +14 -0
  89. data/lib/cura/event/resize.rb +17 -0
  90. data/lib/cura/event/selected.rb +14 -0
  91. data/lib/cura/event/unfocus.rb +14 -0
  92. data/lib/cura/focus_controller.rb +89 -0
  93. data/lib/cura/key.rb +313 -0
  94. data/lib/cura/margins.rb +16 -0
  95. data/lib/cura/offsets.rb +91 -0
  96. data/lib/cura/padding.rb +16 -0
  97. data/lib/cura/pencil.rb +29 -0
  98. data/lib/cura/version.rb +6 -0
  99. data/lib/cura/window.rb +85 -0
  100. data/spec/cura/attributes/has_ancestry_spec.rb +108 -0
  101. data/spec/cura/attributes/has_application_spec.rb +59 -0
  102. data/spec/cura/attributes/has_attributes_spec.rb +75 -0
  103. data/spec/cura/attributes/has_children_spec.rb +169 -0
  104. data/spec/cura/attributes/has_colors_spec.rb +20 -0
  105. data/spec/cura/attributes/has_coordinates_spec.rb +19 -0
  106. data/spec/cura/attributes/has_dimensions_spec.rb +19 -0
  107. data/spec/cura/attributes/has_events_spec.rb +18 -0
  108. data/spec/cura/attributes/has_focusability_spec.rb +58 -0
  109. data/spec/cura/attributes/has_offsets_spec.rb +18 -0
  110. data/spec/cura/attributes/has_orientation_spec.rb +102 -0
  111. data/spec/cura/attributes/has_relative_coordinates_spec.rb +18 -0
  112. data/spec/cura/attributes/has_side_attributes_spec.rb +19 -0
  113. data/spec/spec_helper.rb +12 -0
  114. data/spec/support/shared_examples_for_attributes.rb +122 -0
  115. metadata +211 -0
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+ require "support/shared_examples_for_attributes"
3
+
4
+ require "cura/attributes/has_initialize"
5
+ require "cura/attributes/has_side_attributes"
6
+
7
+ describe Cura::Attributes::HasSideAttributes do
8
+
9
+ let(:instance) do
10
+ instance_class = Class.new
11
+ instance_class.include(Cura::Attributes::HasInitialize)
12
+ instance_class.include(Cura::Attributes::HasSideAttributes)
13
+
14
+ instance_class.new
15
+ end
16
+
17
+ it_should_behave_like "an object with size accessors", :top, :right, :bottom, :left
18
+
19
+ end
@@ -0,0 +1,12 @@
1
+ require "simplecov"
2
+ SimpleCov.start
3
+
4
+ RSpec.configure do |config|
5
+ config.expect_with :rspec do |expectations|
6
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
7
+ end
8
+
9
+ config.mock_with :rspec do |mocks|
10
+ mocks.verify_partial_doubles = true
11
+ end
12
+ end
@@ -0,0 +1,122 @@
1
+ shared_examples "an object with integer accessors" do |*attributes|
2
+ options = attributes.last.is_a?(Hash) ? attributes.pop : {}
3
+ options = { default: 0 }.merge(options)
4
+
5
+ attributes.each do |attribute|
6
+
7
+ describe "##{attribute}" do
8
+
9
+ it "should be initialized with the correct value" do
10
+ expect(instance.send(attribute)).to eq(options[:default])
11
+ end
12
+
13
+ end
14
+
15
+ describe "##{attribute}=" do
16
+
17
+ it "should set the attribute correctly" do
18
+ instance.send("#{attribute}=", 10)
19
+ expect(instance.send(attribute)).to eq(10)
20
+ end
21
+
22
+ it "should convert the value to an integer" do
23
+ instance.send("#{attribute}=", "10")
24
+ expect(instance.send(attribute)).to eq(10)
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+ end
31
+
32
+ shared_examples "an object with size accessors" do |*attributes|
33
+ options = attributes.last.is_a?(Hash) ? attributes.pop : {}
34
+ options = { default: 0 }.merge(options)
35
+
36
+ attributes.each do |attribute|
37
+
38
+ it_should_behave_like "an object with integer accessors", attribute, options
39
+
40
+ describe "##{attribute}=" do
41
+
42
+ context "when a symbol is passed" do
43
+
44
+ context "and it is valid" do
45
+
46
+ it "should set the attribute correctly" do
47
+ instance.send("#{attribute}=", :inherit)
48
+ expect(instance.send(attribute)).to eq(:inherit)
49
+
50
+ instance.send("#{attribute}=", :auto)
51
+ expect(instance.send(attribute)).to eq(:auto)
52
+ end
53
+
54
+ end
55
+
56
+ context "and it is invalid" do
57
+
58
+ it "should raise an ArgumentError" do
59
+ expect { instance.send("#{attribute}=", :invalid_symbol) }.to raise_error(ArgumentError)
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+
66
+ end
67
+
68
+ end
69
+ end
70
+
71
+ shared_examples "an object with color accessors" do |*attributes|
72
+ attributes.each do |attribute|
73
+
74
+ describe "##{attribute}" do
75
+
76
+ it "should be initialized with the correct value" do
77
+ expect(instance.send(attribute)).to eq(:inherit)
78
+ end
79
+
80
+ end
81
+
82
+ describe "##{attribute}=" do
83
+
84
+ context "when a Color is passed" do
85
+
86
+ before { instance.send("#{attribute}=", Cura::Color.red) }
87
+
88
+ it "should set the attribute correctly" do
89
+ expect(instance.send(attribute)).to eq(Cura::Color.red)
90
+ end
91
+
92
+ end
93
+
94
+ context "when a Symbol-like object is passed" do
95
+
96
+ context "and it is valid" do
97
+
98
+ it "should set the attribute correctly" do
99
+ instance.send("#{attribute}=", :inherit)
100
+ expect(instance.send(attribute)).to eq(:inherit)
101
+
102
+ instance.send("#{attribute}=", "inherit")
103
+ expect(instance.send(attribute)).to eq(:inherit)
104
+ end
105
+
106
+ end
107
+
108
+ context "and it is invalid" do
109
+
110
+ it "should set the attribute correctly" do
111
+ expect { instance.send("#{attribute}=", :invalid_symbol) }.to raise_error(Cura::Error::InvalidColor)
112
+ expect { instance.send("#{attribute}=", "invalid_symbol") }.to raise_error(Cura::Error::InvalidColor)
113
+ end
114
+
115
+ end
116
+
117
+ end
118
+
119
+ end
120
+
121
+ end
122
+ end
metadata ADDED
@@ -0,0 +1,211 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cura
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Scott Lewis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-01-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: builder
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.2
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.2
27
+ description: A library written in pure Ruby for building user interfaces.
28
+ email: ryan@rynet.us
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - Gemfile
34
+ - Gemfile.lock
35
+ - LICENSE
36
+ - README.md
37
+ - Rakefile
38
+ - cura.gemspec
39
+ - examples/box_model/bin/box_model
40
+ - examples/box_model/debug.log
41
+ - examples/box_model/lib/box_model.rb
42
+ - examples/box_model/lib/box_model/application.rb
43
+ - examples/hello_world/bin/hello_world
44
+ - examples/hello_world/lib/hello_world.rb
45
+ - examples/mruby-examples/README.md
46
+ - examples/mruby-examples/include/cura_examples.h
47
+ - examples/mruby-examples/mrbgem.rake
48
+ - examples/mruby-examples/src/gem_init.c
49
+ - examples/mruby-examples/tools/hello_world/hello_world.c
50
+ - examples/todo_list/app.log
51
+ - examples/todo_list/bin/todo_list
52
+ - examples/todo_list/data.db
53
+ - examples/todo_list/debug.log
54
+ - examples/todo_list/lib/todo_list.rb
55
+ - examples/todo_list/lib/todo_list/application.rb
56
+ - examples/todo_list/lib/todo_list/component/header.rb
57
+ - examples/todo_list/lib/todo_list/component/list.rb
58
+ - examples/todo_list/lib/todo_list/component/list_item.rb
59
+ - examples/todo_list/lib/todo_list/component/list_items.rb
60
+ - examples/todo_list/lib/todo_list/component/lists.rb
61
+ - examples/todo_list/lib/todo_list/database.rb
62
+ - examples/todo_list/lib/todo_list/model/list.rb
63
+ - examples/todo_list/lib/todo_list/model/list_item.rb
64
+ - examples/todo_list/profile.html
65
+ - lib/cura.rb
66
+ - lib/cura/adapter.rb
67
+ - lib/cura/application.rb
68
+ - lib/cura/attributes/has_ancestry.rb
69
+ - lib/cura/attributes/has_application.rb
70
+ - lib/cura/attributes/has_attributes.rb
71
+ - lib/cura/attributes/has_children.rb
72
+ - lib/cura/attributes/has_colors.rb
73
+ - lib/cura/attributes/has_coordinates.rb
74
+ - lib/cura/attributes/has_dimensions.rb
75
+ - lib/cura/attributes/has_events.rb
76
+ - lib/cura/attributes/has_focusability.rb
77
+ - lib/cura/attributes/has_initialize.rb
78
+ - lib/cura/attributes/has_offsets.rb
79
+ - lib/cura/attributes/has_orientation.rb
80
+ - lib/cura/attributes/has_relative_coordinates.rb
81
+ - lib/cura/attributes/has_root.rb
82
+ - lib/cura/attributes/has_side_attributes.rb
83
+ - lib/cura/attributes/has_windows.rb
84
+ - lib/cura/borders.rb
85
+ - lib/cura/color.rb
86
+ - lib/cura/component/base.rb
87
+ - lib/cura/component/button.rb
88
+ - lib/cura/component/group.rb
89
+ - lib/cura/component/label.rb
90
+ - lib/cura/component/listbox.rb
91
+ - lib/cura/component/pack.rb
92
+ - lib/cura/component/scrollbar.rb
93
+ - lib/cura/component/textbox.rb
94
+ - lib/cura/cursor.rb
95
+ - lib/cura/error/base.rb
96
+ - lib/cura/error/invalid_adapter.rb
97
+ - lib/cura/error/invalid_application.rb
98
+ - lib/cura/error/invalid_color.rb
99
+ - lib/cura/error/invalid_component.rb
100
+ - lib/cura/error/invalid_middleware.rb
101
+ - lib/cura/event.rb
102
+ - lib/cura/event/base.rb
103
+ - lib/cura/event/click.rb
104
+ - lib/cura/event/dispatcher.rb
105
+ - lib/cura/event/focus.rb
106
+ - lib/cura/event/handler.rb
107
+ - lib/cura/event/key_down.rb
108
+ - lib/cura/event/middleware/aimer/base.rb
109
+ - lib/cura/event/middleware/aimer/dispatcher_target.rb
110
+ - lib/cura/event/middleware/aimer/mouse_focus.rb
111
+ - lib/cura/event/middleware/aimer/target_option.rb
112
+ - lib/cura/event/middleware/base.rb
113
+ - lib/cura/event/middleware/dispatch.rb
114
+ - lib/cura/event/middleware/translator/base.rb
115
+ - lib/cura/event/middleware/translator/mouse_click.rb
116
+ - lib/cura/event/mouse.rb
117
+ - lib/cura/event/mouse_button.rb
118
+ - lib/cura/event/mouse_wheel_down.rb
119
+ - lib/cura/event/mouse_wheel_up.rb
120
+ - lib/cura/event/resize.rb
121
+ - lib/cura/event/selected.rb
122
+ - lib/cura/event/unfocus.rb
123
+ - lib/cura/focus_controller.rb
124
+ - lib/cura/key.rb
125
+ - lib/cura/margins.rb
126
+ - lib/cura/offsets.rb
127
+ - lib/cura/padding.rb
128
+ - lib/cura/pencil.rb
129
+ - lib/cura/version.rb
130
+ - lib/cura/window.rb
131
+ - spec/cura/attributes/has_ancestry_spec.rb
132
+ - spec/cura/attributes/has_application_spec.rb
133
+ - spec/cura/attributes/has_attributes_spec.rb
134
+ - spec/cura/attributes/has_children_spec.rb
135
+ - spec/cura/attributes/has_colors_spec.rb
136
+ - spec/cura/attributes/has_coordinates_spec.rb
137
+ - spec/cura/attributes/has_dimensions_spec.rb
138
+ - spec/cura/attributes/has_events_spec.rb
139
+ - spec/cura/attributes/has_focusability_spec.rb
140
+ - spec/cura/attributes/has_offsets_spec.rb
141
+ - spec/cura/attributes/has_orientation_spec.rb
142
+ - spec/cura/attributes/has_relative_coordinates_spec.rb
143
+ - spec/cura/attributes/has_side_attributes_spec.rb
144
+ - spec/spec_helper.rb
145
+ - spec/support/shared_examples_for_attributes.rb
146
+ homepage: http://github.com/RyanScottLewis/
147
+ licenses:
148
+ - MIT
149
+ metadata: {}
150
+ post_install_message:
151
+ rdoc_options: []
152
+ require_paths:
153
+ - lib
154
+ required_ruby_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ requirements: []
165
+ rubyforge_project:
166
+ rubygems_version: 2.4.5
167
+ signing_key:
168
+ specification_version: 4
169
+ summary: A library written in pure Ruby for building user interfaces.
170
+ test_files:
171
+ - examples/box_model/lib/box_model/application.rb
172
+ - examples/box_model/lib/box_model.rb
173
+ - examples/box_model/bin/box_model
174
+ - examples/box_model/debug.log
175
+ - examples/hello_world/lib/hello_world.rb
176
+ - examples/hello_world/bin/hello_world
177
+ - examples/mruby-examples/mrbgem.rake
178
+ - examples/mruby-examples/src/gem_init.c
179
+ - examples/mruby-examples/include/cura_examples.h
180
+ - examples/mruby-examples/README.md
181
+ - examples/mruby-examples/tools/hello_world/hello_world.c
182
+ - examples/todo_list/lib/todo_list.rb
183
+ - examples/todo_list/lib/todo_list/component/list_item.rb
184
+ - examples/todo_list/lib/todo_list/component/lists.rb
185
+ - examples/todo_list/lib/todo_list/component/list.rb
186
+ - examples/todo_list/lib/todo_list/component/list_items.rb
187
+ - examples/todo_list/lib/todo_list/component/header.rb
188
+ - examples/todo_list/lib/todo_list/database.rb
189
+ - examples/todo_list/lib/todo_list/application.rb
190
+ - examples/todo_list/lib/todo_list/model/list_item.rb
191
+ - examples/todo_list/lib/todo_list/model/list.rb
192
+ - examples/todo_list/profile.html
193
+ - examples/todo_list/bin/todo_list
194
+ - examples/todo_list/data.db
195
+ - examples/todo_list/app.log
196
+ - examples/todo_list/debug.log
197
+ - spec/cura/attributes/has_children_spec.rb
198
+ - spec/cura/attributes/has_events_spec.rb
199
+ - spec/cura/attributes/has_coordinates_spec.rb
200
+ - spec/cura/attributes/has_attributes_spec.rb
201
+ - spec/cura/attributes/has_offsets_spec.rb
202
+ - spec/cura/attributes/has_colors_spec.rb
203
+ - spec/cura/attributes/has_dimensions_spec.rb
204
+ - spec/cura/attributes/has_side_attributes_spec.rb
205
+ - spec/cura/attributes/has_ancestry_spec.rb
206
+ - spec/cura/attributes/has_orientation_spec.rb
207
+ - spec/cura/attributes/has_relative_coordinates_spec.rb
208
+ - spec/cura/attributes/has_application_spec.rb
209
+ - spec/cura/attributes/has_focusability_spec.rb
210
+ - spec/support/shared_examples_for_attributes.rb
211
+ - spec/spec_helper.rb