class RuboCop::Schema::AsciiDoc::Cop
Constants
- ATTRS
Attributes
attributes[R]
@return [Array<Attribute>]
description[R]
@return [String]
enabled_by_default[R]
@return [TrueClass, FalseClass]
name[R]
@return [String]
supports_autocorrect[R]
@return [TrueClass, FalseClass]
Public Instance Methods
to_h()
click to toggle source
# File lib/rubocop/schema/ascii_doc/cop.rb, line 25 def to_h ATTRS.map { |k| [k, __send__(k)] }.to_h end
Protected Instance Methods
scan()
click to toggle source
# File lib/rubocop/schema/ascii_doc/cop.rb, line 31 def scan @name = root.title read_stats_table read_description read_attributes end
Private Instance Methods
attr_table_block()
click to toggle source
@return [Asciidoctor::Block, nil]
# File lib/rubocop/schema/ascii_doc/cop.rb, line 78 def attr_table_block @attr_table_block ||= root .query(context: :section) { |s| s.title == 'Configurable attributes' } &.first &.query(context: :table) &.first end
find_description_range()
click to toggle source
# File lib/rubocop/schema/ascii_doc/cop.rb, line 64 def find_description_range top = stats_table_block ? root.blocks.index(stats_table_block) + 1 : 0 bottom = root.blocks.index(root.sections.first) || 0 top..(bottom - 1) end
read_attributes()
click to toggle source
# File lib/rubocop/schema/ascii_doc/cop.rb, line 52 def read_attributes return unless attr_table_block @attributes = table_to_hash(attr_table_block).map do |row| Attribute.new( name: row['Name'], default: presence(row['Default value']), type: presence(row['Configurable values']) ) end end
read_description()
click to toggle source
# File lib/rubocop/schema/ascii_doc/cop.rb, line 47 def read_description blocks = root.blocks[find_description_range] @description = blocks.map(&method(:stringify_section)).join("\n\n") if blocks.any? end
read_stats_table()
click to toggle source
# File lib/rubocop/schema/ascii_doc/cop.rb, line 40 def read_stats_table return unless stats_table @enabled_by_default = stats_table['Enabled by default'] == 'Enabled' @supports_autocorrect = stats_table['Supports autocorrection'] == 'Yes' end
stats_table()
click to toggle source
@return [Array<Hash>, nil]
# File lib/rubocop/schema/ascii_doc/cop.rb, line 87 def stats_table @stats_table ||= stats_table_block && table_to_hash(stats_table_block).first end
stats_table_block()
click to toggle source
@return [Asciidoctor::Block, nil]
# File lib/rubocop/schema/ascii_doc/cop.rb, line 71 def stats_table_block @stats_table_block ||= root .query(context: :table) { |t| t.rows.head.first.first.text == 'Enabled by default' } .first end