Class: RuboCop::RSpec::DescriptionExtractor
- Inherits:
-
Object
- Object
- RuboCop::RSpec::DescriptionExtractor
- 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
-
#initialize(yardocs) ⇒ DescriptionExtractor
constructor
A new instance of DescriptionExtractor.
- #to_h ⇒ Object
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_h ⇒ Object
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 |