Class: VersionBoss::Gem::VersionFileFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/version_boss/gem/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.

[
  VersionBoss::Gem::VersionFileSources::Version,
  VersionBoss::Gem::VersionFileSources::VersionRb,
  VersionBoss::Gem::VersionFileSources::Gemspec
].freeze

Class Method Summary collapse

Class Method Details

.findVersionBoss::VersionFile?

Finds the version file for the gem

Examples:

version_file = VersionBoss::Gem::VersionFileFactory.find
version_file.path # => 'lib/version_boss/version.rb'
version_file.version # => '1.2.3'

Returns:

  • (VersionBoss::VersionFile, nil)

    the version file or nil if no version file was found



31
32
33
34
35
36
37
# File 'lib/version_boss/gem/version_file_factory.rb', line 31

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