Sha256: dd882ec6b8104b7a22530f9be17909eef5c565f8e3cecf10eaa5fc112c97ab18

Contents?: true

Size: 765 Bytes

Versions: 3

Compression:

Stored size: 765 Bytes

Contents

class CheckIn::Factory

  TAG = /^(.+\S+)\s*\((.*)\)$/

  def initialize(label, value, within: nil)
    @label = label
    @value = value
    @within = within
  end

  def call
    if in_quotes?
      remove_quotes!
    end

    if !@value.nil? && @value[':'] && !in_quotes?
      step = CheckIn::ComplexInput
      # return if text_complex_input(label, value, within)
    elsif @label =~ TAG
      @label = $1
      tag    = $2
      step   = Pickles.config.check_step_by_tag(tag) || CheckIn::Input
    else
      step = CheckIn::Input
    end

    step.new(@label, @value, @within)
  end

private

  def in_quotes?
    @in_quotes ||= @value && @value[0] == "\"" && @value[-1] == "\""
  end

  def remove_quotes!
    @value[0]  = ''
    @value[-1] = ''
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pickles-0.2.1 lib/cucumber/pickles/steps/check_in/factory.rb
pickles-0.2.0 lib/cucumber/pickles/steps/check_in/factory.rb
pickles-0.1.12 lib/cucumber/pickles/steps/check_in/factory.rb