class FeduxOrgStdlib::VersionManagement::RubygemVersionFileParser

Ruby version file parser

Attributes

modules[R]
version[R]

Public Instance Methods

parse(file) click to toggle source
# File lib/fedux_org_stdlib/version_management/rubygem_version_file_parser.rb, line 12
def parse(file)
  data = File.read(file)

  @version = data.match(/(?:VERSION|Version)\s+=\s+["']([^'"]+)["']/) { Regexp.last_match[1] }
  @modules = data.scan(/^\s*module\s+([A-Z][A-Za-z0-9]+(?:::[A-Z][A-Z0-9a-z]+)*)$/x).flatten

  fail Exceptions::VersionFileInvalid, JSON.dump(file: file) if version.blank?
end