Class: Semverify::VersionFileFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/semverify/version_file_factory.rb

Overview

Finds the file that contains the gem's version and returns a VersionFile instance

Constant Summary collapse

VERSION_FILE_SOURCES =

The list of VersionFileSources to check for the version file

The order of the list is important. The first VersionFileSource that finds a version file will be used.

[
  Semverify::VersionFileSources::Version,
  Semverify::VersionFileSources::VersionRb,
  Semverify::VersionFileSources::Gemspec
].freeze

Class Method Summary collapse

Class Method Details

.findSemverify::VersionFile?

Finds the version file for the gem

Examples:

version_file = Semverify::VersionFileFactory.find
version_file.path # => 'lib/semverify/version.rb'
version_file.version # => '1.2.3'

Returns:

[View source]

30
31
32
33
34
35
36
# File 'lib/semverify/version_file_factory.rb', line 30

def self.find
  VERSION_FILE_SOURCES.each do |version_file_source|
    version_file = version_file_source.find
    return version_file if version_file
  end
  nil
end