Class: CIRunner::VersionVerifier
- Inherits:
-
Object
- Object
- CIRunner::VersionVerifier
- Defined in:
- lib/ci_runner/version_verifier.rb
Overview
Class used to check if a newer version of CI Runner has been released. This is used to inform the user to update its gem.
The check only runs every week.
Constant Summary collapse
- SEVEN_DAYS =
86_400 * 7
Instance Method Summary collapse
-
#last_checked ⇒ Pathname
Path of a file used to store when we last checked for a release.
-
#new_ci_runner_version? ⇒ Boolean
Check if the user is running the latest version of CI Runner.
-
#upstream_version ⇒ Gem::Version
(also: #fetch_upstream_version)
Makes a request to GitHub to get the latest release on the Edouard-chin/ci_runner repository.
Instance Method Details
#last_checked ⇒ Pathname
Path of a file used to store when we last checked for a release.
40 41 42 |
# File 'lib/ci_runner/version_verifier.rb', line 40 def last_checked Configuration::User.instance.config_directory.join("last-checked") end |
#new_ci_runner_version? ⇒ Boolean
Check if the user is running the latest version of CI Runner.
16 17 18 19 20 21 22 23 |
# File 'lib/ci_runner/version_verifier.rb', line 16 def new_ci_runner_version? return false unless check? fetch_upstream_version FileUtils.touch(last_checked) upstream_version > Gem::Version.new(VERSION) end |
#upstream_version ⇒ Gem::Version Also known as: fetch_upstream_version
Makes a request to GitHub to get the latest release on the Edouard-chin/ci_runner repository
28 29 30 31 32 33 34 |
# File 'lib/ci_runner/version_verifier.rb', line 28 def upstream_version @upstream_version ||= begin release = Client::Github.new(Configuration::User.instance.github_token).latest_release("Edouard-chin/ci_runner") Gem::Version.new(release["tag_name"].sub(/\Av/, "")) end end |