Class: Moku::Validator::RubyVersion

Inherits:
Validator
  • Object
show all
Defined in:
lib/moku/validator/ruby_version.rb

Overview

Validate an artifact's .ruby-version file. Specifically:

  • There is a .ruby-version present

  • It specifies only a major version (e.g. 2.5)

Constant Summary collapse

VERSION_FORM =

rubocop:disable Style/MutableConstant

/^[1-9]\.[0-9]+$/
VERSION_MALFORMED =
"A forbidden .ruby-version file was found. The .ruby-version" \
" file must specify exactly MAJOR.MINOR version."
VERSION_MISSING =
"You must supply a .ruby-version file that specifies exactly" \
" the MAJOR.MINOR version."

Instance Method Summary collapse

Methods inherited from Validator

#errors, #initialize, #valid?

Constructor Details

This class inherits a constructor from Moku::Validator::Validator

Instance Method Details

#validateObject


18
19
20
21
22
23
24
25
26
# File 'lib/moku/validator/ruby_version.rb', line 18

def validate
  if path.exist?
    unless VERSION_FORM =~ File.read(path)
      @errors << VERSION_MALFORMED
    end
  else
    @errors << VERSION_MISSING
  end
end