Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #241: Implement tilde and caret matching #367

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

tomschr
Copy link
Member

@tomschr tomschr commented Nov 15, 2022

  • Introduce Spec class to deal with such comparisons
  • Improve documentation
  • Simplify code in Version.match (delegates to Spec.match)

Implementation Questions

  • Is the Spec class the right approach here? Any other options?
  • Should we use different names for Spec.match?
  • Is the VersionRegex class a good idea? It shares some constant regexes between Version and Spec. Or should we better use just variables and share those?
  • The Spec class supports operators like Spec("1.*") == Version(1, 2, 3). I'm wondering if this is useful as we can't use the same for ~ and ^. If we remove operators, the code gets a bit smaller, but then we have to call Spec.match. Good, bad?
  • In the (hopefully near) future, I would like to create a SpecSet class to support extended ranges like <=1.2.3 || >=2.3.4. Any design decisions that should be implemented in regards to this?
  • Where and how could we improve the code?

@tomschr tomschr added Release_3.x.y Only for the major release 3 Enhancement Not a bug, but increases or improves in value, quality, desirability, or attractiveness labels Nov 15, 2022
@tomschr tomschr self-assigned this Nov 15, 2022
@tomschr tomschr requested a review from a team November 15, 2022 20:50
@Lexicality
Copy link
Contributor

My specific use-case was an event processor that routed messages based on their semver number, so for example, everything matching ~=1.2 would go to the latest event handler, ==1.1.* to a legacy handler and so on.
Ultimately I hacked something together and have since left the company, so it doesn't really matter to me anymore 😅

However, I will say that I really don't like operator overloading and much prefer a match method or similar.

@tomschr
Copy link
Member Author

tomschr commented Nov 16, 2022

However, I will say that I really don't like operator overloading and much prefer a match method or similar.

Yeah, that's also one of the questions where I'm unsure about that. 🤔

@tomschr tomschr force-pushed the feature/284-matching branch 7 times, most recently from 5d9f68e to a22b1ab Compare March 7, 2023 07:06
@tomschr tomschr changed the title Fix #284: Implement tilde and caret matching Fix #241: Implement tilde and caret matching Nov 1, 2023
* Introduce Spec class to deal with such comparisons
* Improve documentation
* Simplify code in Version.match (delegates to Spec.match)
* Rename _MAJOR, _MINOR, _PATCH, _PRERELEASE, and _BUILD and
  remove the "_" prefix
* Change _REGEX, _REGEX_TEMPLATE, and _REGEX_OPTIONAL_MINOR_AND_PATCH
  and remove the "_" prefix
From Version to VersionRegex
* Remove unused Int_or_Str type
* Reuse String in SpecComparable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Not a bug, but increases or improves in value, quality, desirability, or attractiveness Release_3.x.y Only for the major release 3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants