cura 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +45 -21
- data/cura.gemspec +1 -1
- data/examples/hello_world/lib/hello_world.rb +10 -10
- data/examples/mruby-examples/mrbgem.rake +5 -6
- data/examples/todo_list/data.db +0 -0
- data/examples/todo_list/lib/todo_list/application.rb +24 -18
- data/lib/cura/adapter.rb +13 -20
- data/lib/cura/application.rb +47 -51
- data/lib/cura/attributes/has_ancestry.rb +4 -8
- data/lib/cura/attributes/has_application.rb +3 -7
- data/lib/cura/attributes/has_attributes.rb +1 -9
- data/lib/cura/attributes/has_children.rb +14 -20
- data/lib/cura/attributes/has_colors.rb +14 -18
- data/lib/cura/attributes/has_coordinates.rb +9 -15
- data/lib/cura/attributes/has_dimensions.rb +12 -18
- data/lib/cura/attributes/has_events.rb +10 -18
- data/lib/cura/attributes/has_focusability.rb +5 -11
- data/lib/cura/attributes/has_initialize.rb +1 -5
- data/lib/cura/attributes/has_offsets.rb +16 -20
- data/lib/cura/attributes/has_orientation.rb +12 -18
- data/lib/cura/attributes/has_relative_coordinates.rb +4 -8
- data/lib/cura/attributes/has_root.rb +18 -22
- data/lib/cura/attributes/has_side_attributes.rb +18 -24
- data/lib/cura/attributes/has_windows.rb +13 -19
- data/lib/cura/borders.rb +0 -4
- data/lib/cura/color.rb +84 -91
- data/lib/cura/component/base.rb +29 -33
- data/lib/cura/component/button.rb +10 -16
- data/lib/cura/component/group.rb +14 -18
- data/lib/cura/component/label.rb +44 -48
- data/lib/cura/component/listbox.rb +24 -28
- data/lib/cura/component/pack.rb +14 -18
- data/lib/cura/component/scrollbar.rb +41 -45
- data/lib/cura/component/textbox.rb +21 -25
- data/lib/cura/cursor.rb +15 -23
- data/lib/cura/error/base.rb +0 -3
- data/lib/cura/error/invalid_adapter.rb +1 -7
- data/lib/cura/error/invalid_application.rb +1 -7
- data/lib/cura/error/invalid_color.rb +1 -7
- data/lib/cura/error/invalid_component.rb +1 -7
- data/lib/cura/error/invalid_middleware.rb +1 -7
- data/lib/cura/event.rb +4 -8
- data/lib/cura/event/base.rb +17 -24
- data/lib/cura/event/click.rb +1 -6
- data/lib/cura/event/dispatcher.rb +20 -26
- data/lib/cura/event/focus.rb +1 -6
- data/lib/cura/event/handler.rb +16 -24
- data/lib/cura/event/key_down.rb +11 -17
- data/lib/cura/event/middleware/aimer/base.rb +4 -10
- data/lib/cura/event/middleware/aimer/dispatcher_target.rb +2 -8
- data/lib/cura/event/middleware/aimer/mouse_focus.rb +6 -11
- data/lib/cura/event/middleware/aimer/target_option.rb +4 -10
- data/lib/cura/event/middleware/base.rb +0 -4
- data/lib/cura/event/middleware/dispatch.rb +0 -4
- data/lib/cura/event/middleware/translator/base.rb +4 -10
- data/lib/cura/event/middleware/translator/mouse_click.rb +4 -8
- data/lib/cura/event/mouse.rb +5 -11
- data/lib/cura/event/mouse_button.rb +21 -27
- data/lib/cura/event/mouse_wheel_down.rb +1 -6
- data/lib/cura/event/mouse_wheel_up.rb +1 -6
- data/lib/cura/event/resize.rb +0 -4
- data/lib/cura/event/selected.rb +1 -6
- data/lib/cura/event/unfocus.rb +1 -6
- data/lib/cura/focus_controller.rb +19 -23
- data/lib/cura/key.rb +277 -283
- data/lib/cura/margins.rb +0 -4
- data/lib/cura/offsets.rb +14 -18
- data/lib/cura/padding.rb +0 -4
- data/lib/cura/pencil.rb +3 -7
- data/lib/cura/version.rb +1 -3
- data/lib/cura/window.rb +11 -16
- data/spec/cura/attributes/has_ancestry_spec.rb +39 -39
- data/spec/cura/attributes/has_application_spec.rb +20 -20
- data/spec/cura/attributes/has_attributes_spec.rb +26 -26
- data/spec/cura/attributes/has_children_spec.rb +54 -54
- data/spec/cura/attributes/has_colors_spec.rb +4 -4
- data/spec/cura/attributes/has_coordinates_spec.rb +4 -4
- data/spec/cura/attributes/has_dimensions_spec.rb +4 -4
- data/spec/cura/attributes/has_events_spec.rb +4 -4
- data/spec/cura/attributes/has_focusability_spec.rb +18 -18
- data/spec/cura/attributes/has_offsets_spec.rb +4 -4
- data/spec/cura/attributes/has_orientation_spec.rb +38 -38
- data/spec/cura/attributes/has_relative_coordinates_spec.rb +4 -4
- data/spec/cura/attributes/has_side_attributes_spec.rb +4 -4
- data/spec/spec_helper.rb +1 -1
- data/spec/support/shared_examples_for_attributes.rb +41 -41
- metadata +1 -1
@@ -4,15 +4,15 @@ require "cura/attributes/has_initialize"
|
|
4
4
|
require "cura/attributes/has_offsets"
|
5
5
|
|
6
6
|
describe Cura::Attributes::HasOffsets 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::HasOffsets)
|
12
|
-
|
12
|
+
|
13
13
|
instance_class.new
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
pending
|
17
|
-
|
17
|
+
|
18
18
|
end
|
@@ -4,99 +4,99 @@ require "cura/attributes/has_initialize"
|
|
4
4
|
require "cura/attributes/has_orientation"
|
5
5
|
|
6
6
|
describe Cura::Attributes::HasOrientation do
|
7
|
-
|
7
|
+
|
8
8
|
let(:instance_class) do
|
9
9
|
instance_class = Class.new
|
10
10
|
instance_class.include(Cura::Attributes::HasInitialize)
|
11
11
|
instance_class.include(Cura::Attributes::HasOrientation)
|
12
|
-
|
12
|
+
|
13
13
|
instance_class
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
let(:instance) { instance_class.new }
|
17
|
-
|
17
|
+
|
18
18
|
describe "#orientation" do
|
19
|
-
|
19
|
+
|
20
20
|
it "should be initialized with the correct value" do
|
21
21
|
expect(instance.orientation).to eq(:vertical)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
describe "#orientation=" do
|
27
|
-
|
27
|
+
|
28
28
|
context "when a symbol is passed" do
|
29
|
-
|
29
|
+
|
30
30
|
context "and it is valid" do
|
31
|
-
|
31
|
+
|
32
32
|
it "should set the attribute correctly" do
|
33
33
|
instance.orientation = :horizontal
|
34
34
|
expect(instance.orientation).to eq(:horizontal)
|
35
|
-
|
35
|
+
|
36
36
|
instance.orientation = :vertical
|
37
37
|
expect(instance.orientation).to eq(:vertical)
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
context "and it is invalid" do
|
43
|
-
|
43
|
+
|
44
44
|
it "should raise an ArgumentError" do
|
45
45
|
expect { instance.orientation = :invalid_symbol }.to raise_error(ArgumentError)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
describe "#horizontal?" do
|
55
|
-
|
55
|
+
|
56
56
|
context "when the orientation is set to :vertical" do
|
57
|
-
|
57
|
+
|
58
58
|
let(:instance) { instance_class.new(orientation: :vertical) }
|
59
|
-
|
59
|
+
|
60
60
|
it "should return the correct value" do
|
61
61
|
expect(instance.horizontal?).to eq(false)
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
context "when the orientation is set to :horizontal" do
|
67
|
-
|
67
|
+
|
68
68
|
let(:instance) { instance_class.new(orientation: :horizontal) }
|
69
|
-
|
69
|
+
|
70
70
|
it "should return the correct value" do
|
71
71
|
expect(instance.horizontal?).to eq(true)
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
describe "#vertical?" do
|
79
|
-
|
79
|
+
|
80
80
|
context "when the orientation is set to :vertical" do
|
81
|
-
|
81
|
+
|
82
82
|
let(:instance) { instance_class.new(orientation: :vertical) }
|
83
|
-
|
83
|
+
|
84
84
|
it "should return the correct value" do
|
85
85
|
expect(instance.vertical?).to eq(true)
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
context "when the orientation is set to :horizontal" do
|
91
|
-
|
91
|
+
|
92
92
|
let(:instance) { instance_class.new(orientation: :horizontal) }
|
93
|
-
|
93
|
+
|
94
94
|
it "should return the correct value" do
|
95
95
|
expect(instance.vertical?).to eq(false)
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
end
|
@@ -4,15 +4,15 @@ require "cura/attributes/has_initialize"
|
|
4
4
|
require "cura/attributes/has_relative_coordinates"
|
5
5
|
|
6
6
|
describe Cura::Attributes::HasRelativeCoordinates 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::HasRelativeCoordinates)
|
12
|
-
|
12
|
+
|
13
13
|
instance_class.new
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
pending
|
17
|
-
|
17
|
+
|
18
18
|
end
|
@@ -5,15 +5,15 @@ require "cura/attributes/has_initialize"
|
|
5
5
|
require "cura/attributes/has_side_attributes"
|
6
6
|
|
7
7
|
describe Cura::Attributes::HasSideAttributes 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::HasSideAttributes)
|
13
|
-
|
13
|
+
|
14
14
|
instance_class.new
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it_should_behave_like "an object with size accessors", :top, :right, :bottom, :left
|
18
|
-
|
18
|
+
|
19
19
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,122 +1,122 @@
|
|
1
1
|
shared_examples "an object with integer accessors" do |*attributes|
|
2
2
|
options = attributes.last.is_a?(Hash) ? attributes.pop : {}
|
3
3
|
options = { default: 0 }.merge(options)
|
4
|
-
|
4
|
+
|
5
5
|
attributes.each do |attribute|
|
6
|
-
|
6
|
+
|
7
7
|
describe "##{attribute}" do
|
8
|
-
|
8
|
+
|
9
9
|
it "should be initialized with the correct value" do
|
10
10
|
expect(instance.send(attribute)).to eq(options[:default])
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "##{attribute}=" do
|
16
|
-
|
16
|
+
|
17
17
|
it "should set the attribute correctly" do
|
18
18
|
instance.send("#{attribute}=", 10)
|
19
19
|
expect(instance.send(attribute)).to eq(10)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should convert the value to an integer" do
|
23
23
|
instance.send("#{attribute}=", "10")
|
24
24
|
expect(instance.send(attribute)).to eq(10)
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
shared_examples "an object with size accessors" do |*attributes|
|
33
33
|
options = attributes.last.is_a?(Hash) ? attributes.pop : {}
|
34
34
|
options = { default: 0 }.merge(options)
|
35
|
-
|
35
|
+
|
36
36
|
attributes.each do |attribute|
|
37
|
-
|
37
|
+
|
38
38
|
it_should_behave_like "an object with integer accessors", attribute, options
|
39
|
-
|
39
|
+
|
40
40
|
describe "##{attribute}=" do
|
41
|
-
|
41
|
+
|
42
42
|
context "when a symbol is passed" do
|
43
|
-
|
43
|
+
|
44
44
|
context "and it is valid" do
|
45
|
-
|
45
|
+
|
46
46
|
it "should set the attribute correctly" do
|
47
47
|
instance.send("#{attribute}=", :inherit)
|
48
48
|
expect(instance.send(attribute)).to eq(:inherit)
|
49
|
-
|
49
|
+
|
50
50
|
instance.send("#{attribute}=", :auto)
|
51
51
|
expect(instance.send(attribute)).to eq(:auto)
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
context "and it is invalid" do
|
57
|
-
|
57
|
+
|
58
58
|
it "should raise an ArgumentError" do
|
59
59
|
expect { instance.send("#{attribute}=", :invalid_symbol) }.to raise_error(ArgumentError)
|
60
60
|
end
|
61
|
-
|
61
|
+
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
end
|
65
|
-
|
65
|
+
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
71
|
shared_examples "an object with color accessors" do |*attributes|
|
72
72
|
attributes.each do |attribute|
|
73
|
-
|
73
|
+
|
74
74
|
describe "##{attribute}" do
|
75
|
-
|
75
|
+
|
76
76
|
it "should be initialized with the correct value" do
|
77
77
|
expect(instance.send(attribute)).to eq(:inherit)
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
describe "##{attribute}=" do
|
83
|
-
|
83
|
+
|
84
84
|
context "when a Color is passed" do
|
85
|
-
|
85
|
+
|
86
86
|
before { instance.send("#{attribute}=", Cura::Color.red) }
|
87
|
-
|
87
|
+
|
88
88
|
it "should set the attribute correctly" do
|
89
89
|
expect(instance.send(attribute)).to eq(Cura::Color.red)
|
90
90
|
end
|
91
|
-
|
91
|
+
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
context "when a Symbol-like object is passed" do
|
95
|
-
|
95
|
+
|
96
96
|
context "and it is valid" do
|
97
|
-
|
97
|
+
|
98
98
|
it "should set the attribute correctly" do
|
99
99
|
instance.send("#{attribute}=", :inherit)
|
100
100
|
expect(instance.send(attribute)).to eq(:inherit)
|
101
|
-
|
101
|
+
|
102
102
|
instance.send("#{attribute}=", "inherit")
|
103
103
|
expect(instance.send(attribute)).to eq(:inherit)
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
context "and it is invalid" do
|
109
|
-
|
109
|
+
|
110
110
|
it "should set the attribute correctly" do
|
111
111
|
expect { instance.send("#{attribute}=", :invalid_symbol) }.to raise_error(Cura::Error::InvalidColor)
|
112
112
|
expect { instance.send("#{attribute}=", "invalid_symbol") }.to raise_error(Cura::Error::InvalidColor)
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
end
|
116
|
-
|
116
|
+
|
117
117
|
end
|
118
|
-
|
118
|
+
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
end
|
122
122
|
end
|