class Kuroko2::Workflow::ShellScanner

Constants

STRING_LITERAL

Public Class Methods

new(text) click to toggle source
# File lib/autoload/kuroko2/workflow/shell_scanner.rb, line 8
def initialize(text)
  @text = text
end

Public Instance Methods

strip_comment() click to toggle source
# File lib/autoload/kuroko2/workflow/shell_scanner.rb, line 12
def strip_comment
  return @text if @text.nil?

  result = ''
  while scanner.rest?
    break if scanner.peek(1) == '#'

    token = scanner.scan(/[^'"#]+/) || scanner.scan(STRING_LITERAL) || scanner.scan(/[^#]+/)
    break if token.nil?

    result << token
  end
  result
end

Private Instance Methods

scanner() click to toggle source
# File lib/autoload/kuroko2/workflow/shell_scanner.rb, line 29
def scanner
  @scanner ||= StringScanner.new(@text)
end