Sha256: 15190eedf402327d52ebf21ec80c5785239e8a7360732e015a75bc85dc47ed99
Contents?: true
Size: 1.18 KB
Versions: 5
Compression:
Stored size: 1.18 KB
Contents
module YARD::CodeObjects class StepTransformerObject < Base include Cucumber::LocationHelper attr_reader :constants, :keyword, :source, :value, :literal_value attr_accessor :steps ESCAPE_PATTERN = /#\{\s*(\w+)\s*\}/ def value=(value) @literal_value = format_source(value) @value = format_source(value) until (nested = constants_from_value).empty? nested.each {|n| @value.gsub!(value_regex(n),find_value_for_constant(n)) } end @steps = [] end def regex @regex ||= /#{strip_regex_from(@value)}/ end def constants_from_value(data=@value) data.scan(ESCAPE_PATTERN).flatten.collect { |value| value.strip } end protected def find_value_for_constant(name) constant = YARD::Registry.all(:constant).find{|c| c.name == name.to_sym } log.warn "StepTransformer#find_value_for_constant : Could not find the CONSTANT #{name} using an empty string for value." unless constant constant ? strip_regex_from(constant.value) : "" end def value_regex(value) /#\{\s*#{value}\s*\}/ end def strip_regex_from(value) value.gsub(/^\/|\/$/,'') end end end
Version data entries
5 entries across 5 versions & 1 rubygems