scarpe 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/.yardopts +11 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +112 -0
- data/README.md +31 -24
- data/Rakefile +13 -1
- data/docs/yard/catscradle.md +44 -0
- data/docs/yard/template/default/fulldoc/html/setup.rb +13 -0
- data/docs/yard/template/default/layout/html/setup.rb +9 -0
- data/examples/background_with_image.rb +16 -0
- data/examples/bloopsaphone/working/bronx_army_knife.rb +66 -0
- data/examples/bloopsaphone/working/morning_serenity.rb +21 -0
- data/examples/bloopsaphone/working/simpsons_theme_song_by_why.rb +6 -4
- data/examples/button_go_away.rb +1 -1
- data/examples/check.rb +18 -0
- data/examples/clear_and_append.rb +24 -0
- data/examples/download_and_show_image.rb +28 -0
- data/examples/edit_box.rb +3 -5
- data/examples/fonts.rb +2 -2
- data/examples/get_headers.rb +10 -0
- data/examples/highlander.rb +2 -0
- data/examples/link.rb +2 -2
- data/examples/local_fonts.rb +4 -0
- data/examples/local_images.rb +4 -0
- data/examples/motion_events.rb +20 -0
- data/examples/parse_xl_funnies.rb +58 -0
- data/examples/radio/radio.rb +16 -0
- data/examples/radio/radio_groups.rb +18 -0
- data/examples/radio/radio_same_slot.rb +6 -0
- data/examples/ruby_racer.rb +13 -15
- data/examples/selfitude.rb +18 -0
- data/examples/shapes/shapes_fill.rb +4 -3
- data/examples/shoes_school.rb +2 -4
- data/examples/show_hide.rb +6 -0
- data/examples/skip_ci/change_my_audio_source.rb +21 -0
- data/examples/skip_ci/guitar_fretboard.rb +137 -0
- data/examples/video.rb +10 -0
- data/exe/scarpe +42 -66
- data/fonts/Pacifico.ttf +0 -0
- data/lacci/Gemfile +22 -0
- data/lacci/Gemfile.lock +72 -0
- data/lacci/Rakefile +12 -0
- data/lacci/lacci.gemspec +37 -0
- data/lacci/lib/lacci/scarpe_cli.rb +70 -0
- data/lacci/lib/lacci/scarpe_core.rb +21 -0
- data/lacci/lib/lacci/version.rb +13 -0
- data/lacci/lib/shoes/app.rb +264 -0
- data/{lib/scarpe → lacci/lib/shoes}/background.rb +1 -1
- data/{lib/scarpe → lacci/lib/shoes}/border.rb +1 -1
- data/{lib/scarpe → lacci/lib/shoes}/colors.rb +1 -1
- data/lacci/lib/shoes/constants.rb +29 -0
- data/{lib/scarpe → lacci/lib/shoes}/display_service.rb +40 -45
- data/lacci/lib/shoes/download.rb +123 -0
- data/lacci/lib/shoes/log.rb +71 -0
- data/lacci/lib/shoes/spacing.rb +9 -0
- data/{lib/scarpe → lacci/lib/shoes}/widget.rb +63 -43
- data/{lib/scarpe → lacci/lib/shoes/widgets}/alert.rb +3 -3
- data/{lib/scarpe → lacci/lib/shoes/widgets}/arc.rb +7 -5
- data/{lib/scarpe → lacci/lib/shoes/widgets}/button.rb +3 -3
- data/lacci/lib/shoes/widgets/check.rb +28 -0
- data/lacci/lib/shoes/widgets/document_root.rb +20 -0
- data/{lib/scarpe → lacci/lib/shoes/widgets}/edit_box.rb +10 -5
- data/{lib/scarpe → lacci/lib/shoes/widgets}/edit_line.rb +2 -2
- data/lacci/lib/shoes/widgets/flow.rb +22 -0
- data/lacci/lib/shoes/widgets/font.rb +14 -0
- data/{lib/scarpe → lacci/lib/shoes/widgets}/image.rb +3 -7
- data/lacci/lib/shoes/widgets/line.rb +18 -0
- data/{lib/scarpe → lacci/lib/shoes/widgets}/link.rb +2 -2
- data/{lib/scarpe → lacci/lib/shoes/widgets}/list_box.rb +2 -2
- data/{lib/scarpe → lacci/lib/shoes/widgets}/para.rb +4 -26
- data/lacci/lib/shoes/widgets/radio.rb +35 -0
- data/lacci/lib/shoes/widgets/shape.rb +37 -0
- data/lacci/lib/shoes/widgets/slot.rb +75 -0
- data/{lib/scarpe → lacci/lib/shoes/widgets}/span.rb +2 -2
- data/lacci/lib/shoes/widgets/stack.rb +24 -0
- data/{lib/scarpe → lacci/lib/shoes/widgets}/star.rb +6 -9
- data/lacci/lib/shoes/widgets/subscription_item.rb +60 -0
- data/lacci/lib/shoes/widgets/text_widget.rb +51 -0
- data/lacci/lib/shoes/widgets/video.rb +15 -0
- data/lacci/lib/shoes/widgets.rb +29 -0
- data/lacci/lib/shoes.rb +127 -0
- data/lacci/test/test_colors.rb +39 -0
- data/lacci/test/test_helper.rb +9 -0
- data/lacci/test/test_lacci.rb +9 -0
- data/lib/scarpe/cats_cradle.rb +249 -0
- data/lib/scarpe/evented_assertions.rb +88 -0
- data/lib/scarpe/version.rb +1 -1
- data/lib/scarpe/wv/alert.rb +3 -2
- data/lib/scarpe/wv/app.rb +30 -8
- data/lib/scarpe/wv/arc.rb +5 -6
- data/lib/scarpe/wv/background.rb +10 -1
- data/lib/scarpe/wv/border.rb +5 -3
- data/lib/scarpe/wv/button.rb +11 -9
- data/lib/scarpe/wv/check.rb +29 -0
- data/lib/scarpe/wv/control_interface.rb +14 -20
- data/lib/scarpe/wv/control_interface_test.rb +13 -28
- data/lib/scarpe/wv/document_root.rb +3 -45
- data/lib/scarpe/wv/edit_box.rb +5 -7
- data/lib/scarpe/wv/edit_line.rb +2 -2
- data/lib/scarpe/wv/flow.rb +10 -20
- data/lib/scarpe/wv/font.rb +36 -0
- data/lib/scarpe/wv/html.rb +3 -2
- data/lib/scarpe/wv/image.rb +7 -2
- data/lib/scarpe/wv/line.rb +4 -7
- data/lib/scarpe/wv/link.rb +1 -0
- data/lib/scarpe/wv/list_box.rb +3 -3
- data/lib/scarpe/wv/para.rb +16 -14
- data/lib/scarpe/wv/radio.rb +34 -0
- data/lib/scarpe/wv/shape.rb +44 -8
- data/lib/scarpe/wv/slot.rb +81 -0
- data/lib/scarpe/wv/spacing.rb +1 -1
- data/lib/scarpe/wv/span.rb +10 -8
- data/lib/scarpe/wv/stack.rb +10 -30
- data/lib/scarpe/wv/star.rb +11 -12
- data/lib/scarpe/wv/subscription_item.rb +50 -0
- data/lib/scarpe/wv/video.rb +34 -0
- data/lib/scarpe/wv/web_wrangler.rb +238 -58
- data/lib/scarpe/wv/webview_local_display.rb +27 -5
- data/lib/scarpe/wv/webview_relay_display.rb +18 -119
- data/lib/scarpe/wv/webview_relay_util.rb +143 -0
- data/lib/scarpe/wv/widget.rb +80 -11
- data/lib/scarpe/wv/wv_display_worker.rb +17 -4
- data/lib/scarpe/wv.rb +33 -4
- data/lib/scarpe/wv_local.rb +1 -1
- data/lib/scarpe/wv_relay.rb +1 -1
- data/lib/scarpe.rb +3 -32
- data/scarpe-components/.gitignore +1 -0
- data/scarpe-components/Gemfile +22 -0
- data/scarpe-components/README.md +35 -0
- data/scarpe-components/Rakefile +12 -0
- data/scarpe-components/lib/scarpe/components/base64.rb +29 -0
- data/scarpe-components/lib/scarpe/components/file_helpers.rb +65 -0
- data/scarpe-components/lib/scarpe/components/modular_logger.rb +113 -0
- data/scarpe-components/lib/scarpe/components/print_logger.rb +43 -0
- data/{lib/scarpe → scarpe-components/lib/scarpe/components}/promises.rb +102 -35
- data/scarpe-components/lib/scarpe/components/segmented_file_loader.rb +170 -0
- data/scarpe-components/lib/scarpe/components/unit_test_helpers.rb +217 -0
- data/scarpe-components/lib/scarpe/components/version.rb +7 -0
- data/scarpe-components/scarpe-components.gemspec +38 -0
- data/scarpe-components/test/test_components.rb +9 -0
- data/scarpe-components/test/test_helper.rb +23 -0
- data/scarpe-components/test/test_promises.rb +260 -0
- data/scarpe-components/test/test_segmented_app_files.rb +182 -0
- data/{lib/scarpe → spikes}/glibui/widget.rb +2 -2
- data/{lib/scarpe → spikes}/glibui.rb +1 -1
- data/templates/basic_class_template.erb +1 -1
- data/templates/class_template_with_event_bind.erb +1 -1
- data/templates/class_template_with_shapes.erb +1 -1
- data/templates/webview_template.erb +0 -3
- metadata +165 -117
- data/examples/fill.rb +0 -25
- data/examples/legacy/not_checked/shoes-contrib/basic/class-book.yaml +0 -387
- data/examples/legacy/not_checked/shoes-contrib/good/good-clock.rb +0 -51
- data/examples/legacy/not_checked/shoes-contrib/good/good-follow.rb +0 -26
- data/examples/legacy/not_checked/shoes-contrib/good/good-reminder.rb +0 -174
- data/examples/legacy/not_checked/shoes-contrib/good/good-vjot.rb +0 -56
- data/examples/legacy/not_checked/shoes-contrib/simple/simple-timer.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/good-clock.rb +0 -51
- data/examples/legacy/not_checked/shoes-dep-samples/good-follow.rb +0 -26
- data/examples/legacy/not_checked/shoes-dep-samples/good-reminder.rb +0 -174
- data/examples/legacy/not_checked/shoes-dep-samples/good-vjot.rb +0 -56
- data/examples/legacy/not_checked/shoes-dep-samples/simple-accordion.rb +0 -75
- data/examples/legacy/not_checked/shoes-dep-samples/simple-anim-shapes.rb +0 -17
- data/examples/legacy/not_checked/shoes-dep-samples/simple-anim-text.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-arc.rb +0 -23
- data/examples/legacy/not_checked/shoes-dep-samples/simple-bounce.rb +0 -24
- data/examples/legacy/not_checked/shoes-dep-samples/simple-calc.rb +0 -70
- data/examples/legacy/not_checked/shoes-dep-samples/simple-chipmunk.rb +0 -26
- data/examples/legacy/not_checked/shoes-dep-samples/simple-control-sizes.rb +0 -24
- data/examples/legacy/not_checked/shoes-dep-samples/simple-curve.rb +0 -26
- data/examples/legacy/not_checked/shoes-dep-samples/simple-dialogs.rb +0 -29
- data/examples/legacy/not_checked/shoes-dep-samples/simple-draw.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-editor.rb +0 -28
- data/examples/legacy/not_checked/shoes-dep-samples/simple-form.rb +0 -28
- data/examples/legacy/not_checked/shoes-dep-samples/simple-form.shy +0 -0
- data/examples/legacy/not_checked/shoes-dep-samples/simple-mask.rb +0 -21
- data/examples/legacy/not_checked/shoes-dep-samples/simple-menu.rb +0 -31
- data/examples/legacy/not_checked/shoes-dep-samples/simple-menu1.rb +0 -35
- data/examples/legacy/not_checked/shoes-dep-samples/simple-rubygems.rb +0 -29
- data/examples/legacy/not_checked/shoes-dep-samples/simple-slide.rb +0 -45
- data/examples/legacy/not_checked/shoes-dep-samples/simple-sphere.rb +0 -28
- data/examples/legacy/not_checked/shoes-dep-samples/simple-sqlite3.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-timer.rb +0 -13
- data/examples/legacy/not_checked/shoes-dep-samples/simple-video.rb +0 -13
- data/examples/legacy/not_checked/simple/anim-text.rb +0 -13
- data/examples/legacy/not_checked/simple/arc.rb +0 -23
- data/examples/legacy/not_checked/simple/bounce.rb +0 -24
- data/examples/legacy/not_checked/simple/chipmunk.rb +0 -26
- data/examples/legacy/not_checked/simple/curve.rb +0 -26
- data/examples/legacy/not_checked/simple/dialogs.rb +0 -29
- data/examples/legacy/not_checked/simple/downloader.rb +0 -40
- data/examples/legacy/not_checked/simple/draw.rb +0 -13
- data/examples/legacy/not_checked/simple/mask.rb +0 -21
- data/examples/legacy/not_checked/simple/slide.rb +0 -45
- data/examples/legacy/not_checked/simple/sphere.rb +0 -28
- data/lib/constants.rb +0 -5
- data/lib/scarpe/app.rb +0 -78
- data/lib/scarpe/document_root.rb +0 -20
- data/lib/scarpe/fill.rb +0 -23
- data/lib/scarpe/flow.rb +0 -19
- data/lib/scarpe/line.rb +0 -25
- data/lib/scarpe/logger.rb +0 -155
- data/lib/scarpe/shape.rb +0 -19
- data/lib/scarpe/spacing.rb +0 -9
- data/lib/scarpe/stack.rb +0 -70
- data/lib/scarpe/text_widget.rb +0 -42
- data/lib/scarpe/unit_test_helpers.rb +0 -163
- data/lib/scarpe/widgets.rb +0 -30
- data/lib/scarpe/wv/fill.rb +0 -30
- data/lib/scarpe/wv/shape_helper.rb +0 -44
- /data/{lib/scarpe → spikes}/glibui/README.md +0 -0
- /data/{lib/scarpe → spikes}/glibui/alert.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/app.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/background.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/border.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/button.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/dimensions.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/document_root.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/edit_box.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/edit_line.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/flow.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/html.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/image.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/link.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/local_display.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/para.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/spacing.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/stack.rb +0 -0
- /data/{lib/scarpe → spikes}/glibui/text_widget.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/alert.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/button.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/colors.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/core.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/flow.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/libui.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/notepad.md +0 -0
- /data/{lib/scarpe → spikes}/libui/para.rb +0 -0
- /data/{lib/scarpe → spikes}/libui/stack.rb +0 -0
@@ -1,163 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "tempfile"
|
4
|
-
require "json"
|
5
|
-
require "fileutils"
|
6
|
-
|
7
|
-
# Helpers here should *not* use Webview-specific functionality.
|
8
|
-
# The intention is that these are helpers for various Scarpe display
|
9
|
-
# services that do *not* use Webview.
|
10
|
-
|
11
|
-
module Scarpe::Test; end
|
12
|
-
|
13
|
-
# We want test failures set up once *total*, not per Minitest::Test. So an instance var
|
14
|
-
# doesn't do it.
|
15
|
-
ALREADY_SET_UP_LOGGED_TEST_FAILURES = { setup: false }
|
16
|
-
|
17
|
-
# General helpers for general usage
|
18
|
-
module Scarpe::Test::Helpers
|
19
|
-
def with_tempfile(prefix, contents, dir: Dir.tmpdir)
|
20
|
-
t = Tempfile.new(prefix, dir)
|
21
|
-
t.write(contents)
|
22
|
-
t.flush # Make sure the contents are written out
|
23
|
-
|
24
|
-
yield(t.path)
|
25
|
-
ensure
|
26
|
-
t.close
|
27
|
-
t.unlink
|
28
|
-
end
|
29
|
-
|
30
|
-
# Temporarily set env vars for the block of code inside
|
31
|
-
def with_env_vars(envs)
|
32
|
-
old_env = {}
|
33
|
-
envs.each do |k, v|
|
34
|
-
old_env[k] = ENV[k]
|
35
|
-
ENV[k] = v
|
36
|
-
end
|
37
|
-
yield
|
38
|
-
ensure
|
39
|
-
old_env.each { |k, v| ENV[k] = v }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# This test will save extensive logs in case of test failure.
|
44
|
-
# Note that it defines setup/teardown methods. If you want
|
45
|
-
# multiple setup/teardowns from multiple places to happen you
|
46
|
-
# may need to explictly call (e.g. with logged_test_setup/teardown)
|
47
|
-
# to ensure everything you want happens.
|
48
|
-
module Scarpe::Test::LoggedTest
|
49
|
-
LOGGER_DIR = File.expand_path("#{__dir__}/../../logger")
|
50
|
-
|
51
|
-
def file_id
|
52
|
-
"#{self.class.name}_#{self.name}"
|
53
|
-
end
|
54
|
-
|
55
|
-
def logged_test_setup
|
56
|
-
# Make sure test failures will be saved at the end of the run.
|
57
|
-
# Delete stale test failures and logging only the *first* time this is called.
|
58
|
-
set_up_test_failures
|
59
|
-
|
60
|
-
@normal_log_config = Scarpe::Logger.current_log_config
|
61
|
-
Scarpe::Logger.configure_logger(log_config_for_test)
|
62
|
-
|
63
|
-
Scarpe::Logger.logger("LoggedScarpeTest").info("Test: #{self.class.name}##{self.name}")
|
64
|
-
end
|
65
|
-
|
66
|
-
# If you include this module and don't override setup/teardown, everything will
|
67
|
-
# work fine. But if you need more setup/teardown steps, you can do that too.
|
68
|
-
def setup
|
69
|
-
logged_test_setup
|
70
|
-
end
|
71
|
-
|
72
|
-
def logged_test_teardown
|
73
|
-
# Restore previous log config
|
74
|
-
Scarpe::Logger.configure_logger(@normal_log_config)
|
75
|
-
|
76
|
-
if self.failure
|
77
|
-
save_failure_logs
|
78
|
-
else
|
79
|
-
remove_unsaved_logs
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def teardown
|
84
|
-
logged_test_teardown
|
85
|
-
end
|
86
|
-
|
87
|
-
def log_config_for_test
|
88
|
-
{
|
89
|
-
"default" => ["debug", "logger/test_failure_#{file_id}.log"],
|
90
|
-
|
91
|
-
"WebviewAPI" => ["debug", "logger/test_failure_wv_api_#{file_id}.log"],
|
92
|
-
|
93
|
-
"DisplayService" => ["debug", "logger/test_failure_events_#{file_id}.log"],
|
94
|
-
"WV::RelayDisplayService" => ["debug", "logger/test_failure_events_#{file_id}.log"],
|
95
|
-
"WV::WebviewDisplayService" => ["debug", "logger/test_failure_events_#{file_id}.log"],
|
96
|
-
"WV::ControlInterface" => ["debug", "logger/test_failure_events_#{file_id}.log"],
|
97
|
-
}
|
98
|
-
end
|
99
|
-
|
100
|
-
# This could be a lot simpler except I want to only update the file list in one place,
|
101
|
-
# log_config_for_test(). Having a single spot should (I hope) make it a lot friendlier to
|
102
|
-
# add more logfiles for different components, logged API objects, etc.
|
103
|
-
def saved_log_files
|
104
|
-
lc = log_config_for_test
|
105
|
-
log_outfiles = lc.values.map { |_level, loc| loc }
|
106
|
-
log_outfiles.select { |s| s.start_with?("logger/") }.map { |s| s.delete_prefix("logger/") }
|
107
|
-
end
|
108
|
-
|
109
|
-
def set_up_test_failures
|
110
|
-
return if ALREADY_SET_UP_LOGGED_TEST_FAILURES[:setup]
|
111
|
-
|
112
|
-
ALREADY_SET_UP_LOGGED_TEST_FAILURES[:setup] = true
|
113
|
-
# Delete stale test failures, if any, before starting the first failure-logged test
|
114
|
-
Dir["#{LOGGER_DIR}/test_failure*.log"].each { |fn| File.unlink(fn) }
|
115
|
-
|
116
|
-
Minitest.after_run do
|
117
|
-
# Print test failure notice to console
|
118
|
-
unless Dir["#{LOGGER_DIR}/test_failure*.out.log"].empty?
|
119
|
-
puts "Some tests have failed! See #{LOGGER_DIR}/test_failure*.out.log for test logs!"
|
120
|
-
end
|
121
|
-
|
122
|
-
# Remove un-saved test logs
|
123
|
-
Dir["#{LOGGER_DIR}/test_failure*.log"].each do |f|
|
124
|
-
next if f.include?(".out.log")
|
125
|
-
|
126
|
-
File.unlink(f) if File.exist?(f)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def logfail_out_loc(filepath)
|
132
|
-
# Add a .out prefix before final .log
|
133
|
-
out_loc = filepath.gsub(%r{.log\Z}, ".out.log")
|
134
|
-
|
135
|
-
if out_loc == filepath
|
136
|
-
raise "Something is wrong! Could not figure out failure-log output path for #{filepath.inspect}!"
|
137
|
-
end
|
138
|
-
|
139
|
-
if File.exist?(out_loc)
|
140
|
-
raise "Duplicate test file #{out_loc.inspect}? This file should *not* already exist!"
|
141
|
-
end
|
142
|
-
|
143
|
-
out_loc
|
144
|
-
end
|
145
|
-
|
146
|
-
def save_failure_logs
|
147
|
-
saved_log_files.each do |log_file|
|
148
|
-
full_loc = File.expand_path("#{LOGGER_DIR}/#{log_file}")
|
149
|
-
# TODO: we'd like to skip 0-length logfiles. But also Logging doesn't flush. For now, ignore.
|
150
|
-
next unless File.exist?(full_loc)
|
151
|
-
|
152
|
-
FileUtils.mv full_loc, logfail_out_loc(full_loc)
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
def remove_unsaved_logs
|
157
|
-
Dir["#{LOGGER_DIR}/test_failure*.log"].each do |f|
|
158
|
-
next if f.include?(".out.log") # Don't delete saved logs
|
159
|
-
|
160
|
-
File.unlink(f)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
data/lib/scarpe/widgets.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative "colors"
|
4
|
-
require_relative "widget"
|
5
|
-
require_relative "app"
|
6
|
-
|
7
|
-
require_relative "spacing"
|
8
|
-
require_relative "background"
|
9
|
-
require_relative "border"
|
10
|
-
require_relative "star"
|
11
|
-
|
12
|
-
require_relative "fill"
|
13
|
-
|
14
|
-
require_relative "document_root"
|
15
|
-
require_relative "para"
|
16
|
-
require_relative "stack"
|
17
|
-
require_relative "flow"
|
18
|
-
require_relative "button"
|
19
|
-
require_relative "image"
|
20
|
-
require_relative "edit_box"
|
21
|
-
require_relative "edit_line"
|
22
|
-
require_relative "list_box"
|
23
|
-
require_relative "alert"
|
24
|
-
require_relative "span"
|
25
|
-
require_relative "shape"
|
26
|
-
require_relative "arc"
|
27
|
-
|
28
|
-
require_relative "text_widget"
|
29
|
-
require_relative "link"
|
30
|
-
require_relative "line"
|
data/lib/scarpe/wv/fill.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Scarpe
|
4
|
-
class WebviewFill < WebviewWidget
|
5
|
-
def initialize(properties)
|
6
|
-
super(properties)
|
7
|
-
end
|
8
|
-
|
9
|
-
def element
|
10
|
-
width = @parent.get_style[:width]
|
11
|
-
height = @parent.get_style[:height]
|
12
|
-
|
13
|
-
HTML.render do |h|
|
14
|
-
h.div(id: html_id, style: style(width, height)) do
|
15
|
-
@text
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
private
|
21
|
-
|
22
|
-
def style(width, height)
|
23
|
-
styles = {}
|
24
|
-
styles[:width] = width
|
25
|
-
styles[:height] = height
|
26
|
-
styles[:background] = @color if @color
|
27
|
-
styles
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module ShapeHelper
|
4
|
-
def path_commands
|
5
|
-
$path_commands ||= []
|
6
|
-
end
|
7
|
-
|
8
|
-
def move_to(x, y)
|
9
|
-
validate_coordinates(x, y)
|
10
|
-
path_commands << "M #{x} #{y}"
|
11
|
-
end
|
12
|
-
|
13
|
-
def line_to(x, y)
|
14
|
-
validate_coordinates(x, y)
|
15
|
-
path_commands << "L #{x} #{y}"
|
16
|
-
end
|
17
|
-
|
18
|
-
def shape_path
|
19
|
-
path_commands_str = path_commands.join(" ")
|
20
|
-
path_commands_str
|
21
|
-
end
|
22
|
-
|
23
|
-
def colors
|
24
|
-
$colors ||= []
|
25
|
-
end
|
26
|
-
|
27
|
-
def fill(color)
|
28
|
-
$current_color = color
|
29
|
-
end
|
30
|
-
|
31
|
-
def color_for_fill
|
32
|
-
$current_color || "black"
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def validate_coordinates(x, y)
|
38
|
-
raise ArgumentError, "Invalid coordinates: x=#{x}, y=#{y}" unless valid_coordinate?(x) && valid_coordinate?(y)
|
39
|
-
end
|
40
|
-
|
41
|
-
def valid_coordinate?(coordinate)
|
42
|
-
coordinate.is_a?(Numeric)
|
43
|
-
end
|
44
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|