class Travis::Conditions::V1::Regex

Constants

DELIM
ESC
REGEX

Attributes

str[R]

Public Class Methods

new(str) click to toggle source
# File lib/travis/conditions/v1/regex.rb, line 17
def initialize(str)
  @str = StringScanner.new(str.to_s.strip)
  @esc = false
end

Public Instance Methods

read() click to toggle source
# File lib/travis/conditions/v1/regex.rb, line 39
def read
  char = peek(1)
  if char == DELIM && !@esc
    :eos
  elsif char == ESC
    @esc = true
    getch
  else
    @esc = false
    getch
  end
end
regex() click to toggle source
# File lib/travis/conditions/v1/regex.rb, line 31
def regex
  return unless peek(1) == DELIM && reg = getch
  char = nil
  reg << char while (char = read) && char != :eos
  reg << DELIM if char == :eos
  reg unless reg.empty?
end
scan() click to toggle source
# File lib/travis/conditions/v1/regex.rb, line 22
def scan
  word || regex
end
word() click to toggle source
# File lib/travis/conditions/v1/regex.rb, line 26
def word
  return if peek(1) == DELIM
  str.scan(REGEX)
end