Repository navigation
Add margin's :flush option, Paramix and String::Mask - #347
Merged
Merged
Conversation
With :flush, every line that isn't blank gets the same margin, and relative indentation isn't kept. This is what String#tab did before it was removed in 3.1.0, except that blank lines are left alone and leading tabs count as indentation. tapout, turn and dnote each carry a copy of tab. Fill out margin's tests, which had one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Paramix::Parametric makes a module take parameters where it is included or extended: include M[:name => 'x']. It was part of Facets until 2.7.0, when it became the Paramix gem; this is that gem's version, with tests from its demos. In the mixin, public, private and protected still define a method when given a block, and now also take names alone, as Module's own do. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A mask is a string in which some characters are empty slots; masks combine character by character with +, -, *, & and ^. It was Facets' string/mask until 2.7.0, when it became the Strmask gem. It is loaded with require 'facets/string/mask', not by require 'facets'. Changed from the gem: - Masks of different lengths combine, the shorter one's missing characters counting as empty. The gem raised a TypeError when the second was shorter, and cut the result short when the first was. - A mask can be made without an empty-slot character; the gem's to_s and inspect raised for one. - hash and eql? are defined, so equal masks are the same hash key. - apply works: it called String#to_mask and Functor, neither of which the gem defined. - Only methods a string has are passed on to it, and respond_to? agrees. The gem rescued NoMethodError around the call, which hid errors raised inside the method. - It works under frozen string literals. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A mask compared equal to an ordinary string read as a mask, so it was equal to both its printed and its internal form, which aren't equal to each other, and == disagreed with eql?. Compare mask.to_s with a string instead. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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.
Three additions for 4.2.0, found while going through the other Rubyworks projects. One commit each.
String#margintakes:flushEvery line that isn't blank gets the same margin. This is what
String#tabdid before it was removed in 3.1.0 (tapout, turn and dnote still carry copies), except that blank lines are left alone and leading tabs count as indentation.String#tabtois not restored: it ismargin(n, lead: true).marginhad one test; it now has ten.Paramix::Parametric(standard,require 'facets/paramix')Parametric mixins:
include Greeter[:name => 'x']. Part of Facets until 2.7.0, then the Paramix gem; this is the gem's code, with tests taken from its demos. One change: in the mixin,public,privateandprotectedstill define a method when given a block, and now also take names alone asModule's own do.String::MaskandString#mask(core, opt-in,require 'facets/string/mask')Facets'
string/maskuntil 2.7.0, then the Strmask gem. Not loaded byrequire 'facets'; listed as# uncommoninfacets/string.rb. Changed from the gem:TypeErrorwhen the second was shorter, and cut the result short when the first was.to_sraised for one.hashandeql?are defined, so equal masks are the same hash key.applyworks. It calledString#to_maskandFunctor, which the gem didn't define.respond_to?agrees.mask.to_swith a string. The gem compared a string with the mask's internal form.Checks
rake test(1510 tests, with the same 4 pending as on main) andrake qed:codepass on Ruby 3.4.9.🤖 Generated with Claude Code