-
Notifications
You must be signed in to change notification settings - Fork 15
Feature/semver #532
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
Merged
Merged
Feature/semver #532
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
2968a19
added undefined matcher flow
5cbe5dc
polish
c770cff
Merge pull request #510 from splitio/undefined-matcher
chillaq 75cc222
added semver class
21f408b
polish
6b83afc
added equalto semver matcher
93d73b0
polish
45fbd0b
polish
8aa6bb9
added greater than or equal to semver matcher
30232f8
added less than or equal semver matcher
2f95e4b
added semver between matcher
2749c65
added in list semver matcher
7fd6f34
polish
e9677d9
fixed matcher logic
dc0caa6
fixed matcher logic
9f1b7d9
semver matchers integrations spec
8a1d214
Used csv for spec and added builder for semver class
f12ee2a
added csv files
acad113
updated using build for semver class
1e4a238
used build for semver class
8bf838b
used build for semver class
cf60f11
used build for semver class
61b8c9e
fixed condition
8cc7ff5
Merge pull request #514 from splitio/semver-class
chillaq f875912
Merge pull request #516 from splitio/semver-equalto-matcher
chillaq 608c259
Merge pull request #517 from splitio/semver-greater-or-equalto-matcher
chillaq 229a9f7
Merge pull request #518 from splitio/semver-less-or-equalto-matcher
chillaq 89826a3
Merge pull request #519 from splitio/semver-between-matcher
chillaq f76b944
Merge pull request #521 from splitio/semver-integration-spec
chillaq 980c272
added version attribute and used it in compare
b9e8fd8
updated semver spec
b1529d2
Fixed compare logic in semver, equalto and inlist matchers.
a8761d7
Added nil check for all matchers and updated specs
5a084a8
polish
a302223
Merge branch 'Feature/Semver' into semver-inlist-matcher
chillaq 7ec5da7
added version length check for compare
4ecad51
correcting specs and comparisons
a1cab94
Merge pull request #525 from splitio/semver-inlist-matcher
chillaq 0f5ac2f
Merge branch 'development' into Feature/Semver
chillaq db9311a
updated query api order, fixed spec and added error to split logger
418e5d7
added debug to split logger
b7ecdd1
update debug logging in semver matchers
1bc71a5
fixed spec
abea9d2
polishing
581d6e3
polish
50fe596
polish
2a54d08
polish and test update
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
33 changes: 33 additions & 0 deletions
33
lib/splitclient-rb/engine/matchers/between_semver_matcher.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module SplitIoClient | ||
| class BetweenSemverMatcher < Matcher | ||
| MATCHER_TYPE = 'BETWEEN_SEMVER' | ||
|
|
||
| attr_reader :attribute | ||
|
|
||
| def initialize(attribute, start_value, end_value, logger, validator) | ||
| super(logger) | ||
| @validator = validator | ||
| @attribute = attribute | ||
| @semver_start = SplitIoClient::Semver.build(start_value, logger) | ||
| @semver_end = SplitIoClient::Semver.build(end_value, logger) | ||
| @logger = logger | ||
| end | ||
|
|
||
| def match?(args) | ||
| return false unless verify_semver_arg?(args, 'BetweenSemverMatcher') | ||
|
|
||
| value_to_match = SplitIoClient::Semver.build(args[:attributes][@attribute.to_sym], @logger) | ||
| if value_to_match.nil? || @semver_start.nil? || @semver_end.nil? | ||
| @logger.error('betweenStringMatcherData is required for BETWEEN_SEMVER matcher type') | ||
| return false | ||
|
|
||
| end | ||
| matches = ([0, -1].include?(@semver_start.compare(value_to_match)) && | ||
| [0, 1].include?(@semver_end.compare(value_to_match))) | ||
| @logger.debug("[BetweenMatcher] #{value_to_match} matches -> #{matches}") | ||
| matches | ||
| end | ||
| end | ||
| end | ||
28 changes: 28 additions & 0 deletions
28
lib/splitclient-rb/engine/matchers/equal_to_semver_matcher.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module SplitIoClient | ||
| class EqualToSemverMatcher < Matcher | ||
| MATCHER_TYPE = 'EQUAL_TO_SEMVER' | ||
|
|
||
| attr_reader :attribute | ||
|
|
||
| def initialize(attribute, string_value, logger, validator) | ||
| super(logger) | ||
| @validator = validator | ||
| @attribute = attribute | ||
| @semver = SplitIoClient::Semver.build(string_value, logger) | ||
| @logger = logger | ||
| end | ||
|
|
||
| def match?(args) | ||
| return false unless verify_semver_arg?(args, 'EqualsToSemverMatcher') | ||
|
|
||
| value_to_match = SplitIoClient::Semver.build(args[:attributes][@attribute.to_sym], @logger) | ||
| return false unless check_semver_value_to_match(value_to_match, MATCHER_TYPE) | ||
|
|
||
| matches = (@semver.version == value_to_match.version) | ||
| @logger.debug("[EqualsToSemverMatcher] #{value_to_match} matches -> #{matches}") | ||
| matches | ||
| end | ||
| end | ||
| end |
28 changes: 28 additions & 0 deletions
28
lib/splitclient-rb/engine/matchers/greater_than_or_equal_to_semver_matcher.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module SplitIoClient | ||
| class GreaterThanOrEqualToSemverMatcher < Matcher | ||
| MATCHER_TYPE = 'GREATER_THAN_OR_EQUAL_TO_SEMVER' | ||
|
|
||
| attr_reader :attribute | ||
|
|
||
| def initialize(attribute, string_value, logger, validator) | ||
| super(logger) | ||
| @validator = validator | ||
| @attribute = attribute | ||
| @semver = SplitIoClient::Semver.build(string_value, logger) | ||
| @logger = logger | ||
| end | ||
|
|
||
| def match?(args) | ||
| return false unless verify_semver_arg?(args, 'GreaterThanOrEqualsToSemverMatcher') | ||
|
|
||
| value_to_match = SplitIoClient::Semver.build(args[:attributes][@attribute.to_sym], @logger) | ||
| return false unless check_semver_value_to_match(value_to_match, MATCHER_TYPE) | ||
|
|
||
| matches = [0, 1].include?(value_to_match.compare(@semver)) | ||
| @logger.debug("[GreaterThanOrEqualsToSemverMatcher] #{value_to_match} matches -> #{matches}") | ||
| matches | ||
| end | ||
| end | ||
| end |
36 changes: 36 additions & 0 deletions
36
lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module SplitIoClient | ||
| class InListSemverMatcher < Matcher | ||
| MATCHER_TYPE = 'IN_LIST_SEMVER' | ||
|
|
||
| attr_reader :attribute | ||
|
|
||
| def initialize(attribute, list_value, logger, validator) | ||
| super(logger) | ||
| @validator = validator | ||
| @attribute = attribute | ||
| @semver_list = [] | ||
|
|
||
| list_value.map do |item| | ||
| version = SplitIoClient::Semver.build(item, logger) | ||
| @semver_list << version unless version.nil? | ||
| end | ||
| @logger = logger | ||
| end | ||
|
|
||
| def match?(args) | ||
| return false if @semver_list.empty? || !verify_semver_arg?(args, 'InListSemverMatcher') | ||
|
|
||
| value_to_match = SplitIoClient::Semver.build(args[:attributes][@attribute.to_sym], @logger) | ||
| if value_to_match.nil? | ||
| @logger.error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type') | ||
| return false | ||
|
|
||
| end | ||
| matches = (@semver_list.map { |item| item.version == value_to_match.version }).any? { |item| item == true } | ||
| @logger.debug("[InListSemverMatcher] #{value_to_match} matches -> #{matches}") | ||
| matches | ||
| end | ||
| end | ||
| end |
28 changes: 28 additions & 0 deletions
28
lib/splitclient-rb/engine/matchers/less_than_or_equal_to_semver_matcher.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module SplitIoClient | ||
| class LessThanOrEqualToSemverMatcher < Matcher | ||
| MATCHER_TYPE = 'LESS_THAN_OR_EQUAL_TO_SEMVER' | ||
|
|
||
| attr_reader :attribute | ||
|
|
||
| def initialize(attribute, string_value, logger, validator) | ||
| super(logger) | ||
| @validator = validator | ||
| @attribute = attribute | ||
| @semver = SplitIoClient::Semver.build(string_value, logger) | ||
| @logger = logger | ||
| end | ||
|
|
||
| def match?(args) | ||
| return false unless verify_semver_arg?(args, 'LessThanOrEqualsToSemverMatcher') | ||
|
|
||
| value_to_match = SplitIoClient::Semver.build(args[:attributes][@attribute.to_sym], @logger) | ||
| return false unless check_semver_value_to_match(value_to_match, MATCHER_TYPE) | ||
|
|
||
| matches = [0, -1].include?(value_to_match.compare(@semver)) | ||
| @logger.debug("[LessThanOrEqualsToSemverMatcher] #{value_to_match} matches -> #{matches}") | ||
| matches | ||
| end | ||
| end | ||
| end |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,5 +30,23 @@ def equals?(obj) | |
| def string_type? | ||
| false | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def verify_semver_arg?(args, matcher_name) | ||
| @logger.debug("[#{matcher_name}] evaluating value and attributes.") | ||
| return false unless @validator.valid_matcher_arguments(args) | ||
|
|
||
| true | ||
| end | ||
|
|
||
| def check_semver_value_to_match(value_to_match, matcher_spec_name) | ||
| if value_to_match.nil? || @semver.nil? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. are you sure about the scope of |
||
| @logger.error("stringMatcherData is required for #{matcher_spec_name} matcher type") | ||
| return false | ||
|
|
||
| end | ||
| true | ||
| end | ||
| end | ||
| end | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.