Sha256: a25fd3e0fb3b1062c75d59e36908f195a5e416dc7749a677cd33c540393a6cc1

Contents?: true

Size: 433 Bytes

Versions: 2

Compression:

Stored size: 433 Bytes

Contents

require 'roodi/checks/check'

module Roodi
  module Checks
    class ClassNameCheck < Check
      def interesting_nodes
        [:class]
      end
  
      def evaluate(node)
        class_name = node[1].class == Symbol ? node[1] : node[1].last
        pattern = /^[A-Z][a-zA-Z0-9]*$/
        add_error "Class name \"#{node[1]}\" should match pattern #{pattern.inspect}" unless class_name.to_s =~ pattern
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
roodi-1.1.1 lib/roodi/checks/class_name_check.rb
roodi-1.2.0 lib/roodi/checks/class_name_check.rb