class Cucumber::Messages::Source

Represents the Source message in Cucumber’s message protocol.

//// Source

*

A source file, typically a Gherkin document or Java/Ruby/JavaScript source code

Attributes

data[R]

The contents of the file

media_type[R]

The media type of the file. Can be used to specify custom types, such as

text/x.cucumber.gherkin+plain
uri[R]

*

The [URI](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier)
of the source, typically a file path relative to the root directory

Public Class Methods

from_h(hash) click to toggle source

Returns a new Source from the given hash. If the hash keys are camelCased, they are properly assigned to the corresponding snake_cased attributes.

Cucumber::Messages::Source.from_h(some_hash) # => #<Cucumber::Messages::Source:0x... ...>
# File lib/cucumber/messages/source.rb, line 52
def self.from_h(hash)
  return nil if hash.nil?

  new(
    uri: hash[:uri],
    data: hash[:data],
    media_type: hash[:mediaType]
  )
end
new( uri: '', data: '', media_type: SourceMediaType::TEXT_X_CUCUMBER_GHERKIN_PLAIN ) click to toggle source
Calls superclass method
# File lib/cucumber/messages/source.rb, line 34
def initialize(
  uri: '',
  data: '',
  media_type: SourceMediaType::TEXT_X_CUCUMBER_GHERKIN_PLAIN
)
  @uri = uri
  @data = data
  @media_type = media_type
  super()
end