class Chutney::ChutneyLint

gherkin linter

Attributes

files[R]
results[R]
verbose[RW]

Public Class Methods

new(*files) click to toggle source
# File lib/chutney.rb, line 59
def initialize(*files)
  @files = files
  @results = Hash.new { |h, k| h[k] = [] }
  i18n_paths = Dir[File.expand_path(File.join(__dir__, 'config/locales')) + '/*.yml']

  i18n_paths.each do |path|
    next if I18n.load_path.include?(path)

    I18n.load_path << path
    I18n.backend.reload!
  end
end

Public Instance Methods

analyse() click to toggle source
# File lib/chutney.rb, line 85
def analyse
  files.each do |f|
    lint(f)
  end
  @results
end
Also aliased as: analyze
analyze()
Alias for: analyse
configuration() click to toggle source
# File lib/chutney.rb, line 72
def configuration
  unless @config
    default_file = [File.expand_path('..', __dir__), '**/config', 'chutney_defaults.yml']
    config_file = Dir.glob(File.join(default_file)).first.freeze
    @config = Configuration.new(config_file)
  end
  @config
end
configuration=(config) click to toggle source
# File lib/chutney.rb, line 81
def configuration=(config)
  @config = config
end
linters() click to toggle source
# File lib/chutney.rb, line 95
def linters
  @linters ||= Linter.descendants.filter { |l| configuration.dig(l.linter_name, 'Enabled') }
end
linters=(*linters) click to toggle source
# File lib/chutney.rb, line 99
def linters=(*linters)
  @linters = linters
end

Private Instance Methods

lint(file) click to toggle source
# File lib/chutney.rb, line 105
def lint(file)
  parsed = CukeModeler::FeatureFile.new(file)
  linters.each do |linter_class|
    linter = linter_class.new(file, parsed, configuration[linter_class.linter_name])
    linter.lint
    @results[file] << { linter: linter.linter_name, issues: linter.issues }
  end
end