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.
- checksums.yaml +4 -4
- data/lib/shoes/arc.rb +10 -13
- data/lib/shoes/arrow.rb +1 -11
- data/lib/shoes/background.rb +0 -3
- data/lib/shoes/border.rb +0 -3
- data/lib/shoes/button.rb +4 -1
- data/lib/shoes/check_button.rb +0 -1
- data/lib/shoes/common/art_element.rb +21 -0
- data/lib/shoes/common/background_element.rb +10 -0
- data/lib/shoes/common/clickable.rb +2 -0
- data/lib/shoes/common/rotate.rb +1 -2
- data/lib/shoes/common/ui_element.rb +10 -1
- data/lib/shoes/core/version.rb +1 -1
- data/lib/shoes/download.rb +47 -29
- data/lib/shoes/dsl.rb +99 -40
- data/lib/shoes/font.rb +0 -4
- data/lib/shoes/http_request.rb +91 -0
- data/lib/shoes/image.rb +0 -1
- data/lib/shoes/input_box.rb +0 -1
- data/lib/shoes/internal_app.rb +1 -1
- data/lib/shoes/line.rb +25 -11
- data/lib/shoes/link.rb +10 -4
- data/lib/shoes/list_box.rb +0 -1
- data/lib/shoes/mock/app.rb +6 -0
- data/lib/shoes/mock/clickable.rb +3 -0
- data/lib/shoes/mock/font.rb +0 -4
- data/lib/shoes/oval.rb +3 -13
- data/lib/shoes/progress.rb +0 -1
- data/lib/shoes/rect.rb +1 -11
- data/lib/shoes/shape.rb +16 -8
- data/lib/shoes/slot.rb +2 -1
- data/lib/shoes/star.rb +8 -11
- data/lib/shoes/text_block.rb +0 -1
- data/lib/shoes/ui/picker.rb +29 -8
- data/lib/shoes/version.rb +1 -1
- metadata +8 -231
- data/Guardfile +0 -5
- data/Rakefile +0 -1
- data/bin/shoes-stub +0 -62
- data/ext/install/Rakefile +0 -39
- data/ext/install/shoes.bat +0 -17
- data/lib/rubygems_plugin.rb +0 -24
- data/shoes-core.gemspec +0 -22
- data/spec/shoes/animation_spec.rb +0 -71
- data/spec/shoes/app_spec.rb +0 -454
- data/spec/shoes/arc_spec.rb +0 -52
- data/spec/shoes/arrow_spec.rb +0 -28
- data/spec/shoes/background_spec.rb +0 -47
- data/spec/shoes/border_spec.rb +0 -46
- data/spec/shoes/builtin_methods_spec.rb +0 -122
- data/spec/shoes/button_spec.rb +0 -55
- data/spec/shoes/check_spec.rb +0 -36
- data/spec/shoes/color_spec.rb +0 -429
- data/spec/shoes/common/attachable_spec.rb +0 -32
- data/spec/shoes/common/inspect_spec.rb +0 -26
- data/spec/shoes/common/remove_spec.rb +0 -37
- data/spec/shoes/common/rotate_spec.rb +0 -13
- data/spec/shoes/common/style_normalizer_spec.rb +0 -28
- data/spec/shoes/common/style_spec.rb +0 -197
- data/spec/shoes/common/translate_spec.rb +0 -27
- data/spec/shoes/configuration_spec.rb +0 -51
- data/spec/shoes/constants_spec.rb +0 -39
- data/spec/shoes/dialog_spec.rb +0 -169
- data/spec/shoes/dimension_spec.rb +0 -451
- data/spec/shoes/dimensions_spec.rb +0 -868
- data/spec/shoes/download_spec.rb +0 -198
- data/spec/shoes/flow_spec.rb +0 -132
- data/spec/shoes/font_spec.rb +0 -36
- data/spec/shoes/framework_learning_spec.rb +0 -31
- data/spec/shoes/gradient_spec.rb +0 -31
- data/spec/shoes/helpers/fake_absolute_element.rb +0 -31
- data/spec/shoes/helpers/fake_element.rb +0 -25
- data/spec/shoes/helpers/inspect_helpers.rb +0 -5
- data/spec/shoes/helpers/sample17_helper.rb +0 -65
- data/spec/shoes/image_spec.rb +0 -69
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +0 -80
- data/spec/shoes/integration_spec.rb +0 -19
- data/spec/shoes/internal_app_spec.rb +0 -148
- data/spec/shoes/keypress_spec.rb +0 -11
- data/spec/shoes/keyrelease_spec.rb +0 -11
- data/spec/shoes/line_spec.rb +0 -120
- data/spec/shoes/link_spec.rb +0 -149
- data/spec/shoes/list_box_spec.rb +0 -87
- data/spec/shoes/logger/ruby_spec.rb +0 -8
- data/spec/shoes/logger_spec.rb +0 -45
- data/spec/shoes/oval_spec.rb +0 -25
- data/spec/shoes/packager_spec.rb +0 -25
- data/spec/shoes/point_spec.rb +0 -99
- data/spec/shoes/progress_spec.rb +0 -54
- data/spec/shoes/radio_spec.rb +0 -32
- data/spec/shoes/rect_spec.rb +0 -40
- data/spec/shoes/renamed_delegate_spec.rb +0 -69
- data/spec/shoes/shape_spec.rb +0 -119
- data/spec/shoes/shared_examples/button.rb +0 -6
- data/spec/shoes/shared_examples/changeable.rb +0 -26
- data/spec/shoes/shared_examples/clickable.rb +0 -5
- data/spec/shoes/shared_examples/common_methods.rb +0 -35
- data/spec/shoes/shared_examples/dimensions.rb +0 -32
- data/spec/shoes/shared_examples/dsl.rb +0 -44
- data/spec/shoes/shared_examples/dsl/animate.rb +0 -29
- data/spec/shoes/shared_examples/dsl/arc.rb +0 -45
- data/spec/shoes/shared_examples/dsl/background.rb +0 -26
- data/spec/shoes/shared_examples/dsl/border.rb +0 -10
- data/spec/shoes/shared_examples/dsl/button.rb +0 -5
- data/spec/shoes/shared_examples/dsl/cap.rb +0 -6
- data/spec/shoes/shared_examples/dsl/check.rb +0 -11
- data/spec/shoes/shared_examples/dsl/edit_box.rb +0 -8
- data/spec/shoes/shared_examples/dsl/edit_line.rb +0 -8
- data/spec/shoes/shared_examples/dsl/editable_element.rb +0 -29
- data/spec/shoes/shared_examples/dsl/fill.rb +0 -27
- data/spec/shoes/shared_examples/dsl/flow.rb +0 -15
- data/spec/shoes/shared_examples/dsl/gradient.rb +0 -62
- data/spec/shoes/shared_examples/dsl/image.rb +0 -21
- data/spec/shoes/shared_examples/dsl/line.rb +0 -9
- data/spec/shoes/shared_examples/dsl/nofill.rb +0 -6
- data/spec/shoes/shared_examples/dsl/nostroke.rb +0 -6
- data/spec/shoes/shared_examples/dsl/oval.rb +0 -88
- data/spec/shoes/shared_examples/dsl/pattern.rb +0 -34
- data/spec/shoes/shared_examples/dsl/progress.rb +0 -7
- data/spec/shoes/shared_examples/dsl/rect.rb +0 -92
- data/spec/shoes/shared_examples/dsl/rgb.rb +0 -28
- data/spec/shoes/shared_examples/dsl/shape.rb +0 -61
- data/spec/shoes/shared_examples/dsl/star.rb +0 -110
- data/spec/shoes/shared_examples/dsl/stroke.rb +0 -30
- data/spec/shoes/shared_examples/dsl/strokewidth.rb +0 -19
- data/spec/shoes/shared_examples/dsl/style.rb +0 -32
- data/spec/shoes/shared_examples/dsl/text_elements.rb +0 -84
- data/spec/shoes/shared_examples/dsl/video.rb +0 -5
- data/spec/shoes/shared_examples/dsl_app_context.rb +0 -11
- data/spec/shoes/shared_examples/hover.rb +0 -78
- data/spec/shoes/shared_examples/parent.rb +0 -6
- data/spec/shoes/shared_examples/scroll.rb +0 -41
- data/spec/shoes/shared_examples/shared_element_method.rb +0 -60
- data/spec/shoes/shared_examples/slot.rb +0 -441
- data/spec/shoes/shared_examples/state.rb +0 -26
- data/spec/shoes/shared_examples/style.rb +0 -77
- data/spec/shoes/slot_spec.rb +0 -176
- data/spec/shoes/sound_spec.rb +0 -16
- data/spec/shoes/span_spec.rb +0 -112
- data/spec/shoes/spec_helper.rb +0 -24
- data/spec/shoes/stack_spec.rb +0 -79
- data/spec/shoes/star_spec.rb +0 -49
- data/spec/shoes/text_block_dimensions_spec.rb +0 -77
- data/spec/shoes/text_block_spec.rb +0 -314
- data/spec/shoes/text_spec.rb +0 -22
- data/spec/shoes/ui/picker_spec.rb +0 -69
- data/spec/shoes/url_spec.rb +0 -67
- data/spec/shoes/widget_spec.rb +0 -78
- data/spec/shoes_spec.rb +0 -41
- data/spec/spec_helper.rb +0 -27
data/lib/shoes/font.rb
CHANGED
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'uri'
|
4
|
+
require 'net/http'
|
5
|
+
|
6
|
+
# Wrapper for Net::HTTP to provide us to the functionality that we need which
|
7
|
+
# isn't easily available from any particular gem out there :(
|
8
|
+
#
|
9
|
+
# Specific things this class does that we need include:
|
10
|
+
#
|
11
|
+
# 1) Reading in chunks to trigger progress
|
12
|
+
# 2) Allow for graceful redirection
|
13
|
+
#
|
14
|
+
# Most of the gems out there do 2) but not 1), or do both but are untested on
|
15
|
+
# JRuby.
|
16
|
+
#
|
17
|
+
class Shoes
|
18
|
+
class HttpRequest
|
19
|
+
def initialize(started_proc = nil, redirects_left = 5)
|
20
|
+
@started_proc = started_proc
|
21
|
+
@redirects_left = redirects_left
|
22
|
+
end
|
23
|
+
|
24
|
+
def read_chunks(url, meth, body, headers = {}, &blk)
|
25
|
+
uri = URI(url)
|
26
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: needs_ssl?(uri)) do |http|
|
27
|
+
request = build_request(uri, meth, body, headers)
|
28
|
+
|
29
|
+
http.request(request) do |response|
|
30
|
+
case response
|
31
|
+
when Net::HTTPSuccess
|
32
|
+
handle_success(response, &blk)
|
33
|
+
when Net::HTTPRedirection
|
34
|
+
handle_redirect(response, headers, &blk)
|
35
|
+
else
|
36
|
+
handle_error(response)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def build_request(uri, meth, body, headers)
|
45
|
+
klass = Net::HTTP.const_get(meth.downcase.capitalize)
|
46
|
+
klass.new(uri).tap do |request|
|
47
|
+
request.body = body
|
48
|
+
headers.each do |(key, value)|
|
49
|
+
request[key] = value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def handle_redirect(response, headers, &blk)
|
55
|
+
raise "Exhausted trying to redirect... See ya'" if @redirects_left <= 0
|
56
|
+
|
57
|
+
next_uri = URI(response["Location"])
|
58
|
+
|
59
|
+
if schemes_mismatch?(response.uri, next_uri) &&
|
60
|
+
!allowed_scheme_change?(response.uri, next_uri)
|
61
|
+
raise "Disallowed redirection from '#{response.uri.scheme}' to '#{next_uri.scheme}'"
|
62
|
+
end
|
63
|
+
|
64
|
+
@redirects_left -= 1
|
65
|
+
read_chunks(next_uri, "GET", nil, headers, &blk)
|
66
|
+
end
|
67
|
+
|
68
|
+
def handle_success(response)
|
69
|
+
@started_proc&.call(response)
|
70
|
+
response.read_body do |chunk|
|
71
|
+
yield chunk
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def handle_error(response)
|
76
|
+
raise "#{response.code} #{response.message}"
|
77
|
+
end
|
78
|
+
|
79
|
+
def schemes_mismatch?(original_uri, new_uri)
|
80
|
+
original_uri.scheme != new_uri.scheme
|
81
|
+
end
|
82
|
+
|
83
|
+
def allowed_scheme_change?(original_uri, new_uri)
|
84
|
+
original_uri.scheme == "http" && new_uri.scheme == "https"
|
85
|
+
end
|
86
|
+
|
87
|
+
def needs_ssl?(uri)
|
88
|
+
uri.scheme == "https"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/lib/shoes/image.rb
CHANGED
data/lib/shoes/input_box.rb
CHANGED
data/lib/shoes/internal_app.rb
CHANGED
@@ -7,8 +7,8 @@ class Shoes
|
|
7
7
|
# and providing the bulk of the functionality, leaving the App a relatively
|
8
8
|
# blank slate for users to bend to their will.
|
9
9
|
class InternalApp
|
10
|
-
include Common::Style
|
11
10
|
include Common::Clickable
|
11
|
+
include Common::Style
|
12
12
|
include DimensionsDelegations
|
13
13
|
|
14
14
|
extend Forwardable
|
data/lib/shoes/line.rb
CHANGED
@@ -2,26 +2,40 @@ require 'matrix'
|
|
2
2
|
|
3
3
|
class Shoes
|
4
4
|
class Line
|
5
|
-
include Common::
|
6
|
-
include Common::Clickable
|
7
|
-
include Common::Hover
|
8
|
-
include Common::Stroke
|
9
|
-
include Common::Style
|
10
|
-
include Common::Translate
|
5
|
+
include Common::ArtElement
|
11
6
|
|
12
7
|
attr_reader :point_a, :point_b
|
13
8
|
|
14
9
|
style_with :angle, :art_styles, :dimensions, :x2, :y2
|
15
10
|
STYLES = { angle: 0, fill: Shoes::COLORS[:black] }.freeze
|
16
11
|
|
17
|
-
def create_dimensions(
|
18
|
-
|
19
|
-
|
12
|
+
def create_dimensions(x1, y1, x2, y2)
|
13
|
+
x1, y1, x2, y2 = default_coordinates(x1, y1, x2, y2)
|
14
|
+
|
15
|
+
@point_a = Shoes::Point.new(x1, y1)
|
16
|
+
@point_b = Shoes::Point.new(x2, y2)
|
20
17
|
|
21
18
|
enclosing_box_of_line
|
22
19
|
|
23
|
-
style[:x2] = point_b.x
|
24
|
-
style[:y2] = point_b.y
|
20
|
+
style[:x2] = @point_b.x
|
21
|
+
style[:y2] = @point_b.y
|
22
|
+
end
|
23
|
+
|
24
|
+
def default_coordinates(x1, y1, x2, y2)
|
25
|
+
x1 ||= @style[:left] || 0
|
26
|
+
y1 ||= @style[:top] || 0
|
27
|
+
|
28
|
+
x2 ||= @style[:right]
|
29
|
+
if x2
|
30
|
+
# With 3 arguments, draws horizontal line, so fallback to y1
|
31
|
+
y2 ||= @style[:bottom] || y1
|
32
|
+
else
|
33
|
+
# If didn't get needed arguments, set start to end which draws nothing
|
34
|
+
x2 = x1
|
35
|
+
y2 = y1
|
36
|
+
end
|
37
|
+
|
38
|
+
[x1, y1, x2, y2]
|
25
39
|
end
|
26
40
|
|
27
41
|
# Check out http://math.stackexchange.com/questions/60070/checking-whether-a-point-lies-on-a-wide-line-segment
|
data/lib/shoes/link.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
class Shoes
|
2
2
|
class Link < Span
|
3
|
-
include Common::Style
|
4
3
|
include Common::Fill
|
5
|
-
include Common::Stroke
|
6
4
|
include Common::Hover
|
5
|
+
include Common::Stroke
|
6
|
+
include Common::Style
|
7
7
|
|
8
8
|
attr_reader :app, :gui, :blk
|
9
9
|
style_with :common_styles, :text_block_styles
|
@@ -14,12 +14,12 @@ class Shoes
|
|
14
14
|
style_init styles
|
15
15
|
@gui = Shoes.backend_for self
|
16
16
|
|
17
|
-
|
17
|
+
register_click blk
|
18
18
|
super texts, @style
|
19
19
|
end
|
20
20
|
|
21
21
|
# Doesn't use Common::Clickable because of URL flavor option clicks
|
22
|
-
def
|
22
|
+
def register_click(blk)
|
23
23
|
if blk.nil?
|
24
24
|
blk = if @style[:click].respond_to? :call
|
25
25
|
@style[:click]
|
@@ -35,6 +35,12 @@ class Shoes
|
|
35
35
|
def click(&blk)
|
36
36
|
@gui.click blk if blk
|
37
37
|
@blk = blk
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def release(&blk)
|
42
|
+
@gui.release blk if blk
|
43
|
+
self
|
38
44
|
end
|
39
45
|
|
40
46
|
def pass_coordinates?
|
data/lib/shoes/list_box.rb
CHANGED
data/lib/shoes/mock/app.rb
CHANGED
data/lib/shoes/mock/clickable.rb
CHANGED
data/lib/shoes/mock/font.rb
CHANGED
data/lib/shoes/oval.rb
CHANGED
@@ -1,27 +1,17 @@
|
|
1
1
|
class Shoes
|
2
2
|
class Oval
|
3
|
-
include Common::
|
4
|
-
include Common::Clickable
|
5
|
-
include Common::Fill
|
6
|
-
include Common::Hover
|
7
|
-
include Common::Stroke
|
8
|
-
include Common::Style
|
9
|
-
include Common::Translate
|
3
|
+
include Common::ArtElement
|
10
4
|
|
11
5
|
style_with :art_styles, :center, :common_styles, :dimensions, :radius
|
12
6
|
STYLES = { fill: Shoes::COLORS[:black] }.freeze
|
13
7
|
|
14
8
|
def create_dimensions(left, top, width, height)
|
15
|
-
left ||= @style[:left]
|
16
|
-
top ||= @style[:top]
|
9
|
+
left ||= @style[:left] || 0
|
10
|
+
top ||= @style[:top] || 0
|
17
11
|
width ||= @style[:diameter] || @style[:width] || (@style[:radius] || 0) * 2
|
18
12
|
height ||= @style[:height] || width
|
19
13
|
|
20
14
|
@dimensions = AbsoluteDimensions.new left, top, width, height, @style
|
21
15
|
end
|
22
|
-
|
23
|
-
def needs_rotate?
|
24
|
-
rotate && rotate.nonzero?
|
25
|
-
end
|
26
16
|
end
|
27
17
|
end
|
data/lib/shoes/progress.rb
CHANGED
data/lib/shoes/rect.rb
CHANGED
@@ -1,12 +1,6 @@
|
|
1
1
|
class Shoes
|
2
2
|
class Rect
|
3
|
-
include Common::
|
4
|
-
include Common::Fill
|
5
|
-
include Common::Stroke
|
6
|
-
include Common::Clickable
|
7
|
-
include Common::Hover
|
8
|
-
include Common::Style
|
9
|
-
include Common::Translate
|
3
|
+
include Common::ArtElement
|
10
4
|
|
11
5
|
style_with :angle, :art_styles, :curve, :common_styles, :dimensions
|
12
6
|
STYLES = { angle: 0, curve: 0, fill: Shoes::COLORS[:black] }.freeze
|
@@ -19,9 +13,5 @@ class Shoes
|
|
19
13
|
|
20
14
|
@dimensions = AbsoluteDimensions.new left, top, width, height, @style
|
21
15
|
end
|
22
|
-
|
23
|
-
def needs_rotate?
|
24
|
-
rotate && rotate.nonzero?
|
25
|
-
end
|
26
16
|
end
|
27
17
|
end
|
data/lib/shoes/shape.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
class Shoes
|
2
2
|
class Shape
|
3
|
-
include Common::
|
4
|
-
include Common::Clickable
|
5
|
-
include Common::Fill
|
6
|
-
include Common::Stroke
|
7
|
-
include Common::Style
|
8
|
-
include Common::Translate
|
3
|
+
include Common::ArtElement
|
9
4
|
|
10
5
|
attr_reader :blk, :x, :y, :left_bound, :top_bound, :right_bound, :bottom_bound
|
11
6
|
|
@@ -13,8 +8,11 @@ class Shoes
|
|
13
8
|
|
14
9
|
STYLES = { fill: Shoes::COLORS[:black] }.freeze
|
15
10
|
|
16
|
-
def create_dimensions
|
17
|
-
|
11
|
+
def create_dimensions(left, top)
|
12
|
+
left ||= @style[:left] || 0
|
13
|
+
top ||= @style[:top] || 0
|
14
|
+
|
15
|
+
@dimensions = AbsoluteDimensions.new left, top
|
18
16
|
end
|
19
17
|
|
20
18
|
def handle_block(blk)
|
@@ -40,6 +38,16 @@ class Shoes
|
|
40
38
|
@app.height
|
41
39
|
end
|
42
40
|
|
41
|
+
def element_width
|
42
|
+
return super unless @right_bound && @left_bound
|
43
|
+
@right_bound - @left_bound
|
44
|
+
end
|
45
|
+
|
46
|
+
def element_height
|
47
|
+
return super unless @bottom_bound && @top_bound
|
48
|
+
@bottom_bound - @top_bound
|
49
|
+
end
|
50
|
+
|
43
51
|
def fixed_height?
|
44
52
|
false
|
45
53
|
end
|
data/lib/shoes/slot.rb
CHANGED
@@ -3,7 +3,6 @@ class Shoes
|
|
3
3
|
include Common::UIElement
|
4
4
|
include Common::Clickable
|
5
5
|
include Common::Hover
|
6
|
-
include Common::Style
|
7
6
|
|
8
7
|
# We need that offset because otherwise element overlap e.g. occupy
|
9
8
|
# the same pixel - this way they start right next to each other
|
@@ -194,6 +193,8 @@ class Shoes
|
|
194
193
|
|
195
194
|
update_current_position(current_position, element)
|
196
195
|
rescue => e
|
196
|
+
raise e if ENV['SHOES_ENV'] == 'test'
|
197
|
+
|
197
198
|
puts "SWALLOWED POSITIONING EXCEPTION ON #{element} - go take care of it: " + e.to_s
|
198
199
|
puts e.backtrace.join("\n\t")
|
199
200
|
puts 'Unfortunately we have to swallow it or risk SWT hanging.'
|
data/lib/shoes/star.rb
CHANGED
@@ -1,21 +1,18 @@
|
|
1
1
|
class Shoes
|
2
2
|
class Star
|
3
|
-
include Common::
|
4
|
-
include Common::Clickable
|
5
|
-
include Common::Fill
|
6
|
-
include Common::Hover
|
7
|
-
include Common::Stroke
|
8
|
-
include Common::Style
|
9
|
-
include Common::Translate
|
3
|
+
include Common::ArtElement
|
10
4
|
|
11
5
|
style_with :angle, :art_styles, :common_styles, :dimensions, :inner, :outer, :points
|
12
6
|
STYLES = { angle: 0, fill: Shoes::COLORS[:black] }.freeze
|
13
7
|
|
8
|
+
# Don't use param defaults as DSL explicit passes nil for missing params
|
14
9
|
def create_dimensions(left, top, points, outer, inner)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
left ||= @style[:left] || 0
|
11
|
+
top ||= @style[:top] || 0
|
12
|
+
|
13
|
+
points ||= @style[:points] || 10
|
14
|
+
outer ||= @style[:outer] || 100.0
|
15
|
+
inner ||= @style[:inner] || 50.0
|
19
16
|
|
20
17
|
# Careful not to turn Fixnum to Float, lest Dimensions make you relative!
|
21
18
|
width = outer * 2
|
data/lib/shoes/text_block.rb
CHANGED
data/lib/shoes/ui/picker.rb
CHANGED
@@ -1,7 +1,19 @@
|
|
1
|
+
#
|
2
|
+
# This class is used for interactively (if necessary) picking the Shoes
|
3
|
+
# backend that the user will run their Shoes app with.
|
4
|
+
#
|
5
|
+
# This interacts with backend gems via the following contract:
|
6
|
+
#
|
7
|
+
# * Backend provides file "shoes/#{backend_name}/generate_backend.rb"
|
8
|
+
# * Requiring that file defines a module Shoes::SelectedBackend
|
9
|
+
# * Shoes::SelectedBackend should implement the following class methods:
|
10
|
+
# * generate(path) - passed bin path, generates shell command to start
|
11
|
+
# Shoes on given backend
|
12
|
+
# * validate() - checks whether this backend is valid to run (i.e. right
|
13
|
+
# ruby platform) and exits if not.
|
14
|
+
#
|
1
15
|
class Shoes
|
2
16
|
module UI
|
3
|
-
# This class is used for interactively (if necessary) picking the Shoes
|
4
|
-
# backend that the user will run their Shoes app with.
|
5
17
|
class Picker
|
6
18
|
def initialize(input = STDIN, output = STDOUT)
|
7
19
|
@input = input
|
@@ -10,8 +22,11 @@ class Shoes
|
|
10
22
|
|
11
23
|
def run(bin_dir, desired_backend = nil)
|
12
24
|
bundle
|
13
|
-
|
14
|
-
|
25
|
+
|
26
|
+
require_generator(desired_backend)
|
27
|
+
validate_generator
|
28
|
+
|
29
|
+
write_backend(bin_dir)
|
15
30
|
end
|
16
31
|
|
17
32
|
# Only bundle if we find a local Gemfile. This allows us to work properly
|
@@ -78,13 +93,19 @@ class Shoes
|
|
78
93
|
"shoes-#{match.tr('/', '-')}"
|
79
94
|
end
|
80
95
|
|
81
|
-
def
|
96
|
+
def require_generator(desired_backend)
|
97
|
+
generator_file = select_generator(desired_backend)
|
82
98
|
require generator_file
|
99
|
+
end
|
100
|
+
|
101
|
+
def validate_generator
|
102
|
+
Shoes::SelectedBackend.validate
|
103
|
+
end
|
83
104
|
|
105
|
+
def write_backend(bin_dir)
|
84
106
|
File.open(File.expand_path(File.join(bin_dir, "shoes-backend")), "w") do |file|
|
85
|
-
|
86
|
-
|
87
|
-
file.write(generate_backend(ENV["SHOES_PICKER_BIN_DIR"] || bin_dir))
|
107
|
+
dest_dir = ENV["SHOES_PICKER_BIN_DIR"] || bin_dir
|
108
|
+
file.write(Shoes::SelectedBackend.generate(dest_dir))
|
88
109
|
end
|
89
110
|
end
|
90
111
|
end
|