Class: Tailor::Rulers::AllowScreamingSnakeCaseClassesRuler
- Inherits:
-
Tailor::Ruler
- Object
- Tailor::Ruler
- Tailor::Rulers::AllowScreamingSnakeCaseClassesRuler
- Defined in:
- lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb
Instance Attribute Summary
Attributes inherited from Tailor::Ruler
Instance Method Summary collapse
- #const_update(token, lexed_line, lineno, column) ⇒ Object
-
#initialize(config, options) ⇒ AllowScreamingSnakeCaseClassesRuler
constructor
A new instance of AllowScreamingSnakeCaseClassesRuler.
-
#measure(token, lineno, column) ⇒ Object
Checks to see if the class name matches /[A-Z].*_/.
Methods inherited from Tailor::Ruler
#add_child_ruler, #problem_type, #problems
Methods included from Logger::Mixin
Constructor Details
#initialize(config, options) ⇒ AllowScreamingSnakeCaseClassesRuler
Returns a new instance of AllowScreamingSnakeCaseClassesRuler.
6 7 8 9 |
# File 'lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb', line 6 def initialize(config, ) super(config, ) add_lexer_observers :const end |
Instance Method Details
#const_update(token, lexed_line, lineno, column) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb', line 11 def const_update(token, lexed_line, lineno, column) ident_index = lexed_line.event_index(column) previous_event = lexed_line.event_at(ident_index - 2) log "previous event: #{previous_event}" return if previous_event.nil? if previous_event[1] == :on_kw && (previous_event.last == 'class' || previous_event.last == 'module') measure(token, lineno, column) end end |
#measure(token, lineno, column) ⇒ Object
Checks to see if the class name matches /[A-Z].*_/.
29 30 31 32 33 34 35 36 |
# File 'lib/tailor/rulers/allow_screaming_snake_case_classes_ruler.rb', line 29 def measure(token, lineno, column) if token.screaming_snake_case? = 'Screaming-snake-case class/module found.' @problems << Problem.new(problem_type, lineno, column, , @options[:level]) end end |