Class: Mnenv::Homebrew::Fetcher

Inherits:
Fetcher
  • Object
show all
Defined in:
lib/mnenv/homebrew/fetcher.rb

Constant Summary collapse

GITHUB_REPO =
'metanorma/homebrew-metanorma'
API_URL =
"https://api.github.com/repos/#{GITHUB_REPO}/tags".freeze

Instance Attribute Summary

Attributes inherited from Fetcher

#repository

Instance Method Summary collapse

Methods inherited from Fetcher

#fetch_and_save, #initialize

Constructor Details

This class inherits a constructor from Mnenv::Fetcher

Instance Method Details

#fetch_allObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mnenv/homebrew/fetcher.rb', line 13

def fetch_all
  uri = URI("#{API_URL}?per_page=100")
  versions = []
  page = 0

  loop do
    data = fetch_json(uri)
    data.each do |tag|
      name = tag['name']
      next unless name.match?(/^v\d+\.\d+\.\d+$/)

      versions << HomebrewVersion.new(
        version: name.sub(/^v/, ''),
        tag_name: name,
        commit_sha: tag['commit']['sha']
      )
    end

    page += 1
    uri = URI("#{API_URL}?per_page=100&page=#{page}")
    break if data.empty?
  end

  versions.sort
end