Sha256: 733ff6a84438a6ec4af67bc4e613e3c563c1befe904166600c890f13ffcf7933

Contents?: true

Size: 903 Bytes

Versions: 14

Compression:

Stored size: 903 Bytes

Contents

require 'gherkin/rubify'

module Lucid
  module AST
    module MultilineArgument

      class << self
        include Gherkin::Rubify

        def from(argument)
          return unless argument
          return argument if argument.respond_to?(:to_step_definition_arg)

          case(rubify(argument))
          when String
            # TODO: This duplicates work that Gherkin already does.
            # Ideally the string should be passed directly to Gherkin for parsing.
            AST::DocString.new(argument, '')
          when Gherkin::Formatter::Model::DocString
            AST::DocString.new(argument.value, argument.content_type)
          when Array
            AST::Table.new(argument.map{|row| row.cells})
          else
            raise ArgumentError, "Lucid does not know how to convert #{argument} into a multi-line argument."
          end
        end

      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
lucid-0.5.1 lib/lucid/ast/multiline_argument.rb
lucid-0.4.1 lib/lucid/ast/multiline_argument.rb
lucid-0.4.0 lib/lucid/ast/multiline_argument.rb
lucid-0.3.3 lib/lucid/ast/multiline_argument.rb
lucid-0.3.0 lib/lucid/ast/multiline_argument.rb
lucid-0.2.1 lib/lucid/ast/multiline_argument.rb
lucid-0.2.0 lib/lucid/ast/multiline_argument.rb
lucid-0.1.1 lib/lucid/ast/multiline_argument.rb
lucid-0.1.0 lib/lucid/ast/multiline_argument.rb
lucid-0.0.9 lib/lucid/ast/multiline_argument.rb
lucid-0.0.8 lib/lucid/ast/multiline_argument.rb
lucid-0.0.7 lib/lucid/ast/multiline_argument.rb
lucid-0.0.6 lib/lucid/ast/multiline_argument.rb
lucid-0.0.5 lib/lucid/ast/multiline_argument.rb