shoes-core 4.0.0.pre7 → 4.0.0.pre8

Sign up to get free protection for your applications and to get access to all the features.
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,25 +0,0 @@
1
- class Shoes
2
- class FakeElement < Dimensions
3
- include Common::Attachable
4
- include Common::Inspect
5
- include Common::Positioning
6
- include Common::Remove
7
- include Common::Visibility
8
-
9
- def add_child(_element)
10
- true
11
- end
12
-
13
- def adjust_current_position(*_)
14
- end
15
-
16
- # Fake this out instead of using Common::Style to avoid things like touching
17
- # app level styles, etc. that we don't need for testing purposes
18
- def style
19
- @style ||= {}
20
- @style
21
- end
22
-
23
- attr_accessor :parent, :gui
24
- end
25
- end
@@ -1,5 +0,0 @@
1
- module InspectHelpers
2
- def shoes_object_id_pattern
3
- '0x[0-9a-f]{8}'
4
- end
5
- end
@@ -1,65 +0,0 @@
1
- # Emulates samples/sample17.rb
2
- #
3
- # Shoes.app width: 240, height: 95 do
4
- # para 'Testing, test, test. ',
5
- # strong('Breadsticks. '),
6
- # em('Breadsticks. '),
7
- # code('Breadsticks. '),
8
- # bg(fg(strong(ins('EVEN BETTER.')), white), rgb(255, 0, 192)),
9
- # sub('fine!')
10
- # end
11
- #
12
- class Sample17Helper
13
- def initialize(app)
14
- # This gives us the Shoes::App
15
- @app = app.app
16
- end
17
-
18
- def create_para
19
- @app.para("Testing, test, test. ", strong_breadsticks, em, code, bg, sub)
20
- end
21
-
22
- def breadsticks
23
- "Breadsticks. "
24
- end
25
-
26
- def even_better
27
- "EVEN BETTER."
28
- end
29
-
30
- def fine
31
- "fine!"
32
- end
33
-
34
- def strong_breadsticks
35
- @strong_breadsticks ||= @app.strong breadsticks
36
- end
37
-
38
- def em
39
- @em ||= @app.em breadsticks
40
- end
41
-
42
- def code
43
- @code ||= @app.code breadsticks
44
- end
45
-
46
- def ins
47
- @ins ||= @app.ins even_better
48
- end
49
-
50
- def fg
51
- @fg ||= @app.fg strong, Shoes::COLORS[:white]
52
- end
53
-
54
- def strong
55
- @strong ||= @app.strong ins
56
- end
57
-
58
- def bg
59
- @bg ||= @app.bg fg, Shoes::Color.new(255, 0, 192)
60
- end
61
-
62
- def sub
63
- @sub ||= @app.sub fine
64
- end
65
- end
@@ -1,69 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Image do
4
- include_context "dsl app"
5
-
6
- describe "basic" do
7
- let(:left) { 10 }
8
- let(:top) { 20 }
9
- let(:width) { 100 }
10
- let(:height) { 200 }
11
-
12
- let(:filename) { File.expand_path "../../../static/shoes-icon.png", __FILE__ }
13
- let(:updated_filename) { File.expand_path "../../../static/shoes-icon-brown.png", __FILE__ }
14
-
15
- subject(:image) { Shoes::Image.new(app, parent, filename, left: left, top: top, width: width, height: height) }
16
-
17
- it { is_expected.to be_instance_of(Shoes::Image) }
18
-
19
- it "should update image path" do
20
- subject.path = updated_filename
21
- expect(subject.path).to eq(updated_filename)
22
- end
23
-
24
- it_behaves_like "movable object"
25
- it_behaves_like "object with dimensions"
26
- it_behaves_like "object with hover"
27
-
28
- it_behaves_like "object with style" do
29
- let(:subject_without_style) { Shoes::Image.new(app, parent, filename) }
30
- let(:subject_with_style) { Shoes::Image.new(app, parent, filename, arg_styles) }
31
- end
32
-
33
- describe "relative dimensions from parent" do
34
- subject { Shoes::Image.new(app, parent, filename, relative_opts) }
35
- it_behaves_like "object with relative dimensions"
36
- end
37
-
38
- describe "negative dimensions" do
39
- subject { Shoes::Image.new(app, parent, filename, negative_opts) }
40
- it_behaves_like "object with negative dimensions"
41
- end
42
- end
43
-
44
- describe 'file source' do
45
- subject { Shoes::Image.new(app, parent, filename, input_opts) }
46
-
47
- context 'invalid path' do
48
- let(:filename) { 'something_crazy' }
49
- it 'should raise an error' do
50
- expect { subject }.to raise_error Shoes::FileNotFoundError
51
- end
52
- end
53
-
54
- context 'absolute path' do
55
- let(:filename) { File.expand_path "../../../static/shoes-icon.png", __FILE__ }
56
- its(:file_path) { should eq filename }
57
- end
58
-
59
- context 'relative path' do
60
- let(:filename) { 'shoes-core/static/shoes-icon.png' }
61
- its(:file_path) { should eq "#{Dir.pwd}/#{filename}" }
62
- end
63
-
64
- describe 'accepts web URL' do
65
- let(:filename) { "http://is.gd/GVAGF7" }
66
- its(:file_path) { should eq("http://is.gd/GVAGF7") }
67
- end
68
- end
69
- end
Binary file
@@ -1,80 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::InputBox do
4
- include_context "dsl app"
5
- let(:input_opts) { {left: left, top: top, width: width, height: height} }
6
- let(:left) { 10 }
7
- let(:top) { 20 }
8
- let(:width) { 100 }
9
- let(:height) { 200 }
10
- let(:text) { "the text" }
11
-
12
- # EditBox is an InputBox but InputBox is never instantiated itself
13
- # And there are problems in the backend due to option settings
14
- subject { Shoes::EditBox.new(app, parent, text, input_opts, input_block) }
15
-
16
- it_behaves_like "object with dimensions"
17
-
18
- it_behaves_like "object with style" do
19
- let(:subject_without_style) { Shoes::EditBox.new(app, parent, text) }
20
- let(:subject_with_style) { Shoes::EditBox.new(app, parent, text, arg_styles) }
21
- end
22
-
23
- it_behaves_like "movable object"
24
- it_behaves_like "an element that can respond to change"
25
- it_behaves_like "object with state"
26
-
27
- it { is_expected.to respond_to :focus }
28
- it { is_expected.to respond_to :text }
29
- it { is_expected.to respond_to :text= }
30
-
31
- it 'forwards calls to highlight_text to the backend' do
32
- expect(subject.gui).to receive(:highlight_text).with(4, 20)
33
- subject.highlight_text 4, 20
34
- end
35
-
36
- it 'forwards calls to caret_to to the backend' do
37
- expect(subject.gui).to receive(:caret_to).with(42)
38
- subject.caret_to 42
39
- end
40
-
41
- describe 'non string text' do
42
- let(:text) { 42 }
43
-
44
- it 'is converted to a string (convenience + error in backend)' do
45
- expect(subject.text).to eq '42'
46
- end
47
- end
48
-
49
- describe "relative dimensions from parent" do
50
- subject { Shoes::EditBox.new(app, parent, text, relative_opts) }
51
- it_behaves_like "object with relative dimensions"
52
- end
53
-
54
- describe "negative dimensions" do
55
- subject { Shoes::EditBox.new(app, parent, text, negative_opts) }
56
- it_behaves_like "object with negative dimensions"
57
- end
58
-
59
- describe Shoes::EditLine do
60
- describe "secret" do
61
- subject { Shoes::EditLine.new(app, parent, text, secret: true, state: 'disabled') }
62
-
63
- it "gets initialized" do
64
- expect(subject.secret).to eq(true)
65
- expect(subject.secret?).to eq(true)
66
- end
67
-
68
- it "respects setting" do
69
- subject.secret = false
70
- expect(subject.secret).to eq(false)
71
- expect(subject.secret?).to eq(false)
72
- end
73
-
74
- it_behaves_like "object with style" do
75
- let(:subject_without_style) { Shoes::EditLine.new(app, parent, text) }
76
- let(:subject_with_style) { Shoes::EditLine.new(app, parent, text, arg_styles) }
77
- end
78
- end
79
- end
80
- end
@@ -1,19 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # also for stuff that is hard/brittle to test in isolation
4
- describe 'Integration specs' do
5
- describe 'hover & leave' do
6
- # that #hover and #leave are called with @__app__.current_slot is hard to
7
- # test since therefore there needs to be a current slot which is only during
8
- # block execution, stubbing it seems fairly brittle and dependent on
9
- # internal structure, see #603
10
- it 'does not raise an error' do
11
- expect do
12
- Shoes.app do
13
- hover {}
14
- leave {}
15
- end
16
- end.not_to raise_error
17
- end
18
- end
19
- end
@@ -1,148 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::InternalApp do
4
- include_context "dsl app"
5
-
6
- subject { app }
7
-
8
- describe "#initialize" do
9
- context "with defaults" do
10
- let(:defaults) { Shoes::InternalApp::DEFAULT_OPTIONS }
11
-
12
- it "sets title", :qt do
13
- expect(subject.app_title).to eq defaults[:title]
14
- end
15
-
16
- it "is resizable", :qt do
17
- expect(subject.resizable).to be_truthy
18
- end
19
-
20
- it "sets width" do
21
- expect(subject.width).to eq(defaults[:width])
22
- end
23
-
24
- it "sets height" do
25
- expect(subject.height).to eq(defaults[:height])
26
- end
27
-
28
- it "does not start as fullscreen" do
29
- expect(subject.start_as_fullscreen?).to be_falsey
30
- end
31
- end
32
-
33
- context "with custom opts" do
34
- let(:input_opts) { {width: 150, height: 2, title: "Shoes::App Spec", resizable: false} }
35
-
36
- it "sets title", :qt do
37
- expect(subject.app_title).to eq input_opts[:title]
38
- end
39
-
40
- it "sets resizable", :qt do
41
- expect(subject.resizable).to be_falsey
42
- end
43
-
44
- it "sets width" do
45
- expect(subject.width).to eq(input_opts[:width])
46
- end
47
-
48
- it "sets height" do
49
- expect(subject.height).to eq(input_opts[:height])
50
- end
51
- end
52
- end
53
-
54
- describe 'fullscreen' do
55
- let(:input_opts) { {fullscreen: true} }
56
-
57
- it "sets fullscreen", :fullscreen do
58
- expect(subject.start_as_fullscreen?).to be_truthy
59
- end
60
- end
61
-
62
- describe '#contents' do
63
- it 'delegates to top_slot' do
64
- expect(subject.contents).to be(subject.top_slot.contents)
65
- end
66
- end
67
-
68
- describe '#inspect' do
69
- let(:input_opts) { {title: 'Dupa'} }
70
-
71
- it 'shows the title in inspect' do
72
- expect(subject.inspect).to include 'Dupa'
73
- end
74
- end
75
-
76
- describe '#clear' do
77
- context 'when called after the initial input block' do
78
- let(:input_block) do
79
- proc do
80
- para "CONTENT"
81
- para "JUST FOR TESTING"
82
- end
83
- end
84
-
85
- before :each do
86
- expect(subject.contents.size).to eq(2)
87
- end
88
-
89
- it 'clears top_slot' do
90
- subject.clear
91
- expect(subject.contents).to be_empty
92
- end
93
- end
94
-
95
- context 'when called in the initial input_block' do
96
- let(:input_block) do
97
- proc do
98
- para 'Hello there'
99
- clear do
100
- para 'see you'
101
- end
102
- end
103
- end
104
-
105
- it 'does not raise an error' do
106
- expect { subject }.not_to raise_error
107
- end
108
-
109
- context 'when called inside a slot' do
110
- let(:input_block) do
111
- proc do
112
- button 'I am here'
113
- stack do
114
- button 'Hi there'
115
- button 'Another one'
116
- clear
117
- end
118
- end
119
- end
120
-
121
- it 'does not delete the slot, or an element outside the slot' do
122
- expect(subject.contents.size).to eq 2
123
- end
124
- end
125
- end
126
-
127
- context 'when called before a button in an initial input block' do
128
- let(:input_block) do
129
- proc do
130
- clear
131
- button 'My Button'
132
- end
133
- end
134
-
135
- it 'allows a button to be created' do
136
- expect(subject.contents.size).to eq(1)
137
- end
138
-
139
- describe 'the button' do
140
- let(:button) { subject.contents.first }
141
-
142
- it 'has the top_slot as its parent' do
143
- expect(button.parent).to eq subject.top_slot
144
- end
145
- end
146
- end
147
- end
148
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Keypress do
4
- include_context "dsl app"
5
-
6
- subject(:keypress) { Shoes::Keypress.new app, &input_block }
7
-
8
- it "should clear" do
9
- expect(keypress).to respond_to(:remove)
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Keyrelease do
4
- include_context "dsl app"
5
-
6
- subject(:keyrelease) { Shoes::Keyrelease.new app, &input_block }
7
-
8
- it "should clear" do
9
- expect(keyrelease).to respond_to(:remove)
10
- end
11
- end