class Librarian::Linter::SourceLinter

Attributes

klass[RW]

Public Class Methods

lint!(klass) click to toggle source
# File lib/librarian/linter/source_linter.rb, line 6
def lint!(klass)
  new(klass).lint!
end
new(klass) click to toggle source
# File lib/librarian/linter/source_linter.rb, line 14
def initialize(klass)
  self.klass = klass
end

Public Instance Methods

lint!() click to toggle source
# File lib/librarian/linter/source_linter.rb, line 18
def lint!
  lint_class_responds_to! *[
    :lock_name,
    :from_spec_args,
    :from_lock_options,
  ]

  lint_instance_responds_to! *[
    :to_spec_args,
    :to_lock_options,
    :manifests,
    :fetch_version,
    :fetch_dependencies,
    :pinned?,
    :unpin!,
    :install!,
  ]
end

Private Instance Methods

lint_class_responds_to!(*names) click to toggle source
# File lib/librarian/linter/source_linter.rb, line 39
def lint_class_responds_to!(*names)
  missing = names.reject{|name| klass.respond_to?(name)}
  return if missing.empty?

  raise "class must respond to #{missing.join(', ')}"
end
lint_instance_responds_to!(*names) click to toggle source
# File lib/librarian/linter/source_linter.rb, line 46
def lint_instance_responds_to!(*names)
  missing = names - klass.public_instance_methods.map(&:to_sym)
  return if missing.empty?

  raise "instance must respond to #{missing.join(', ')}"
end