Class: Mangadex::Api::Version

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/mangadex/api/version_checker.rb

Class Method Summary collapse

Class Method Details

.check_mangadex_versionObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mangadex/api/version_checker.rb', line 10

def self.check_mangadex_version
  puts("Checking Mangadex's latest API version...")
  version = Psych.load(
    RestClient.get(
      'https://api.mangadex.org/api.yaml',
    ).body,
  ).dig('info', 'version')

  if version != Mangadex::Version::STRING
    warn(
      "[Warning] This gem is compatible with #{Mangadex::Version::STRING} but it looks like Mangadex is at #{version}",
      "[Warning] Check out #{Mangadex::Internal::Request::BASE_URI} for more information.",
    )
  end

  version
rescue => error
  nil
end