Class: VersionBoss::Gem::VersionFileSources::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/version_boss/gem/version_file_sources/base.rb

Overview

Base class for a version file source which implements #find

Direct Known Subclasses

Gemspec, Version, VersionRb

Class Method Summary collapse

Class Method Details

.findVersionBoss::Gem::VersionFile?

The first file from #glob whose content matches #content_regexp

Examples:

version_file = VersionBoss::Gem::VersionFileSources::Gemspec.find

Returns:



20
21
22
23
24
25
26
27
28
29
# File 'lib/version_boss/gem/version_file_sources/base.rb', line 20

def self.find
  # :nocov: JRuby does not mark the following line as covered
  Dir[glob].filter_map do |path|
    # :nocov:
    if (match = File.read(path).match(content_regexp))
      version = VersionBoss::Gem::IncrementableVersion.new(match[:version])
      VersionBoss::Gem::VersionFile.new(path, match[:content_before], version, match[:content_after])
    end
  end.first
end