class LockDiff::Github::TagFinder
Public Class Methods
new(repository:, package_name:, version:)
click to toggle source
# File lib/lock_diff/github/tag_finder.rb, line 4 def initialize(repository:, package_name:, version:) @repository = repository @package_name = package_name @version_str = version.to_s end
Public Instance Methods
call()
click to toggle source
# File lib/lock_diff/github/tag_finder.rb, line 10 def call find_tag(limit: 4, per_page: 50) end
Private Instance Methods
find_tag(page: 1, limit:, per_page:)
click to toggle source
# File lib/lock_diff/github/tag_finder.rb, line 16 def find_tag(page: 1, limit:, per_page:) return nil if page > limit fetched_tags = TagsRepository.find(@repository, page: page, per_page: per_page) tag = fetched_tags.find { |tag_name| match_rule?(tag_name) } return tag if tag unless fetched_tags.count < per_page find_tag(page: page + 1, limit: limit, per_page: per_page) end end
match_rule?(tag_name)
click to toggle source
# File lib/lock_diff/github/tag_finder.rb, line 29 def match_rule?(tag_name) [ @version_str, "v#{@version_str}", "#{@package_name}-#{@version_str}", "#{@package_name.downcase}-#{@version_str}" ].include?(tag_name) end