Sha256: 6bab3b7cdd959e37f8ca569efd2b5f454155aea2391767c7036b3957d96a764e
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 KB
Contents
#!/usr/bin/env ruby class LineType def initialize (strippedLine) @strippedLine = strippedLine end def isValid !(s[-1] != ";") end end class VariableLineType < LineType UNINITIALIZED_REGEX = /var[" "]([a-zA-Z0-9])\w+: [a-zA-Z]*([!]?[?]?)/ INITIALIZED_REGEX = /var[" "]([a-zA-Z0-9])\w+ = ([a-zA-Z0-9]?"?[(]?[)]?.?)*/ def isValid isValidUninitialized || isValidInitialized # super.isValid && (isValidUninitialized || isValidInitialized) end def isValidUninitialized !!(@strippedLine =~ UNINITIALIZED_REGEX) && !(@strippedLine.include? "=") end def isValidInitialized !!(@strippedLine =~ INITIALIZED_REGEX) end end class ConstantLineType < LineType UNINITIALIZED_REGEX = /let[" "]([a-zA-Z0-9])\w+: [a-zA-Z]*([!]?[?]?)/ INITIALIZED_REGEX = /let[" "]([a-zA-Z0-9])\w+ = ([a-zA-Z0-9]?"?[(]?[)]?.?)*/ def isValid isValidUninitialized || isValidInitialized # super.isValid && isValidUninitialized || isValidInitialized end def isValidUninitialized !!(@strippedLine =~ UNINITIALIZED_REGEX) && !(@strippedLine.include? "=") end def isValidInitialized !!(@strippedLine =~ INITIALIZED_REGEX) end end class ClassLineType < LineType CLASS_REGEX = /class[" "]([a-zA-Z])\w+((: (([a-zA-Z])\w+))((, (([a-zA-Z])\w+)){0,10}))? {/ def isValid !!(@strippedLine =~ CLASS_REGEX) end end class CommentLineType < LineType COMMENT_WITH_COMMENTS_REGEX = /\/\/\/?(( (?=.))(.{0,}))/ COMMENT_WITHOUT_COMMENTS_REGEX = /\/\/\/?(?!.)/ def isValid !!(@strippedLine =~ COMMENT_WITH_COMMENTS_REGEX) || !!(@strippedLine =~ COMMENT_WITHOUT_COMMENTS_REGEX) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dftsg-0.1.2 | lib/LineType.rb |
dftsg-0.1.1 | lib/LineType.rb |