Class: RuboCop::RSpec::DescriptionExtractor

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/rspec/description_extractor.rb

Overview

Extracts cop descriptions from YARD docstrings

Constant Summary collapse

COP_NAMESPACE =
'RuboCop::Cop::RSpec'.freeze
COP_FORMAT =
'RSpec/%s'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(yardocs) ⇒ DescriptionExtractor

Returns a new instance of DescriptionExtractor.



8
9
10
# File 'lib/rubocop/rspec/description_extractor.rb', line 8

def initialize(yardocs)
  @yardocs = yardocs
end

Instance Method Details

#to_hObject



12
13
14
15
16
17
18
# File 'lib/rubocop/rspec/description_extractor.rb', line 12

def to_h
  cop_documentation.each_with_object({}) do |(name, docstring), config|
    config[format(COP_FORMAT, name)] = {
      'Description' => docstring.split("\n\n").first.to_s
    }
  end
end