Sha256: 7d6bbb74655a3a00f70dd5b1629b5758b4096b3ff90b53d618127efc86b7ac98

Contents?: true

Size: 608 Bytes

Versions: 2

Compression:

Stored size: 608 Bytes

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_]*)(?:#|::)([a-z_][a-zA-Z0-9_]*)'
	  src.gsub!(/\s/,'')
	  
	  if src =~ /([A-Za-z0-9_.~-]+):(\d+)/
		return FaultConditionLine.new($1,$2.to_i)

	  else
		methods = src.split(">")
		methods.map! do |e|
		  unless e =~ Regexp.new(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

2 entries across 2 versions & 1 rubygems

Version Path
faultinjection-0.0.1 lib/fault_injection/parser.rb
faultinjection-0.0.2 lib/fault_injection/parser.rb