Class: LintTrappings::LinterPlugin

Inherits:
Object
  • Object
show all
Defined in:
lib/lint_trappings/linter_plugin.rb

Overview

Represents a collection of linters/configuration which are loaded from a gem.

This is just a wrapper to make accessing files in the gem easier.

Instance Method Summary collapse

Constructor Details

#initialize(require_path) ⇒ LinterPlugin

Returns a new instance of LinterPlugin.

Parameters:

  • require_path (String)

    name of the gem (must be the same as the path to `require`!)


9
10
11
# File 'lib/lint_trappings/linter_plugin.rb', line 9

def initialize(require_path)
  @require_path = require_path
end

Instance Method Details

#config_file_pathString

Returns path to the configuration file that ships with this linter plugin.

Note that this may not exist if no configuration is shipped with the gem.

Returns:

  • (String)

25
26
27
# File 'lib/lint_trappings/linter_plugin.rb', line 25

def config_file_path
  File.join(gem_dir, 'config.yaml')
end

#loadObject


13
14
15
16
17
18
# File 'lib/lint_trappings/linter_plugin.rb', line 13

def load
  require @require_path
rescue LoadError, SyntaxError => ex
  raise LinterLoadError,
        "Unable to load linter plugin at path '#{@require_path}': #{ex.message}"
end