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,32 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Common::Attachable do
4
- include_context "dsl app"
5
-
6
- subject do
7
- Class.new do
8
- include Shoes::Common::Attachable
9
-
10
- attr_reader :style
11
-
12
- def initialize(app, attached_to)
13
- @app = app
14
- @style = { attach: attached_to }
15
- end
16
- end
17
- end
18
-
19
- let(:slot) { double('slot') }
20
-
21
- it "isn't attached" do
22
- expect(subject.new(app, nil).attached_to).to eq(nil)
23
- end
24
-
25
- it "attaches" do
26
- expect(subject.new(app, slot).attached_to).to eq(slot)
27
- end
28
-
29
- it "attaches to Shoes::Window" do
30
- expect(subject.new(app, Shoes::Window).attached_to).to eq(app.top_slot)
31
- end
32
- end
@@ -1,26 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "Shoes::Common::Inspect" do
4
- let(:test_class) do
5
- Class.new do
6
- include Shoes::Common::Inspect
7
- def self.name
8
- "Shoes::InspectableObject"
9
- end
10
- end
11
- end
12
-
13
- describe "when included" do
14
- include InspectHelpers
15
-
16
- subject(:object) { test_class.new }
17
-
18
- it "gives a #to_s like (Shoes::Klass)" do
19
- expect(object.to_s).to eq("(Shoes::InspectableObject)")
20
- end
21
-
22
- it "gives an #inspect like (Shoes::Klass:0x000049e8)" do
23
- expect(object.inspect).to match(/^[(]Shoes::InspectableObject:#{shoes_object_id_pattern}[)]$/)
24
- end
25
- end
26
- end
@@ -1,37 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Common::Remove do
4
- let(:parent) { double 'parent', add_child: true, remove_child: true }
5
- let(:gui) { double 'gui', remove: true }
6
- let(:test_class) { Class.new { include Shoes::Common::Remove } }
7
-
8
- subject { test_class.new }
9
-
10
- before :each do
11
- allow(subject).to receive_messages parent: parent, gui: gui
12
- end
13
-
14
- describe '#remove' do
15
- before :each do
16
- subject.remove
17
- end
18
-
19
- it 'calls removes itself from the parent' do
20
- expect(parent).to have_received(:remove_child).with(subject)
21
- end
22
-
23
- it 'calls remove on the gui' do
24
- expect(gui).to have_received(:remove)
25
- end
26
-
27
- describe 'if the gui does not respond to clear' do
28
- # need to stub clear and respond_to because we get a non stubbed method
29
- # otherwise on our spies when verifying...
30
- let(:gui) { double 'no clear gui', clear: true, respond_to?: false }
31
-
32
- it 'does not call clear on the gui' do
33
- expect(gui).not_to have_received(:clear)
34
- end
35
- end
36
- end
37
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Common::Rotate do
4
- let(:test_class) { Class.new { include Shoes::Common::Rotate } }
5
-
6
- subject { test_class.new }
7
-
8
- describe '#needs_rotate?' do
9
- it 'defaults to falsey value' do
10
- expect(subject.needs_rotate?).to be_falsey
11
- end
12
- end
13
- end
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Common::StyleNormalizer do
4
- subject { Shoes::Common::StyleNormalizer.new }
5
-
6
- it 'does not modify a simple hash' do
7
- input = {left: 100, width: 233}
8
- expect(subject.normalize(input)).to eq input
9
- end
10
-
11
- it 'turns hexcodes for fill into colors' do
12
- input = {fill: 'ffffff'}
13
- expected = {fill: Shoes::Color.new(255, 255, 255)}
14
- expect(subject.normalize(input)).to eq expected
15
- end
16
-
17
- it 'turns hexcodes for stroke into colors' do
18
- input = {stroke: 'ffffff'}
19
- expected = {stroke: Shoes::Color.new(255, 255, 255)}
20
- expect(subject.normalize(input)).to eq expected
21
- end
22
-
23
- it 'does not modify the original hash' do
24
- input = {stroke: '333333'}
25
- subject.normalize input
26
- expect(input).to eq(stroke: '333333')
27
- end
28
- end
@@ -1,197 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Common::Style do
4
- include_context "dsl app"
5
- let(:blue) { Shoes::COLORS[:blue] }
6
-
7
- class StyleTester
8
- include Shoes::Common::Visibility
9
- include Shoes::DimensionsDelegations
10
- include Shoes::Common::Style
11
- include Shoes::Common::Hover
12
-
13
- attr_reader :app, :dimensions
14
- style_with :key, :left, :click, :strokewidth, :fill
15
-
16
- STYLES = { fill: Shoes::COLORS[:blue] }.freeze
17
-
18
- def initialize(app, styles = {})
19
- @app = app # needed for style init
20
- @dimensions = Shoes::Dimensions.new(@app, left: 15)
21
-
22
- # Would normally be done by Common::Initialization
23
- style_init(styles, key: 'value')
24
- update_dimensions
25
- end
26
-
27
- def click(&arg)
28
- @click = arg
29
- end
30
-
31
- def click_blk
32
- @click
33
- end
34
-
35
- def update_visibility
36
- end
37
- end
38
-
39
- subject { StyleTester.new(app) }
40
-
41
- its(:style) { should eq(initial_style) }
42
- let(:initial_style) do
43
- {
44
- key: 'value', left: 15, click: nil, strokewidth: 1, fill: blue, margin: [0, 0, 0, 0],
45
- margin_left: 0, margin_top: 0, margin_right: 0, margin_bottom: 0
46
- }
47
- end
48
-
49
- describe 'reading and writing through #style(hash)' do
50
- let(:input_proc) { proc {} }
51
- let(:changed_style) { {key: 'changed value'} }
52
-
53
- before :each do
54
- subject.style changed_style
55
- end
56
-
57
- it 'returns the changed style' do
58
- expect(subject.style).to eq initial_style.merge changed_style
59
- end
60
-
61
- it 'does update values for new values' do
62
- subject.style new_key: 'new value'
63
- expect(subject.style[:new_key]).to eq 'new value'
64
- end
65
-
66
- it 'reads new dimensions' do
67
- subject.left = 20
68
- expect(subject.style[:left]).to eq 20
69
- end
70
-
71
- it 'writes new dimensions' do
72
- subject.style(left: 200)
73
- expect(subject.left).to eq 200
74
- end
75
-
76
- it 'reads visibility' do
77
- subject.hide
78
- expect(subject.style[:hidden]).to be true
79
- end
80
-
81
- it 'writes visibility' do
82
- subject.style(hidden: true)
83
- expect(subject.hidden?).to be true
84
- end
85
-
86
- it 'sets click' do
87
- subject.style(click: input_proc)
88
- expect(subject.click_blk).to eq input_proc
89
- end
90
-
91
- it 'sets non dimension non click style via setter' do
92
- subject.key = 'silver'
93
- expect(subject.style[:key]).to eq 'silver'
94
- end
95
-
96
- it 'gets non dimension non click style via getter' do
97
- expect(subject.key).to eq 'changed value'
98
- end
99
-
100
- # these specs are rather extensive as they are performance critical for
101
- # redrawing
102
- describe 'calling or not calling #update_style' do
103
- it 'does not call #update_style if no key value pairs changed' do
104
- expect(subject).not_to receive(:update_style)
105
- subject.style changed_style
106
- end
107
-
108
- it 'does not call #update_style if called without arg' do
109
- expect(subject).not_to receive(:update_style)
110
- subject.style
111
- end
112
-
113
- it 'does call #update_style if the values change' do
114
- expect(subject).to receive(:update_style)
115
- subject.style key: 'new value'
116
- end
117
-
118
- it 'does call #update_style if there is a new key-value' do
119
- expect(subject).to receive(:update_style)
120
- subject.style new_key: 'value'
121
- end
122
- end
123
- end
124
-
125
- describe "app-default" do
126
- it "reads app-default styles with reader" do
127
- expect(subject.strokewidth).to eq 1
128
- end
129
-
130
- it "writes app-default styles with writer" do
131
- subject.strokewidth = 5
132
- expect(subject.strokewidth).to eq 5
133
- end
134
-
135
- it "does not read 'default' styles that it doesn't support" do
136
- expect(subject).not_to respond_to :stroke
137
- end
138
-
139
- it "does not write 'default' styles that it doesn't support" do
140
- expect(subject).not_to respond_to :stroke=
141
- end
142
- end
143
-
144
- describe "style priorities" do
145
- subject { StyleTester.new(app, key: 'pumpkin') }
146
- let(:green) { Shoes::COLORS[:green] }
147
-
148
- it 'uses arguments-styles over element-styles' do
149
- expect(subject.key).to eq 'pumpkin'
150
- end
151
-
152
- it "uses element-defaults over app-defaults" do
153
- expect(subject.fill).to eq blue
154
- end
155
-
156
- describe "with app level styles applied" do
157
- let(:app) { Shoes::App.new }
158
-
159
- it "should override class level defaults with app level styles provided those app styles are supported by the class" do
160
- app.style(fill: green)
161
- expect(app.line(0, 0, 10, 10).fill).to eq green
162
- end
163
-
164
- it "should not override class level defaults with app level styles for already instanciated objects" do
165
- line_instance = app.line(0, 0, 10, 10)
166
- app.style(fill: green)
167
- expect(line_instance.fill).not_to eq green
168
- end
169
- end
170
-
171
- # related priority specs are tested individually in spec/shared_examples/style
172
- end
173
-
174
- describe 'StyleWith' do
175
- it 'ensures that readers exist for each supported style' do
176
- subject.supported_styles.each do |style|
177
- expect(subject).to respond_to style
178
- end
179
- end
180
-
181
- it 'ensures that writers exist for each supported style' do
182
- subject.supported_styles.each do |style|
183
- expect(subject).to respond_to "#{style}="
184
- end
185
- end
186
- end
187
-
188
- describe 'sets hover and leave from styles' do
189
- let(:hover_blk) { proc {} }
190
- let(:leave_blk) { proc {} }
191
-
192
- subject { StyleTester.new(app, hover: hover_blk, leave: leave_blk) }
193
-
194
- its(:hover_blk) { should eq(hover_blk) }
195
- its(:leave_blk) { should eq(leave_blk) }
196
- end
197
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Common::Translate do
4
- let(:test_class) do
5
- Class.new do
6
- include Shoes::Common::Translate
7
-
8
- attr_reader :translate
9
-
10
- def initialize(translate)
11
- @translate = translate
12
- end
13
- end
14
- end
15
-
16
- it 'allows nil' do
17
- subject = test_class.new(nil)
18
- expect(subject.translate_left).to eq(0)
19
- expect(subject.translate_top).to eq(0)
20
- end
21
-
22
- it 'sets values' do
23
- subject = test_class.new([10, 20])
24
- expect(subject.translate_left).to eq(10)
25
- expect(subject.translate_top).to eq(20)
26
- end
27
- end
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Shoes::Configuration do
4
- after { Shoes.configuration.reset }
5
-
6
- describe "#logger" do
7
- describe ":ruby" do
8
- before { Shoes.configuration.logger = :ruby }
9
-
10
- it "uses the Ruby logger" do
11
- expect(Shoes.logger.instance_of?(Shoes::Logger::Ruby)).to eq(true)
12
- end
13
- end
14
- end
15
-
16
- describe "backend" do
17
- include_context "dsl app"
18
-
19
- let(:dsl_object) { Shoes::Shape.new app, parent }
20
-
21
- describe "#backend_for" do
22
- it "passes app.gui to backend" do
23
- expect(Shoes.configuration.backend::Shape).to receive(:new).with(an_instance_of(Shoes::Shape), app.gui).and_call_original
24
- dsl_object
25
- end
26
-
27
- it "returns shape backend object" do
28
- expect(Shoes.backend_for(dsl_object)).to be_instance_of(Shoes.configuration.backend::Shape)
29
- end
30
-
31
- it "raises ArgumentError for a non-Shoes object" do
32
- expect { Shoes.backend_for(1..100) }.to raise_error(ArgumentError)
33
- end
34
- end
35
-
36
- describe '#backend_class' do
37
- it 'returns the backend class for a dsl object' do
38
- expect(Shoes.configuration.backend_class(dsl_object)).to eq(Shoes.configuration.backend::Shape)
39
- end
40
-
41
- it 'returns the backend class if fed with a class' do
42
- expect(Shoes.configuration.backend_class(Shoes::Shape)).to eq(Shoes.configuration
43
- .backend::Shape)
44
- end
45
-
46
- it 'raises an error when fed with a non existant class' do
47
- expect { Shoes.configuration.backend_class(Array) }.to raise_error(ArgumentError)
48
- end
49
- end
50
- end
51
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
- require "pathname"
3
-
4
- describe "Shoes constants" do
5
- specify "PI equals Math::PI" do
6
- expect(Shoes::PI).to eq(Math::PI)
7
- end
8
-
9
- specify "TWO_PI equals 2 * Math::PI" do
10
- expect(Shoes::TWO_PI).to eq(2 * Math::PI)
11
- end
12
-
13
- specify "HALF_PI equals 0.5 * Math::PI" do
14
- expect(Shoes::HALF_PI).to eq(0.5 * Math::PI)
15
- end
16
-
17
- describe "DIR" do
18
- let(:shoes_home_dir) { Pathname.new(__FILE__).join("../../..").expand_path }
19
- subject { Pathname.new Shoes::DIR }
20
-
21
- it "is the shoes home directory" do
22
- expect(subject).to eq(shoes_home_dir)
23
- end
24
-
25
- it "contains lib/shoes.rb" do
26
- expect(subject.join("lib/shoes.rb")).to exist
27
- end
28
-
29
- it "contains static/shoes_icon.png" do
30
- expect(subject.join("static/shoes-icon.png")).to exist
31
- end
32
-
33
- it "remains constant when current directory changes" do
34
- Dir.chdir ".." do
35
- expect(subject).to eq(shoes_home_dir)
36
- end
37
- end
38
- end
39
- end