-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathshoes_splorer.rb
executable file
·150 lines (132 loc) · 2.92 KB
/
shoes_splorer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env ruby
# It's cool to be able to visualise the Shoes API -- where are various methods available?
# Future plan: this would be a *great* opportunity for a Shoes::Widget so that we could
# have a "show all the methods by category" thing and put it inside various other widgets
# to see how they all react.
# What methods should Shoes have? You can do worse than to check Shoes4 Shoes-core:
# https://github.com/shoes/shoes4/tree/main/shoes-core/lib/shoes/dsl
SHOES_API_CATEGORIES = {
animate: {
animate: {},
every: {},
timer: {},
},
art: {
arrow: {},
arc: {},
line: {},
oval: {},
rect: {},
star: {},
shape: {},
mask: {},
},
element: {
border: {},
background: {},
edit_line: {},
edit_box: {},
progress: {},
check: {},
radio: {},
list_box: {},
flow: {},
stack: {},
button: {},
},
interaction: {
mouse: {},
motion: {},
resize: {},
hover: {},
leave: {},
keypress: {},
keyrelease: {},
append: {},
visit: {},
scroll_top: {},
#"scroll_top=": {},
clipboard: {},
#"clipboard=": {},
download: {},
gutter: {},
},
media: {
image: {},
video: {},
sound: {},
},
setup: {
# This is deprecated in recent Shoes, but was once how to install gems
setup: {},
},
style: {
style: {},
fill: {},
stroke: {},
cap: {},
rotate: {},
strokewidth: {},
transform: {},
translate: {},
nostroke: {},
nofill: {},
},
text: {
# Text widgets and similar
banner: {},
title: {},
subtitle: {},
tagline: {},
caption: {},
para: {},
inscription: {},
code: {},
del: {},
em: {},
ins: {},
sub: {},
sup: {},
strong: {},
fg: {},
bg: {},
link: {},
span: {},
},
}
def shoes_api_reactivity(instance)
reactivity = {}
SHOES_API_CATEGORIES.each do |category_name, category|
cat_data = category.map do |method_name, data| # For now ignore data
[method_name, instance.respond_to?(method_name)]
end
if cat_data.none? { |_name, reacts| reacts }
reactivity[category_name] = false
elsif cat_data.all? { |_name, reacts| reacts }
reactivity[category_name] = true
else
out = {}
cat_data.each do |name, reacts|
out[name] = reacts
end
reactivity[category_name] = out
end
end
reactivity
end
Shoes.app(title: "Shoes-splorer!") do
para "What Shoes methods are available?"
shoes_api_reactivity(self).flat_map do |category, cat_reacts|
if cat_reacts.respond_to?(:each)
para *(cat_reacts.flat_map do |name, reacts|
[reacts ? "o" : "x", code(name), " "]
end), stroke: :orange
elsif cat_reacts
# Whole category is true
para strong(" #{category}[Woot!] "), stroke: :green
else
# Whole category is false
para em(" xxx"), category.to_s, em("xxx "), stroke: :red
end
end
end