lacci 0.3.0 → 0.5.0

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 (48) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -2
  3. data/Gemfile.lock +4 -32
  4. data/lib/lacci/scarpe_cli.rb +0 -1
  5. data/lib/lacci/version.rb +1 -1
  6. data/lib/scarpe/niente/app.rb +12 -1
  7. data/lib/scarpe/niente/display_service.rb +5 -1
  8. data/lib/scarpe/niente/drawable.rb +2 -0
  9. data/lib/scarpe/niente/shoes_spec.rb +10 -5
  10. data/lib/scarpe/niente.rb +15 -2
  11. data/lib/shoes/app.rb +204 -105
  12. data/lib/shoes/constants.rb +24 -2
  13. data/lib/shoes/display_service.rb +43 -4
  14. data/lib/shoes/drawable.rb +326 -36
  15. data/lib/shoes/drawables/arc.rb +4 -26
  16. data/lib/shoes/drawables/arrow.rb +3 -23
  17. data/lib/shoes/drawables/border.rb +28 -0
  18. data/lib/shoes/drawables/button.rb +5 -21
  19. data/lib/shoes/drawables/check.rb +7 -3
  20. data/lib/shoes/drawables/document_root.rb +4 -4
  21. data/lib/shoes/drawables/edit_box.rb +6 -5
  22. data/lib/shoes/drawables/edit_line.rb +5 -4
  23. data/lib/shoes/drawables/flow.rb +4 -6
  24. data/lib/shoes/drawables/font_helper.rb +62 -0
  25. data/lib/shoes/drawables/image.rb +2 -2
  26. data/lib/shoes/drawables/line.rb +3 -6
  27. data/lib/shoes/drawables/link.rb +16 -9
  28. data/lib/shoes/drawables/list_box.rb +8 -5
  29. data/lib/shoes/drawables/oval.rb +48 -0
  30. data/lib/shoes/drawables/para.rb +106 -18
  31. data/lib/shoes/drawables/progress.rb +2 -1
  32. data/lib/shoes/drawables/radio.rb +5 -3
  33. data/lib/shoes/drawables/rect.rb +7 -6
  34. data/lib/shoes/drawables/shape.rb +4 -3
  35. data/lib/shoes/drawables/slot.rb +102 -9
  36. data/lib/shoes/drawables/stack.rb +7 -12
  37. data/lib/shoes/drawables/star.rb +9 -31
  38. data/lib/shoes/drawables/text_drawable.rb +93 -34
  39. data/lib/shoes/drawables/video.rb +3 -2
  40. data/lib/shoes/drawables/widget.rb +9 -4
  41. data/lib/shoes/drawables.rb +2 -1
  42. data/lib/shoes/errors.rb +13 -3
  43. data/lib/shoes/margin_helper.rb +79 -0
  44. data/lib/shoes.rb +98 -20
  45. metadata +11 -15
  46. data/lib/scarpe/niente/logger.rb +0 -29
  47. data/lib/shoes/drawables/span.rb +0 -27
  48. data/lib/shoes/spacing.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e32d4245e4dc24e8098d8626ca2ad9ba7d4417b6e392d0c0d43c1b003dece24e
4
- data.tar.gz: dea4cd304311e63c498e2c679e8d61ec9b550c56c5a87d33bb4c7b499a08b875
3
+ metadata.gz: e4b8a6a22600196c15c5ed8abbb7710bcc2d24fd2842aaa9190af738ef1e1802
4
+ data.tar.gz: 9bc49da62c2eea40133ca5d0cb01a3af7bec21d0d605478da5c235ce4a34c7a4
5
5
  SHA512:
6
- metadata.gz: 360b04b248cc6011c5a37ca50d284d37d1aebd42f60aa15b7eb3f8b47933faca0d5b6738ae462b3cc67bf9b56b3bd426cb375fa8640111ec00a42a01a5aeaf55
7
- data.tar.gz: 7ef67d55690c0b3ffe845edf747a86a1561dd2aced210d2a870df87f0140eb8aaaab8abbe03212da9557488de655944ecc9d54637679420dc1d8b5594143a5a6
6
+ metadata.gz: 77de9f93d6495c6d0092eaf39bc36d46492a4f32725c3d5b2eb2dc07992cb31c21a10489eea8e77d29144dbbdd1daad8b12b8ccfb42bee1124579a8c0c34dbbb
7
+ data.tar.gz: fa322933a6da6fd7f831ac8490ec5b519f4e93f740fb35dcddf973562abfd81efa7f5cc9c89c4dd4d23f33dbdc35b59b90f9c217708d0c3e168d0658419ac85e
data/Gemfile CHANGED
@@ -17,8 +17,6 @@ group :development do
17
17
  gem "yard"
18
18
  gem "redcarpet"
19
19
  gem "debug"
20
- gem "rubocop", "~> 1.21"
21
- gem "rubocop-shopify"
22
20
  #gem "commonmarker"
23
21
  #gem "github-markup"
24
22
  end
data/Gemfile.lock CHANGED
@@ -1,19 +1,18 @@
1
1
  PATH
2
2
  remote: ../scarpe-components
3
3
  specs:
4
- scarpe-components (0.3.0)
4
+ scarpe-components (0.4.0)
5
5
 
6
6
  PATH
7
7
  remote: .
8
8
  specs:
9
- lacci (0.3.0)
10
- scarpe-components
9
+ lacci (0.4.0)
10
+ scarpe-components (~> 0.4.0)
11
11
 
12
12
  GEM
13
13
  remote: https://rubygems.org/
14
14
  specs:
15
15
  ansi (1.5.0)
16
- ast (2.4.2)
17
16
  builder (3.2.4)
18
17
  debug (1.8.0)
19
18
  irb (>= 1.5.0)
@@ -21,46 +20,21 @@ GEM
21
20
  io-console (0.6.0)
22
21
  irb (1.7.2)
23
22
  reline (>= 0.3.6)
24
- json (2.6.3)
25
- language_server-protocol (3.17.0.3)
26
23
  minitest (5.18.1)
27
24
  minitest-reporters (1.6.0)
28
25
  ansi
29
26
  builder
30
27
  minitest (>= 5.0)
31
28
  ruby-progressbar
32
- parallel (1.23.0)
33
- parser (3.2.2.3)
34
- ast (~> 2.4.1)
35
- racc
36
- racc (1.7.1)
37
- rainbow (3.1.1)
38
29
  rake (13.0.6)
39
30
  redcarpet (3.6.0)
40
- regexp_parser (2.8.1)
41
31
  reline (0.3.6)
42
32
  io-console (~> 0.5)
43
- rexml (3.2.5)
44
- rubocop (1.54.1)
45
- json (~> 2.3)
46
- language_server-protocol (>= 3.17.0)
47
- parallel (~> 1.10)
48
- parser (>= 3.2.2.3)
49
- rainbow (>= 2.2.2, < 4.0)
50
- regexp_parser (>= 1.8, < 3.0)
51
- rexml (>= 3.2.5, < 4.0)
52
- rubocop-ast (>= 1.28.0, < 2.0)
53
- ruby-progressbar (~> 1.7)
54
- unicode-display_width (>= 2.4.0, < 3.0)
55
- rubocop-ast (1.29.0)
56
- parser (>= 3.2.1.0)
57
- rubocop-shopify (2.14.0)
58
- rubocop (~> 1.51)
59
33
  ruby-progressbar (1.13.0)
60
- unicode-display_width (2.4.2)
61
34
  yard (0.9.34)
62
35
 
63
36
  PLATFORMS
37
+ arm64-darwin-21
64
38
  x86_64-darwin-22
65
39
 
66
40
  DEPENDENCIES
@@ -70,8 +44,6 @@ DEPENDENCIES
70
44
  minitest-reporters
71
45
  rake (~> 13.0)
72
46
  redcarpet
73
- rubocop (~> 1.21)
74
- rubocop-shopify
75
47
  scarpe-components!
76
48
  yard
77
49
 
@@ -28,7 +28,6 @@ module Scarpe
28
28
  "Lacci" => [
29
29
  env_or_default("SCARPE_DISPLAY_SERVICE", "(none)"),
30
30
  env_or_default("SCARPE_LOG_CONFIG", "(default)#{Shoes::Log::DEFAULT_LOG_CONFIG.inspect}"),
31
- env_or_default("SCARPE_APP_TEST", "(none)"),
32
31
  ],
33
32
  "Ruby and Shell" => [
34
33
  ["RUBY_DESCRIPTION", RUBY_DESCRIPTION],
data/lib/lacci/version.rb CHANGED
@@ -9,5 +9,5 @@
9
9
  # mostly invisible. Instead, look at the {Shoes} module
10
10
  # to see what's in Lacci.
11
11
  module Lacci
12
- VERSION = "0.3.0"
12
+ VERSION = "0.5.0"
13
13
  end
@@ -14,7 +14,18 @@ module Niente
14
14
  end
15
15
 
16
16
  def run
17
- send_shoes_event("wait", event_name: "custom_event_loop")
17
+ send_shoes_event("return", event_name: "custom_event_loop")
18
+
19
+ @do_shutdown = false
20
+ bind_shoes_event(event_name: "destroy") do
21
+ @do_shutdown = true
22
+ end
23
+
24
+ at_exit do
25
+ until @do_shutdown
26
+ Shoes::DisplayService.dispatch_event("heartbeat", nil)
27
+ end
28
+ end
18
29
  end
19
30
 
20
31
  def destroy
@@ -29,7 +29,7 @@ module Niente
29
29
  # @param properties [Hash] a JSON-serialisable Hash with the drawable's Shoes styles
30
30
  # @param is_widget [Boolean] whether the class is a user-defined Shoes::Widget subclass
31
31
  # @return [Webview::Drawable] the newly-created Webview drawable
32
- def create_display_drawable_for(drawable_class_name, drawable_id, properties, is_widget:)
32
+ def create_display_drawable_for(drawable_class_name, drawable_id, properties, parent_id:, is_widget:)
33
33
  existing = query_display_drawable_for(drawable_id, nil_ok: true)
34
34
  if existing
35
35
  @log.warn("There is already a display drawable for #{drawable_id.inspect}! Returning #{existing.class.name}.")
@@ -47,6 +47,10 @@ module Niente
47
47
  display_drawable.shoes_type = drawable_class_name
48
48
  set_drawable_pairing(drawable_id, display_drawable)
49
49
 
50
+ # Nil parent is okay for DocumentRoot and TextDrawables, so we have to specify it.
51
+ parent = DisplayService.instance.query_display_drawable_for(parent_id, nil_ok: true)
52
+ display_drawable.set_parent(parent)
53
+
50
54
  return display_drawable
51
55
  end
52
56
 
@@ -12,6 +12,7 @@ module Niente
12
12
 
13
13
  super(linkable_id: @shoes_linkable_id)
14
14
 
15
+ # This should only be used for reparenting after a drawable was initially created.
15
16
  bind_shoes_event(event_name: "parent", target: shoes_linkable_id) do |new_parent_id|
16
17
  display_parent = DisplayService.instance.query_display_drawable_for(new_parent_id)
17
18
  if @parent != display_parent
@@ -28,6 +29,7 @@ module Niente
28
29
  end
29
30
 
30
31
  bind_shoes_event(event_name: "destroy", target: shoes_linkable_id) do
32
+ set_parent(nil)
31
33
  end
32
34
  end
33
35
 
@@ -8,7 +8,7 @@ module Niente; end
8
8
  class Niente::Test
9
9
  def self.run_shoes_spec_test_code(code, class_name: nil, test_name: nil)
10
10
  if @shoes_spec_init
11
- raise Shoes::Errors::MultipleShoesSpecRunsError, "Scarpe-Webview can only run a single Shoes spec per process!"
11
+ raise Shoes::Errors::MultipleShoesSpecRunsError, "Niente can only run a single Shoes spec per process!"
12
12
  end
13
13
  @shoes_spec_init = true
14
14
 
@@ -21,7 +21,7 @@ class Niente::Test
21
21
  Shoes::DisplayService.subscribe_to_event("heartbeat", nil) do
22
22
  unless @hb_init
23
23
  Minitest.run []
24
- Shoes::App.instance.destroy
24
+ Shoes.APPS.each(&:destroy)
25
25
  end
26
26
  @hb_init = true
27
27
  end
@@ -30,7 +30,6 @@ class Niente::Test
30
30
  Object.const_set(Scarpe::Components::StringHelpers.camelize(class_name), test_class)
31
31
  test_name = "test_" + test_name unless test_name.start_with?("test_")
32
32
  test_class.define_method(test_name) do
33
- STDERR.puts "Started running #{class_name.inspect}::#{test_name.inspect}"
34
33
  eval(code)
35
34
  end
36
35
  end
@@ -41,15 +40,21 @@ class Niente::ShoesSpecTest < Minitest::Test
41
40
  finder_name = drawable_class.dsl_name
42
41
 
43
42
  define_method(finder_name) do |*args|
44
- app = Shoes::App.instance
43
+ drawables = Shoes::App.find_drawables_by(drawable_class, *args)
45
44
 
46
- drawables = app.find_drawables_by(drawable_class, *args)
47
45
  raise Shoes::Errors::MultipleDrawablesFoundError, "Found more than one #{finder_name} matching #{args.inspect}!" if drawables.size > 1
48
46
  raise Shoes::Errors::NoDrawablesFoundError, "Found no #{finder_name} matching #{args.inspect}!" if drawables.empty?
49
47
 
50
48
  Niente::ShoesSpecProxy.new(drawables[0])
51
49
  end
52
50
  end
51
+
52
+ def drawable(*specs)
53
+ drawables = Shoes::App.find_drawables_by(*specs)
54
+ raise Shoes::Errors::MultipleDrawablesFoundError, "Found more than one #{finder_name} matching #{args.inspect}!" if drawables.size > 1
55
+ raise Shoes::Errors::NoDrawablesFoundError, "Found no #{finder_name} matching #{args.inspect}!" if drawables.empty?
56
+ Niente::ShoesSpecProxy.new(drawables[0])
57
+ end
53
58
  end
54
59
 
55
60
  class Niente::ShoesSpecProxy
data/lib/scarpe/niente.rb CHANGED
@@ -6,8 +6,16 @@
6
6
  # how a real display service should act.
7
7
  module Niente; end
8
8
 
9
- require_relative "niente/logger"
10
- Shoes::Log.instance = Niente::LogImpl.new
9
+ require "scarpe/components/print_logger"
10
+ Shoes::Log.instance = Scarpe::Components::PrintLogImpl.new
11
+ if ENV["NIENTE_LOG_LEVEL"]
12
+ pl = Scarpe::Components::PrintLogImpl::PrintLogger
13
+ level = ENV["NIENTE_LOG_LEVEL"].strip.downcase.to_sym
14
+ unless pl::LEVELS.key?(level)
15
+ raise "Unrecognized Niente log level: #{level.inspect}!"
16
+ end
17
+ pl.min_level = pl::LEVELS[level]
18
+ end
11
19
 
12
20
  require_relative "niente/drawable"
13
21
  require_relative "niente/app"
@@ -16,5 +24,10 @@ require_relative "niente/display_service"
16
24
  require_relative "niente/shoes_spec"
17
25
  Shoes::Spec.instance = Niente::Test
18
26
 
27
+ require "scarpe/components/segmented_file_loader"
28
+ loader = Scarpe::Components::SegmentedFileLoader.new
29
+ Shoes.add_file_loader loader
30
+
19
31
  Shoes::DisplayService.set_display_service_class(Niente::DisplayService)
20
32
 
33
+ Shoes::FEATURES.push(:multi_app)