Class: CompareLinker::GithubTagFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/compare_linker/github_tag_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(octokit, gem_name, repo_full_name) ⇒ GithubTagFinder

Returns a new instance of GithubTagFinder.



5
6
7
8
9
# File 'lib/compare_linker/github_tag_finder.rb', line 5

def initialize(octokit, gem_name, repo_full_name)
  @octokit = octokit
  @gem_name = gem_name
  @repo_full_name = repo_full_name
end

Instance Attribute Details

#gem_nameObject (readonly)

Returns the value of attribute gem_name.



3
4
5
# File 'lib/compare_linker/github_tag_finder.rb', line 3

def gem_name
  @gem_name
end

#octokitObject (readonly)

Returns the value of attribute octokit.



3
4
5
# File 'lib/compare_linker/github_tag_finder.rb', line 3

def octokit
  @octokit
end

#repo_full_nameObject (readonly)

Returns the value of attribute repo_full_name.



3
4
5
# File 'lib/compare_linker/github_tag_finder.rb', line 3

def repo_full_name
  @repo_full_name
end

Instance Method Details

#find(gem_version) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/compare_linker/github_tag_finder.rb', line 11

def find(gem_version)
  tags = auto_paginate { octokit.tags(repo_full_name) }
  if tags
    tags.find { |tag|
      tag.name == gem_version ||
        tag.name == "v#{gem_version}" ||
        tag.name == "#{gem_name}-#{gem_version}"
    }
  end
end