Class: Moku::Validator::Gemfile

Inherits:
Moku::Validator show all
Defined in:
lib/moku/validator/gemfile.rb

Overview

Validate's an artifact's Gemfile. Specifically:

  • If the Gemfile includes a 'ruby' directive, it should specify only a major version (e.g. 2.5).

Constant Summary collapse

GEMFILE_MALFORMED =
"When specifying the ruby version in the Gemfile, the" \
" optional ruby directive must specify exactly MAJOR.MINOR version."
GEMFILE_FORM =

rubocop:disable Style/MutableConstant

/^ruby "[1-9]\.[0-9]+"$/

Instance Method Summary collapse

Instance Method Details

#validateObject


16
17
18
19
20
21
22
23
24
25
# File 'lib/moku/validator/gemfile.rb', line 16

def validate
  if path.exist?
    directive = File.open(path).grep(/^ruby/)
    unless directive.empty?
      unless directive.first =~ GEMFILE_FORM
        @errors << GEMFILE_MALFORMED
      end
    end
  end
end