Sha256: dfa84a75ee06d34530a210c7eca1abfe553e474f020be779054b2572e5f68be9

Contents?: true

Size: 981 Bytes

Versions: 4

Compression:

Stored size: 981 Bytes

Contents


module YARD::CodeObjects

  class StepDefinitionObject < Base
    include Cucumber::LocationHelper
    
    attr_reader :keyword, :value, :compare_value, :source 
    attr_accessor :constants, :steps
    
    def value=(value)
      @value = format_source(value)
      @constants = {}
      @steps = []
    end
    
    def compare_value
      base_value = value.gsub(/^\/|\/$/,'')
      @constants.each do |name,value|
        base_value.gsub!(/\#\{\s*#{name.to_s}\s*\}/,value.gsub(/^\/|\/$/,''))
      end
      base_value
    end
    
    def _value_constants(data=@value)
      #Hash[*data.scan(/\#\{([^\}]+)\}/).flatten.collect {|value| [value.strip,nil]}.flatten]
      data.scan(/\#\{([^\}]+)\}/).flatten.collect { |value| value.strip }
    end
    
    def constants=(value)
      value.each do |val| 
        @constants[val.name.to_s] = val if val.respond_to?(:name) && val.respond_to?(:value)
      end
    end    
    
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cucumber-in-the-yard-1.5.2 lib/yard/code_objects/step_definition.rb
cucumber-in-the-yard-1.5.1 lib/yard/code_objects/step_definition.rb
cucumber-in-the-yard-1.5 lib/yard/code_objects/step_definition.rb
cucumber-in-the-yard-1.4 lib/yard/code_objects/step_definition.rb