cura 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +45 -21
  3. data/cura.gemspec +1 -1
  4. data/examples/hello_world/lib/hello_world.rb +10 -10
  5. data/examples/mruby-examples/mrbgem.rake +5 -6
  6. data/examples/todo_list/data.db +0 -0
  7. data/examples/todo_list/lib/todo_list/application.rb +24 -18
  8. data/lib/cura/adapter.rb +13 -20
  9. data/lib/cura/application.rb +47 -51
  10. data/lib/cura/attributes/has_ancestry.rb +4 -8
  11. data/lib/cura/attributes/has_application.rb +3 -7
  12. data/lib/cura/attributes/has_attributes.rb +1 -9
  13. data/lib/cura/attributes/has_children.rb +14 -20
  14. data/lib/cura/attributes/has_colors.rb +14 -18
  15. data/lib/cura/attributes/has_coordinates.rb +9 -15
  16. data/lib/cura/attributes/has_dimensions.rb +12 -18
  17. data/lib/cura/attributes/has_events.rb +10 -18
  18. data/lib/cura/attributes/has_focusability.rb +5 -11
  19. data/lib/cura/attributes/has_initialize.rb +1 -5
  20. data/lib/cura/attributes/has_offsets.rb +16 -20
  21. data/lib/cura/attributes/has_orientation.rb +12 -18
  22. data/lib/cura/attributes/has_relative_coordinates.rb +4 -8
  23. data/lib/cura/attributes/has_root.rb +18 -22
  24. data/lib/cura/attributes/has_side_attributes.rb +18 -24
  25. data/lib/cura/attributes/has_windows.rb +13 -19
  26. data/lib/cura/borders.rb +0 -4
  27. data/lib/cura/color.rb +84 -91
  28. data/lib/cura/component/base.rb +29 -33
  29. data/lib/cura/component/button.rb +10 -16
  30. data/lib/cura/component/group.rb +14 -18
  31. data/lib/cura/component/label.rb +44 -48
  32. data/lib/cura/component/listbox.rb +24 -28
  33. data/lib/cura/component/pack.rb +14 -18
  34. data/lib/cura/component/scrollbar.rb +41 -45
  35. data/lib/cura/component/textbox.rb +21 -25
  36. data/lib/cura/cursor.rb +15 -23
  37. data/lib/cura/error/base.rb +0 -3
  38. data/lib/cura/error/invalid_adapter.rb +1 -7
  39. data/lib/cura/error/invalid_application.rb +1 -7
  40. data/lib/cura/error/invalid_color.rb +1 -7
  41. data/lib/cura/error/invalid_component.rb +1 -7
  42. data/lib/cura/error/invalid_middleware.rb +1 -7
  43. data/lib/cura/event.rb +4 -8
  44. data/lib/cura/event/base.rb +17 -24
  45. data/lib/cura/event/click.rb +1 -6
  46. data/lib/cura/event/dispatcher.rb +20 -26
  47. data/lib/cura/event/focus.rb +1 -6
  48. data/lib/cura/event/handler.rb +16 -24
  49. data/lib/cura/event/key_down.rb +11 -17
  50. data/lib/cura/event/middleware/aimer/base.rb +4 -10
  51. data/lib/cura/event/middleware/aimer/dispatcher_target.rb +2 -8
  52. data/lib/cura/event/middleware/aimer/mouse_focus.rb +6 -11
  53. data/lib/cura/event/middleware/aimer/target_option.rb +4 -10
  54. data/lib/cura/event/middleware/base.rb +0 -4
  55. data/lib/cura/event/middleware/dispatch.rb +0 -4
  56. data/lib/cura/event/middleware/translator/base.rb +4 -10
  57. data/lib/cura/event/middleware/translator/mouse_click.rb +4 -8
  58. data/lib/cura/event/mouse.rb +5 -11
  59. data/lib/cura/event/mouse_button.rb +21 -27
  60. data/lib/cura/event/mouse_wheel_down.rb +1 -6
  61. data/lib/cura/event/mouse_wheel_up.rb +1 -6
  62. data/lib/cura/event/resize.rb +0 -4
  63. data/lib/cura/event/selected.rb +1 -6
  64. data/lib/cura/event/unfocus.rb +1 -6
  65. data/lib/cura/focus_controller.rb +19 -23
  66. data/lib/cura/key.rb +277 -283
  67. data/lib/cura/margins.rb +0 -4
  68. data/lib/cura/offsets.rb +14 -18
  69. data/lib/cura/padding.rb +0 -4
  70. data/lib/cura/pencil.rb +3 -7
  71. data/lib/cura/version.rb +1 -3
  72. data/lib/cura/window.rb +11 -16
  73. data/spec/cura/attributes/has_ancestry_spec.rb +39 -39
  74. data/spec/cura/attributes/has_application_spec.rb +20 -20
  75. data/spec/cura/attributes/has_attributes_spec.rb +26 -26
  76. data/spec/cura/attributes/has_children_spec.rb +54 -54
  77. data/spec/cura/attributes/has_colors_spec.rb +4 -4
  78. data/spec/cura/attributes/has_coordinates_spec.rb +4 -4
  79. data/spec/cura/attributes/has_dimensions_spec.rb +4 -4
  80. data/spec/cura/attributes/has_events_spec.rb +4 -4
  81. data/spec/cura/attributes/has_focusability_spec.rb +18 -18
  82. data/spec/cura/attributes/has_offsets_spec.rb +4 -4
  83. data/spec/cura/attributes/has_orientation_spec.rb +38 -38
  84. data/spec/cura/attributes/has_relative_coordinates_spec.rb +4 -4
  85. data/spec/cura/attributes/has_side_attributes_spec.rb +4 -4
  86. data/spec/spec_helper.rb +1 -1
  87. data/spec/support/shared_examples_for_attributes.rb +41 -41
  88. metadata +1 -1
@@ -4,72 +4,72 @@ require "cura/attributes/has_initialize"
4
4
  require "cura/attributes/has_attributes"
5
5
 
6
6
  describe Cura::Attributes::HasAttributes do
7
-
7
+
8
8
  let(:instance_class) do
9
9
  instance_class = Class.new { attr_accessor :name }
10
-
10
+
11
11
  instance_class.include(Cura::Attributes::HasInitialize)
12
12
  instance_class.include(Cura::Attributes::HasAttributes)
13
-
13
+
14
14
  instance_class
15
15
  end
16
-
16
+
17
17
  describe ".attribute" do
18
18
  # TODO
19
19
  end
20
-
20
+
21
21
  describe "#initialize" do
22
-
22
+
23
23
  context "when no arguments are given" do
24
-
24
+
25
25
  let(:instance) { instance_class.new }
26
-
26
+
27
27
  it "should do nothing" do
28
28
  expect(instance.name).to eq(nil)
29
29
  end
30
-
30
+
31
31
  end
32
-
32
+
33
33
  context "when an argument is given" do
34
-
34
+
35
35
  let(:instance) { instance_class.new(name: "test") }
36
-
36
+
37
37
  it "should set the attribute" do
38
38
  expect(instance.name).to eq("test")
39
39
  end
40
-
40
+
41
41
  end
42
-
42
+
43
43
  end
44
-
44
+
45
45
  describe "#update_attributes" do
46
-
46
+
47
47
  let(:instance) { instance_class.new }
48
-
48
+
49
49
  context "when no arguments are given" do
50
-
50
+
51
51
  before do
52
52
  instance.update_attributes
53
53
  end
54
-
54
+
55
55
  it "should do nothing" do
56
56
  expect(instance.name).to eq(nil)
57
57
  end
58
-
58
+
59
59
  end
60
-
60
+
61
61
  context "when an argument is given" do
62
-
62
+
63
63
  before do
64
64
  instance.update_attributes(name: "test")
65
65
  end
66
-
66
+
67
67
  it "should set the attribute" do
68
68
  expect(instance.name).to eq("test")
69
69
  end
70
-
70
+
71
71
  end
72
-
72
+
73
73
  end
74
-
74
+
75
75
  end
@@ -5,165 +5,165 @@ require "cura/component/base"
5
5
  require "cura/attributes/has_children"
6
6
 
7
7
  describe Cura::Attributes::HasChildren do
8
-
8
+
9
9
  let(:instance) do
10
10
  instance_class = Class.new
11
11
  instance_class.include(Cura::Attributes::HasChildren)
12
-
12
+
13
13
  instance_class.new
14
14
  end
15
-
15
+
16
16
  let(:child_class) do
17
17
  instance_class = Class.new(Cura::Component::Base)
18
18
  instance_class.include(Cura::Attributes::HasChildren)
19
-
19
+
20
20
  instance_class
21
21
  end
22
-
22
+
23
23
  let(:child_1) { child_class.new }
24
24
  let(:child_2) { child_class.new }
25
25
  let(:children) { [child_1, child_2] }
26
-
26
+
27
27
  describe "#children" do
28
-
28
+
29
29
  it "should be initialized with the correct value" do
30
30
  expect(instance.children).to eq([])
31
31
  end
32
-
32
+
33
33
  context "when recursive is unset" do
34
-
34
+
35
35
  before do
36
36
  instance.add_children(*children)
37
37
  end
38
-
38
+
39
39
  it "should return it's children" do
40
40
  expect(instance.children).to eq(children)
41
41
  end
42
-
42
+
43
43
  end
44
-
44
+
45
45
  context "when recursive is set" do
46
-
46
+
47
47
  let(:child) { child_class.new }
48
-
48
+
49
49
  before do
50
50
  instance.add_child(child)
51
51
  child.add_children(*children)
52
52
  end
53
-
53
+
54
54
  it "should return all of it's children's children as well" do
55
55
  expect(instance.children(true)).to eq([child] + children)
56
56
  end
57
-
57
+
58
58
  end
59
-
59
+
60
60
  end
61
-
61
+
62
62
  describe "#add_child" do
63
-
63
+
64
64
  before do
65
65
  instance.add_child(child_1)
66
66
  instance.add_child(child_2)
67
67
  end
68
-
68
+
69
69
  it "should add the children" do
70
70
  expect(instance.children).to eq([child_1, child_2])
71
71
  end
72
-
72
+
73
73
  end
74
-
74
+
75
75
  describe "#add_children" do
76
-
76
+
77
77
  before do
78
78
  instance.add_children(child_1, child_2)
79
79
  end
80
-
80
+
81
81
  it "should add the children" do
82
82
  expect(instance.children).to eq([child_1, child_2])
83
83
  end
84
-
84
+
85
85
  end
86
-
86
+
87
87
  describe "#delete_child_at" do
88
-
88
+
89
89
  before do
90
90
  instance.add_children(child_1, child_2)
91
91
  end
92
-
92
+
93
93
  context "when a positive index is given" do
94
-
94
+
95
95
  before do
96
96
  instance.delete_child_at(1)
97
97
  end
98
-
98
+
99
99
  it "should delete the child" do
100
100
  expect(instance.children).to eq([child_1])
101
101
  end
102
-
102
+
103
103
  end
104
-
104
+
105
105
  context "when a negative index is given" do
106
-
106
+
107
107
  before do
108
108
  instance.delete_child_at(-1)
109
109
  end
110
-
110
+
111
111
  it "should delete the child" do
112
112
  expect(instance.children).to eq([child_1])
113
113
  end
114
-
114
+
115
115
  end
116
-
116
+
117
117
  end
118
-
118
+
119
119
  describe "#delete_child" do
120
-
120
+
121
121
  before do
122
122
  instance.add_children(child_1, child_2)
123
123
  instance.delete_child(child_2)
124
124
  end
125
-
125
+
126
126
  it "should delete the child" do
127
127
  expect(instance.children).to eq([child_1])
128
128
  end
129
-
129
+
130
130
  end
131
-
131
+
132
132
  describe "#delete_children" do
133
-
133
+
134
134
  before do
135
135
  instance.add_children(child_1, child_2)
136
136
  instance.delete_children
137
137
  end
138
-
138
+
139
139
  it "should delete all children" do
140
140
  expect(instance.children).to eq([])
141
141
  end
142
-
142
+
143
143
  end
144
-
144
+
145
145
  describe "#children?" do
146
-
146
+
147
147
  context "when there aren't children" do
148
-
148
+
149
149
  it "should return false" do
150
150
  expect(instance.children?).to eq(false)
151
151
  end
152
-
152
+
153
153
  end
154
-
154
+
155
155
  context "when there are children" do
156
-
156
+
157
157
  before do
158
158
  instance.add_children(child_1, child_2)
159
159
  end
160
-
160
+
161
161
  it "should return true" do
162
162
  expect(instance.children?).to eq(true)
163
163
  end
164
-
164
+
165
165
  end
166
-
166
+
167
167
  end
168
-
168
+
169
169
  end
@@ -6,15 +6,15 @@ require "cura/attributes/has_initialize"
6
6
  require "cura/attributes/has_colors"
7
7
 
8
8
  describe Cura::Attributes::HasColors do
9
-
9
+
10
10
  let(:instance) do
11
11
  instance_class = Class.new
12
12
  instance_class.include(Cura::Attributes::HasInitialize)
13
13
  instance_class.include(Cura::Attributes::HasColors)
14
-
14
+
15
15
  instance_class.new
16
16
  end
17
-
17
+
18
18
  it_should_behave_like "an object with color accessors", :foreground, :background
19
-
19
+
20
20
  end
@@ -5,15 +5,15 @@ require "cura/attributes/has_initialize"
5
5
  require "cura/attributes/has_coordinates"
6
6
 
7
7
  describe Cura::Attributes::HasCoordinates do
8
-
8
+
9
9
  let(:instance) do
10
10
  instance_class = Class.new
11
11
  instance_class.include(Cura::Attributes::HasInitialize)
12
12
  instance_class.include(Cura::Attributes::HasCoordinates)
13
-
13
+
14
14
  instance_class.new
15
15
  end
16
-
16
+
17
17
  it_should_behave_like "an object with integer accessors", :x, :y
18
-
18
+
19
19
  end
@@ -5,15 +5,15 @@ require "cura/attributes/has_initialize"
5
5
  require "cura/attributes/has_dimensions"
6
6
 
7
7
  describe Cura::Attributes::HasDimensions do
8
-
8
+
9
9
  let(:instance) do
10
10
  instance_class = Class.new
11
11
  instance_class.include(Cura::Attributes::HasInitialize)
12
12
  instance_class.include(Cura::Attributes::HasDimensions)
13
-
13
+
14
14
  instance_class.new
15
15
  end
16
-
16
+
17
17
  it_should_behave_like "an object with size accessors", :width, :height, default: :auto
18
-
18
+
19
19
  end
@@ -4,15 +4,15 @@ require "cura/attributes/has_initialize"
4
4
  require "cura/attributes/has_events"
5
5
 
6
6
  describe Cura::Attributes::HasEvents do
7
-
7
+
8
8
  let(:instance) do
9
9
  instance_class = Class.new
10
10
  instance_class.include(Cura::Attributes::HasInitialize)
11
11
  instance_class.include(Cura::Attributes::HasEvents)
12
-
12
+
13
13
  instance_class.new
14
14
  end
15
-
15
+
16
16
  pending
17
-
17
+
18
18
  end
@@ -4,55 +4,55 @@ require "cura/attributes/has_initialize"
4
4
  require "cura/attributes/has_focusability"
5
5
 
6
6
  describe Cura::Attributes::HasFocusability do
7
-
7
+
8
8
  let(:instance) do
9
9
  instance_class = Class.new
10
10
  instance_class.include(Cura::Attributes::HasInitialize)
11
11
  instance_class.include(Cura::Attributes::HasFocusability)
12
-
12
+
13
13
  instance_class.new
14
14
  end
15
-
15
+
16
16
  describe "#focusable?" do
17
-
17
+
18
18
  it "should be initialized with the correct value" do
19
19
  expect(instance.focusable?).to eq(false)
20
20
  end
21
-
21
+
22
22
  end
23
-
23
+
24
24
  describe "#focusable=" do
25
-
25
+
26
26
  context "when a boolean is passed" do
27
-
27
+
28
28
  it "should set the attribute correctly" do
29
29
  instance.focusable = true
30
30
  expect(instance.focusable?).to eq(true)
31
-
31
+
32
32
  instance.focusable = false
33
33
  expect(instance.focusable?).to eq(false)
34
34
  end
35
-
35
+
36
36
  end
37
-
37
+
38
38
  context "when a truthy object is passed" do
39
-
39
+
40
40
  it "should set the attribute correctly" do
41
41
  instance.focusable = "truthy object"
42
42
  expect(instance.focusable?).to eq(true)
43
43
  end
44
-
44
+
45
45
  end
46
-
46
+
47
47
  context "when a falsey object is passed" do
48
-
48
+
49
49
  it "should set the attribute correctly" do
50
50
  instance.focusable = nil
51
51
  expect(instance.focusable?).to eq(false)
52
52
  end
53
-
53
+
54
54
  end
55
-
55
+
56
56
  end
57
-
57
+
58
58
  end