Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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? What about Version.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 from 507b641 to ac78ab2 Compare November 18, 2022 07:51
@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 force-pushed the feature/284-matching branch from a22b1ab to 017bc0b Compare July 2, 2023 07:32
@tomschr tomschr force-pushed the feature/284-matching branch from 017bc0b to 3f20784 Compare July 24, 2023 08:04
@tomschr tomschr force-pushed the feature/284-matching branch from 11d5668 to 4497769 Compare September 16, 2023 09:29
@tomschr tomschr force-pushed the feature/284-matching branch from 4497769 to d9591b6 Compare October 5, 2023 15:25
@tomschr tomschr changed the title Fix #284: Implement tilde and caret matching Fix #241: Implement tilde and caret matching Nov 1, 2023
@tomschr tomschr force-pushed the feature/284-matching branch from d9591b6 to b577366 Compare November 1, 2023 10:33
* 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.

Implement Extended Version Comparisons (Ranges, Hyphens, Tilde...)
2 participants