shoes-core 4.0.0.pre7 → 4.0.0.pre8

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.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/lib/shoes/arc.rb +10 -13
  3. data/lib/shoes/arrow.rb +1 -11
  4. data/lib/shoes/background.rb +0 -3
  5. data/lib/shoes/border.rb +0 -3
  6. data/lib/shoes/button.rb +4 -1
  7. data/lib/shoes/check_button.rb +0 -1
  8. data/lib/shoes/common/art_element.rb +21 -0
  9. data/lib/shoes/common/background_element.rb +10 -0
  10. data/lib/shoes/common/clickable.rb +2 -0
  11. data/lib/shoes/common/rotate.rb +1 -2
  12. data/lib/shoes/common/ui_element.rb +10 -1
  13. data/lib/shoes/core/version.rb +1 -1
  14. data/lib/shoes/download.rb +47 -29
  15. data/lib/shoes/dsl.rb +99 -40
  16. data/lib/shoes/font.rb +0 -4
  17. data/lib/shoes/http_request.rb +91 -0
  18. data/lib/shoes/image.rb +0 -1
  19. data/lib/shoes/input_box.rb +0 -1
  20. data/lib/shoes/internal_app.rb +1 -1
  21. data/lib/shoes/line.rb +25 -11
  22. data/lib/shoes/link.rb +10 -4
  23. data/lib/shoes/list_box.rb +0 -1
  24. data/lib/shoes/mock/app.rb +6 -0
  25. data/lib/shoes/mock/clickable.rb +3 -0
  26. data/lib/shoes/mock/font.rb +0 -4
  27. data/lib/shoes/oval.rb +3 -13
  28. data/lib/shoes/progress.rb +0 -1
  29. data/lib/shoes/rect.rb +1 -11
  30. data/lib/shoes/shape.rb +16 -8
  31. data/lib/shoes/slot.rb +2 -1
  32. data/lib/shoes/star.rb +8 -11
  33. data/lib/shoes/text_block.rb +0 -1
  34. data/lib/shoes/ui/picker.rb +29 -8
  35. data/lib/shoes/version.rb +1 -1
  36. metadata +8 -231
  37. data/Guardfile +0 -5
  38. data/Rakefile +0 -1
  39. data/bin/shoes-stub +0 -62
  40. data/ext/install/Rakefile +0 -39
  41. data/ext/install/shoes.bat +0 -17
  42. data/lib/rubygems_plugin.rb +0 -24
  43. data/shoes-core.gemspec +0 -22
  44. data/spec/shoes/animation_spec.rb +0 -71
  45. data/spec/shoes/app_spec.rb +0 -454
  46. data/spec/shoes/arc_spec.rb +0 -52
  47. data/spec/shoes/arrow_spec.rb +0 -28
  48. data/spec/shoes/background_spec.rb +0 -47
  49. data/spec/shoes/border_spec.rb +0 -46
  50. data/spec/shoes/builtin_methods_spec.rb +0 -122
  51. data/spec/shoes/button_spec.rb +0 -55
  52. data/spec/shoes/check_spec.rb +0 -36
  53. data/spec/shoes/color_spec.rb +0 -429
  54. data/spec/shoes/common/attachable_spec.rb +0 -32
  55. data/spec/shoes/common/inspect_spec.rb +0 -26
  56. data/spec/shoes/common/remove_spec.rb +0 -37
  57. data/spec/shoes/common/rotate_spec.rb +0 -13
  58. data/spec/shoes/common/style_normalizer_spec.rb +0 -28
  59. data/spec/shoes/common/style_spec.rb +0 -197
  60. data/spec/shoes/common/translate_spec.rb +0 -27
  61. data/spec/shoes/configuration_spec.rb +0 -51
  62. data/spec/shoes/constants_spec.rb +0 -39
  63. data/spec/shoes/dialog_spec.rb +0 -169
  64. data/spec/shoes/dimension_spec.rb +0 -451
  65. data/spec/shoes/dimensions_spec.rb +0 -868
  66. data/spec/shoes/download_spec.rb +0 -198
  67. data/spec/shoes/flow_spec.rb +0 -132
  68. data/spec/shoes/font_spec.rb +0 -36
  69. data/spec/shoes/framework_learning_spec.rb +0 -31
  70. data/spec/shoes/gradient_spec.rb +0 -31
  71. data/spec/shoes/helpers/fake_absolute_element.rb +0 -31
  72. data/spec/shoes/helpers/fake_element.rb +0 -25
  73. data/spec/shoes/helpers/inspect_helpers.rb +0 -5
  74. data/spec/shoes/helpers/sample17_helper.rb +0 -65
  75. data/spec/shoes/image_spec.rb +0 -69
  76. data/spec/shoes/images/shoe.jpg +0 -0
  77. data/spec/shoes/input_box_spec.rb +0 -80
  78. data/spec/shoes/integration_spec.rb +0 -19
  79. data/spec/shoes/internal_app_spec.rb +0 -148
  80. data/spec/shoes/keypress_spec.rb +0 -11
  81. data/spec/shoes/keyrelease_spec.rb +0 -11
  82. data/spec/shoes/line_spec.rb +0 -120
  83. data/spec/shoes/link_spec.rb +0 -149
  84. data/spec/shoes/list_box_spec.rb +0 -87
  85. data/spec/shoes/logger/ruby_spec.rb +0 -8
  86. data/spec/shoes/logger_spec.rb +0 -45
  87. data/spec/shoes/oval_spec.rb +0 -25
  88. data/spec/shoes/packager_spec.rb +0 -25
  89. data/spec/shoes/point_spec.rb +0 -99
  90. data/spec/shoes/progress_spec.rb +0 -54
  91. data/spec/shoes/radio_spec.rb +0 -32
  92. data/spec/shoes/rect_spec.rb +0 -40
  93. data/spec/shoes/renamed_delegate_spec.rb +0 -69
  94. data/spec/shoes/shape_spec.rb +0 -119
  95. data/spec/shoes/shared_examples/button.rb +0 -6
  96. data/spec/shoes/shared_examples/changeable.rb +0 -26
  97. data/spec/shoes/shared_examples/clickable.rb +0 -5
  98. data/spec/shoes/shared_examples/common_methods.rb +0 -35
  99. data/spec/shoes/shared_examples/dimensions.rb +0 -32
  100. data/spec/shoes/shared_examples/dsl.rb +0 -44
  101. data/spec/shoes/shared_examples/dsl/animate.rb +0 -29
  102. data/spec/shoes/shared_examples/dsl/arc.rb +0 -45
  103. data/spec/shoes/shared_examples/dsl/background.rb +0 -26
  104. data/spec/shoes/shared_examples/dsl/border.rb +0 -10
  105. data/spec/shoes/shared_examples/dsl/button.rb +0 -5
  106. data/spec/shoes/shared_examples/dsl/cap.rb +0 -6
  107. data/spec/shoes/shared_examples/dsl/check.rb +0 -11
  108. data/spec/shoes/shared_examples/dsl/edit_box.rb +0 -8
  109. data/spec/shoes/shared_examples/dsl/edit_line.rb +0 -8
  110. data/spec/shoes/shared_examples/dsl/editable_element.rb +0 -29
  111. data/spec/shoes/shared_examples/dsl/fill.rb +0 -27
  112. data/spec/shoes/shared_examples/dsl/flow.rb +0 -15
  113. data/spec/shoes/shared_examples/dsl/gradient.rb +0 -62
  114. data/spec/shoes/shared_examples/dsl/image.rb +0 -21
  115. data/spec/shoes/shared_examples/dsl/line.rb +0 -9
  116. data/spec/shoes/shared_examples/dsl/nofill.rb +0 -6
  117. data/spec/shoes/shared_examples/dsl/nostroke.rb +0 -6
  118. data/spec/shoes/shared_examples/dsl/oval.rb +0 -88
  119. data/spec/shoes/shared_examples/dsl/pattern.rb +0 -34
  120. data/spec/shoes/shared_examples/dsl/progress.rb +0 -7
  121. data/spec/shoes/shared_examples/dsl/rect.rb +0 -92
  122. data/spec/shoes/shared_examples/dsl/rgb.rb +0 -28
  123. data/spec/shoes/shared_examples/dsl/shape.rb +0 -61
  124. data/spec/shoes/shared_examples/dsl/star.rb +0 -110
  125. data/spec/shoes/shared_examples/dsl/stroke.rb +0 -30
  126. data/spec/shoes/shared_examples/dsl/strokewidth.rb +0 -19
  127. data/spec/shoes/shared_examples/dsl/style.rb +0 -32
  128. data/spec/shoes/shared_examples/dsl/text_elements.rb +0 -84
  129. data/spec/shoes/shared_examples/dsl/video.rb +0 -5
  130. data/spec/shoes/shared_examples/dsl_app_context.rb +0 -11
  131. data/spec/shoes/shared_examples/hover.rb +0 -78
  132. data/spec/shoes/shared_examples/parent.rb +0 -6
  133. data/spec/shoes/shared_examples/scroll.rb +0 -41
  134. data/spec/shoes/shared_examples/shared_element_method.rb +0 -60
  135. data/spec/shoes/shared_examples/slot.rb +0 -441
  136. data/spec/shoes/shared_examples/state.rb +0 -26
  137. data/spec/shoes/shared_examples/style.rb +0 -77
  138. data/spec/shoes/slot_spec.rb +0 -176
  139. data/spec/shoes/sound_spec.rb +0 -16
  140. data/spec/shoes/span_spec.rb +0 -112
  141. data/spec/shoes/spec_helper.rb +0 -24
  142. data/spec/shoes/stack_spec.rb +0 -79
  143. data/spec/shoes/star_spec.rb +0 -49
  144. data/spec/shoes/text_block_dimensions_spec.rb +0 -77
  145. data/spec/shoes/text_block_spec.rb +0 -314
  146. data/spec/shoes/text_spec.rb +0 -22
  147. data/spec/shoes/ui/picker_spec.rb +0 -69
  148. data/spec/shoes/url_spec.rb +0 -67
  149. data/spec/shoes/widget_spec.rb +0 -78
  150. data/spec/shoes_spec.rb +0 -41
  151. data/spec/spec_helper.rb +0 -27
@@ -1,198 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Download do
4
- include_context "dsl app"
5
-
6
- let(:name) { "http://www.google.com/logos/nasa50th.gif" }
7
- let(:response_body) { "NASA 50th logo" }
8
- let(:response_status) { ["200", "OK"] }
9
- let(:response_headers) { { "content-length" => "42" } }
10
- let(:opts) { {save: "nasa50th.gif"} }
11
-
12
- subject(:download) { Shoes::Download.new app, parent, name, opts, &input_block }
13
-
14
- let(:percent) { download.percent }
15
- let(:length) { download.length }
16
- let(:content_length) { download.content_length }
17
-
18
- before do
19
- expect(app.current_slot).to receive(:create_bound_block).at_least(1) { |blk| blk ? blk : nil }
20
-
21
- stub_request(:get, name)
22
- .to_return(status: response_status, body: response_body, headers: response_headers)
23
- end
24
-
25
- after do
26
- File.delete opts[:save] if File.exist? opts[:save]
27
- end
28
-
29
- context 'before it has been started' do
30
- it 'is 0 percent' do
31
- expect(percent).to eq(0)
32
- end
33
-
34
- it 'understands abort' do
35
- expect(download).to respond_to(:abort)
36
- end
37
-
38
- it 'has initial content_length of 1' do
39
- expect(content_length).to eq(1)
40
- end
41
-
42
- it 'has initial length of 1' do
43
- expect(length).to eq(1)
44
- end
45
- end
46
-
47
- context 'without a progress proc' do
48
- before :each do
49
- download.start
50
- download.join_thread
51
- end
52
-
53
- it 'finishes' do
54
- expect(download).to be_finished
55
- end
56
-
57
- it 'starts' do
58
- expect(download).to be_started
59
- end
60
-
61
- it 'creates the file specified by save' do
62
- expect(File.exist?(opts[:save])).to be_truthy
63
- end
64
- end
65
-
66
- context 'with a progress proc' do
67
- let(:progress_proc) { proc {} }
68
- let(:opts) { {save: "nasa50th.gif", progress: progress_proc} }
69
- subject(:download) { Shoes::Download.new app, parent, name, opts }
70
-
71
- before :each do
72
- allow(download.gui).to receive :eval_block
73
- download.start
74
- download.join_thread
75
- end
76
-
77
- context 'with content length' do
78
- it 'calls the progress proc from start, download and finish' do
79
- expect(download.gui).to have_received(:eval_block)
80
- .with(progress_proc, download)
81
- .exactly(3).times
82
- end
83
- end
84
-
85
- context 'without content length' do
86
- let(:response_headers) { Hash.new }
87
-
88
- it 'does not call on progress, but called from content length and finish' do
89
- expect(download.gui).to have_received(:eval_block)
90
- .with(progress_proc, download)
91
- .twice
92
- end
93
-
94
- it 'can call percent just fine thanks' do
95
- expect(download.percent).to eq(0)
96
- end
97
- end
98
- end
99
-
100
- describe 'after it is finished' do
101
- let(:result) { download }
102
- let(:response) { download.response }
103
-
104
- before :each do
105
- allow(download.gui).to receive(:eval_block)
106
- download.start
107
- download.join_thread
108
- end
109
-
110
- context 'with a block' do
111
- it 'calls the block with a result' do
112
- expect(download.gui).to have_received(:eval_block).with(input_block, result)
113
- end
114
-
115
- describe 'response object' do
116
- it 'has headers hash' do
117
- expect(response.headers).to eql(response_headers)
118
- end
119
-
120
- it 'has body text' do
121
- expect(response.body).to eql(response_body)
122
- end
123
-
124
- it 'has status array' do
125
- expect(response.status).to eql(response_status)
126
- end
127
- end
128
- end
129
-
130
- context 'without a block' do
131
- subject(:download) { Shoes::Download.new app, parent, name, opts }
132
-
133
- it 'does not call the block' do
134
- expect(download.gui).not_to have_received(:eval_block)
135
- end
136
- end
137
-
138
- context 'with a finish proc' do
139
- let(:finish_proc) { proc {} }
140
- let(:opts) { {save: "nasa50th.gif", finish: finish_proc} }
141
- subject(:download) { Shoes::Download.new app, parent, name, opts }
142
-
143
- it 'calls the finish proc' do
144
- expect(download.gui).to have_received(:eval_block).with(finish_proc, subject)
145
- end
146
- end
147
- end
148
-
149
- describe 'when things go wrong' do
150
- it 'reports back to the parent thread' do
151
- error = StandardError.new("Nope")
152
-
153
- expect(download.gui).to receive(:eval_block).with(anything, error)
154
- allow(download).to receive(:open).and_raise(error)
155
-
156
- download.start
157
- download.join_thread
158
- end
159
-
160
- it 'reports empty values for the response' do
161
- error = StandardError.new("Nope")
162
- allow(download).to receive(:open).and_raise(error)
163
-
164
- download.start
165
- download.join_thread
166
-
167
- expect(download.response.body).to be_empty
168
- expect(download.response.headers).to be_empty
169
- expect(download.response.status).to be_empty
170
- end
171
-
172
- it 'does not die on socket errors, but logs them' do
173
- error = SocketError.new('Badumz')
174
-
175
- expect(download.gui).not_to receive(:eval_block)
176
- expect(Shoes.logger).to receive(:error).with error
177
- allow(download).to receive(:open).and_raise(error)
178
-
179
- download.start
180
- download.join_thread
181
- end
182
-
183
- describe 'with custom error blocks' do
184
- let(:error_proc) { proc {} }
185
- let(:opts) { {save: "nasa50th.gif", error: error_proc} }
186
-
187
- it 'gets called' do
188
- error = StandardError.new("Nope")
189
-
190
- expect(download.gui).to receive(:eval_block).with(error_proc, error)
191
- allow(download).to receive(:open).and_raise(error)
192
-
193
- download.start
194
- download.join_thread
195
- end
196
- end
197
- end
198
- end
@@ -1,132 +0,0 @@
1
- require 'spec_helper'
2
- require 'shoes/helpers/fake_element'
3
-
4
- describe Shoes::Flow do
5
- include_context "dsl app"
6
-
7
- subject(:flow) { Shoes::Flow.new(app, parent, input_opts, input_block) }
8
-
9
- it_behaves_like "clickable object"
10
- it_behaves_like "Slot"
11
- it_behaves_like "object with hover"
12
-
13
- describe "initialize" do
14
- let(:input_opts) { {width: 131, height: 137} }
15
- it "sets accessors" do
16
- expect(flow.parent).to eq(parent)
17
- expect(flow.width).to eq(131)
18
- expect(flow.height).to eq(137)
19
- expect(flow.blk).to eq(input_block)
20
- end
21
-
22
- describe 'margins' do
23
- let(:input_opts) { {margin: 143} }
24
- it 'sets the margins' do
25
- expect(flow.margin).to eq([143, 143, 143, 143])
26
- end
27
- end
28
- end
29
-
30
- it "sets default values" do
31
- f = Shoes::Flow.new(app, parent)
32
- expect(f.width).to eq(app.width)
33
- expect(f.height).to eq(0)
34
- end
35
-
36
- it "clears with an optional block" do
37
- expect(flow).to receive(:clear) do |&blk|
38
- expect(blk).to eq(input_block)
39
- end
40
- flow.clear(&input_block)
41
- end
42
-
43
- describe "positioning" do
44
- it_behaves_like 'positioning through :_position'
45
- it_behaves_like 'positions the first element in the top left'
46
-
47
- shared_examples_for 'positioning in the same line' do
48
- it 'positions an element in the same row as long as they fit' do
49
- expect(element2.absolute_top).to eq(flow.absolute_top)
50
- end
51
-
52
- it 'positions it next to the other element as long as it fits' do
53
- expect(element2.absolute_left).to eq(element.absolute_right + 1)
54
- end
55
-
56
- it 'has a slot height of the maximum value of the 2 elements' do
57
- expect(flow.height).to eq([element.height, element2.height].max)
58
- end
59
- end
60
-
61
- describe 'two elements added' do
62
- include_context 'two slot children'
63
- include_context 'contents_alignment'
64
-
65
- it_behaves_like 'positioning in the same line'
66
-
67
- describe 'exact fit' do
68
- let(:input_opts) { {width: element.width + element2.width} }
69
- it_behaves_like 'positioning in the same line'
70
- end
71
- end
72
-
73
- describe 'when the elements dont fit next to each other' do
74
- let(:input_opts) { {width: element.width + element2.width - 10} }
75
- it_behaves_like 'arranges elements underneath each other'
76
-
77
- describe 'and a third element that goes into the second line' do
78
- include_context 'three slot children'
79
- include_context 'contents_alignment'
80
-
81
- it 'positions the third element right next to the second' do
82
- expect(element3.absolute_left).to eq element2.absolute_right + 1
83
- end
84
-
85
- it 'positions the third element on the same height as element 2' do
86
- expect(element3.absolute_top).to eq element2.absolute_top
87
- end
88
- end
89
- end
90
-
91
- describe 'elements dont fit next to each other and set small height' do
92
- let(:input_opts) { {width: element.width + 10, height: element.height + 10} }
93
- it_behaves_like 'set height and contents alignment'
94
- end
95
-
96
- describe 'elements dont fit next to each other and set big height' do
97
- let(:input_opts) { { width: element.width + 10, height: 1000 } }
98
- it_behaves_like 'set height and contents alignment'
99
- end
100
-
101
- describe 'with margins and two elements not fitting next to each other' do
102
- let(:input_opts) { { width: element.width + 10, margin: 27 } }
103
- it_behaves_like 'taking care of margin'
104
- end
105
- end
106
-
107
- describe 'scrolling' do
108
- include_context "scroll"
109
- subject(:flow) { Shoes::Flow.new(app, parent, opts) }
110
-
111
- context 'when scrollable' do
112
- let(:scroll) { true }
113
-
114
- it_behaves_like "scrollable slot"
115
-
116
- context 'when content overflows' do
117
- include_context "overflowing content"
118
- it_behaves_like "scrollable slot with overflowing content"
119
- end
120
- end
121
-
122
- context 'when slot is not scrollable' do
123
- let(:scroll) { false }
124
-
125
- its(:scroll) { should be_falsey }
126
-
127
- it "initializes scroll_top to 0" do
128
- expect(flow.scroll_top).to eq(0)
129
- end
130
- end
131
- end
132
- end
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- main_object = self
4
-
5
- describe Shoes::Font do
6
- describe 'font method on the main object' do
7
- it 'returns the name of the font loaded' do
8
- result = main_object.font(Shoes::FONT_DIR + "Coolvetica" + '.ttf')
9
- expect(result).to eq 'Coolvetica'
10
- end
11
-
12
- it 'calls the backend add_font method' do
13
- expect(Shoes.backend::Font).to receive :add_font
14
- main_object.font 'some/path'
15
- end
16
- end
17
-
18
- describe '.font_paths_from_dir' do
19
- it 'returns an array of the paths of the fonts in the directory' do
20
- result = Shoes::Font.font_paths_from_dir(Shoes::FONT_DIR)
21
-
22
- expect(result).to include(Shoes::FONT_DIR + 'Coolvetica.ttf',
23
- Shoes::FONT_DIR + 'Lacuna.ttf')
24
- end
25
-
26
- it 'handles sub directories' do
27
- tmp_font_dir = Shoes::FONT_DIR + 'tmp/'
28
- Dir.mkdir(tmp_font_dir)
29
- tmp_font_path = tmp_font_dir + 'weird_font.ttf'
30
- FileUtils.touch tmp_font_path
31
- result = Shoes::Font.font_paths_from_dir(Shoes::FONT_DIR)
32
- expect(result).to include tmp_font_path
33
- FileUtils.rm_r tmp_font_dir
34
- end
35
- end
36
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Learning
4
- class App
5
- attr_accessor :gui
6
-
7
- def initialize
8
- @gui = gui_init
9
- end
10
- end
11
- end
12
-
13
- module TextPlugin
14
- module App
15
- def gui_init
16
- "Peter"
17
- end
18
- end
19
- end
20
-
21
- module Learning
22
- class App
23
- include TextPlugin::App
24
- end
25
- end
26
-
27
- describe "A Shoes Framework" do
28
- it "should include Framework Plugins" do
29
- expect(Learning::App.new.gui).to eq("Peter")
30
- end
31
- end
@@ -1,31 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Gradient do
4
- let(:color1) { Shoes::COLORS[:honeydew] }
5
- let(:color2) { Shoes::COLORS[:salmon] }
6
- subject { Shoes::Gradient.new(color1, color2) }
7
-
8
- describe "comparable" do
9
- let(:new_color) { Shoes::COLORS[:limegreen] }
10
-
11
- it "is equal when values are equal" do
12
- gradient2 = Shoes::Gradient.new(color1, color2)
13
- expect(subject).to eq(gradient2)
14
- end
15
-
16
- it "is not equal when color 1 is different" do
17
- gradient2 = Shoes::Gradient.new(new_color, color2)
18
- expect(subject).not_to eq(gradient2)
19
- end
20
-
21
- it "is not equal when color 2 is different" do
22
- gradient2 = Shoes::Gradient.new(new_color, color2)
23
- expect(subject).not_to eq(gradient2)
24
- end
25
-
26
- it "is not equal to just a color" do
27
- gradient2 = Shoes::Gradient.new(color1, new_color)
28
- expect(subject).not_to eq(gradient2)
29
- end
30
- end
31
- end
@@ -1,31 +0,0 @@
1
- class Shoes
2
- class FakeAbsoluteElement
3
- include Common::Attachable
4
- include Common::Inspect
5
- include Common::Positioning
6
- include Common::Remove
7
- include Common::Visibility
8
-
9
- include Shoes::DimensionsDelegations
10
-
11
- def initialize
12
- @dimensions = AbsoluteDimensions.new 0, 0, 100, 100
13
- end
14
-
15
- def add_child(_element)
16
- true
17
- end
18
-
19
- def adjust_current_position(*_)
20
- end
21
-
22
- # Fake this out instead of using Common::Style to avoid things like touching
23
- # app level styles, etc. that we don't need for testing purposes
24
- def style
25
- @style ||= {}
26
- @style
27
- end
28
-
29
- attr_accessor :dimensions, :parent, :gui
30
- end
31
- end