Repository navigation
fix: return milliseconds from Ruflet.duration - #36
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ruflet.duration(seconds: 2)returned a genericRuflet::Controlof type"Duration"({"_c" => "Duration", "seconds" => 2}) instead of2000.Ruflet::DSL.duration,Ruflet::UI.durationand the top-levelduration(...)were already correct.Cause: the
Rufletmodule forwards helpers tocontrol_delegate, which is aWidgetBuilder.WidgetBuilderhad nodurationmethod, so the call went tomethod_missingand built a control. Passing that into a property put a nested control on the wire. For example,dismissible(movement_duration: Ruflet.duration(milliseconds: 750))sent{"_c":"Duration",...}instead of750.Fix
WidgetBuilder#duration(**parts)now delegates toDSL.duration, the same wayDSL::App#durationalready does. This is a one-method change, with no new syntax and nothing mruby-specific.Usage
Tests
New
packages/ruflet_core/test/duration_helper_test.rb(4 tests). Three failed before the fix.Ruflet.durationreturns milliseconds, and an empty call returns0.Ruflet,Ruflet::UIandWidgetBuilder#durationall agree withRuflet::DSL.duration.durationcall inside a builder block returns an integer and does not add a child control. This passed before the fix too; it guards against a regression.Ruflet.durationused as a control property serializes as an integer.verify_pr.sh(ruflet_core): PASS, 146/146 files, 622 runs. ruflet_server: 11/11.Note:
packages/rufletrun_command_test.rb#test_handle_reload_command_big_r_requests_full_restartis flaky under machine load. It fails 3 of 6 runs on unmodifiedorigin/main, and it is unrelated to this change, which only touches ruflet_core.Engine: no change needed. Durations are already plain integers on the wire.