Skip to content

Commit

Permalink
Extract regex as constant
Browse files Browse the repository at this point in the history
  • Loading branch information
mctofu committed May 5, 2021
1 parent 81322f0 commit 9e402ae
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class LatestVersionFinder
/Repository not found/,
/unrecognized import path/
].freeze
PSEUDO_VERSION_REGEX = /\b\d{14}-[0-9a-f]{12}$/.freeze

def initialize(dependency:, dependency_files:, credentials:,
ignored_versions:, raise_on_ignored: false)
Expand All @@ -38,8 +39,7 @@ def latest_version
attr_reader :dependency, :dependency_files, :credentials, :ignored_versions

def fetch_latest_version
pseudo_version_regex = /\b\d{14}-[0-9a-f]{12}$/
return dependency.version if dependency.version =~ pseudo_version_regex
return dependency.version if dependency.version =~ PSEUDO_VERSION_REGEX

candidate_versions = available_versions
candidate_versions = filter_prerelease_versions(candidate_versions)
Expand Down

0 comments on commit 9e402ae

Please sign in to comment.