Sha256: 929ce2a0558b57b0c1a0747546b7ef3427ce6d897c34871ed2af97d1bcdb41ed
Contents?: true
Size: 985 Bytes
Versions: 1
Compression:
Stored size: 985 Bytes
Contents
# removes the commands from strings retrieved from stuff like `heroku run bash` # since likely you care about the output, not the input # this is especially useful for seeing if a given input command has finished running # if we cannot find a valid input command and output command return the full unparsed string module Hatchet class CommandParser attr_accessor :command def initialize(command) @command = command @parsed_string = "" @raw_string = "" end def regex /#{Regexp.quote(command)}\r*\n+/ end def parse(string) @raw_string = string @parsed_string = string.split(regex).last return self end def to_s @parsed_string || @raw_string end def missing_valid_output? !has_valid_output? end def has_valid_output? return false unless @raw_string.match(regex) return false if @parsed_string.blank? || @parsed_string.strip.blank? true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
heroku_hatchet-0.2.0 | lib/hatchet/command_parser.rb |