Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
Bilal Al committed May 2, 2024
1 parent 581d6e3 commit 50fe596
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/splitclient-rb/cache/repositories/splits_repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class SplitsRepository < Repository
size: 100
}
],
label: "unsupported matcher type"
label: "targeting rule type unsupported by sdk"
}]

def initialize(config, flag_sets_repository, flag_set_filter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def match?(args)
return false unless verify_semver_arg?(args, 'BetweenSemverMatcher')

value_to_match = SplitIoClient::Semver.build(args[:attributes][@attribute.to_sym], @logger)
unless !value_to_match.nil? && !@semver_start.nil? && !@semver_end.nil?
if value_to_match.nil? || @semver_start.nil? || @semver_end.nil?
@logger.error('betweenStringMatcherData is required for BETWEEN_SEMVER matcher type')
return false

Expand Down
9 changes: 7 additions & 2 deletions lib/splitclient-rb/engine/matchers/in_list_semver_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ def initialize(attribute, list_value, logger, validator)
super(logger)
@validator = validator
@attribute = attribute
@semver_list = list_value.map { |item| SplitIoClient::Semver.build(item, logger) }
@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 unless verify_semver_arg?(args, 'InListSemverMatcher')

value_to_match = SplitIoClient::Semver.build(args[:attributes][@attribute.to_sym], @logger)
unless !value_to_match.nil? && @semver_list.all? { |n| !n.nil? }
if value_to_match.nil?
@logger.error('whitelistMatcherData is required for IN_LIST_SEMVER matcher type')
return false
end
Expand Down
3 changes: 2 additions & 1 deletion lib/splitclient-rb/engine/matchers/semver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def compare(to_compare)
return 0 if @version == to_compare.version

# Compare major, minor, and patch versions numerically
return compare_attributes(to_compare) if compare_attributes(to_compare) != 0
result = compare_attributes(to_compare)
return result if result != 0

# Compare pre-release versions lexically
compare_pre_release(to_compare)
Expand Down

0 comments on commit 50fe596

Please sign in to comment.