Sha256: 25c4efd7f81b9d021f8b8e9bfc59489cc0a307ae182b688dd8f815d04d8860a9
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# Command examples # # parser.rb:30 => line 30 in parser.rb # module FaultInjection class Parser def self.compile src method_pat = / ([A-Z][A-Za-z0-9_]*) # class name (?: \#|:: ) # '#' or '::', they are treated as same now. ([a-z_][a-zA-Z0-9_]*) # method name /x method_lineno_pat = / ([A-Z][A-Za-z0-9_]*) # class name (?: \#|:: ) # '#' or '::', they are treated as same. ([a-z_][a-zA-Z0-9_]*) # method name (?: :(\d+) ) # line number in method /x file_line_pat = /^([A-Za-z0-9_.~-]+):(\d+)$/ src.gsub!(/\s/,'') if src =~ file_line_pat return FaultConditionLine.new($~[1],$~[2].to_i) elsif src =~ method_lineno_pat #STDERR.puts("Class=#{$~[1]},method='#{$~[2]}',line='#{$~[3]}'") klass = eval($~[1]) rescue raise(NameError,"No such class:'#{$~[1]}'") method = $~[2] line_in_meth = $~[3].to_i # Proc#to_s contains file name & line number in which # the method is defined. method_info = klass.new.method(method).to_proc.to_s method_info =~ /@([^:]+):(\d+)>$/ #STDERR.puts("file=#{$~[1]},line=#{$~[2]}") return FaultConditionLine.new($~[1], $~[2].to_i + line_in_meth) else methods = src.split(">") methods.map! do |e| unless e =~ method_pat raise ArgumentError,"Invalid method name:'#{e}'" end [$~[1].to_sym, $~[2].to_sym] end c = FaultConditionCall.new c.stack_pattern = methods.reverse # callee first return c end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
faultinjection-0.0.3 | lib/fault_injection/parser.rb |