class Cucumber::RbSupport::RbTransform
end
cucumbers_string.to_i
Transform /^(d+) cucumbers$/ do |cucumbers_string|
Example:
See also RbDsl.
by calling Transform in the <tt>support
ruby files.
A Ruby Transform holds a Regexp and a Proc, and is created
def convert_captures(regexp_source)
def convert_captures(regexp_source) regexp_source .gsub(/(\()(?!\?[<:=!])/,'(?:') .gsub(/(\(\?<)(?![=!])/,'(?:<') end
def initialize(rb_language, pattern, proc)
def initialize(rb_language, pattern, proc) raise MissingProc if proc.nil? || proc.arity < 1 @rb_language, @regexp, @proc = rb_language, Regexp.new(pattern), proc end
def invoke(arg)
def invoke(arg) if matched = match(arg) args = matched.captures.empty? ? [arg] : matched.captures @rb_language.current_world.cucumber_instance_exec(true, @regexp.inspect, *args, &@proc) end end
def match(arg)
def match(arg) arg ? arg.match(@regexp) : nil end
def strip_anchors(regexp_source)
def strip_anchors(regexp_source) regexp_source. gsub(/(^\^|\$$)/, '') end
def strip_captures(regexp_source)
def strip_captures(regexp_source) regexp_source. gsub(/(\()/, ''). gsub(/(\))/, '') end
def to_s
def to_s convert_captures(strip_anchors(@regexp.source)) end