Class: Mnenv::Gemfile::Fetcher

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

Constant Summary collapse

DOCKER_IMAGE =
'metanorma/metanorma'
API_BASE =
"https://registry.hub.docker.com/v2/repositories/#{DOCKER_IMAGE}/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
# File 'lib/mnenv/gemfile/fetcher.rb', line 13

def fetch_all
  uri = URI("#{API_BASE}?page_size=100")
  versions = []

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

      versions << GemfileVersion.new(
        version: name,
        published_at: parse_timestamp(result['tag_last_pushed'])
      )
    end
    break unless data['next']

    uri = URI(data['next'])
  end

  versions.sort
end