Class: Cucumber::Messages::Source

Inherits:
Message show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb,
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.deserializers.rb

Overview

Represents the Source message in Cucumber’s message protocol.

//// Source

*

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Message::Utils

included

Methods included from Message::Serialization

#to_h, #to_json

Methods included from Message::Deserialization

included

Constructor Details

#initialize(uri: '', data: '', media_type: SourceMediaType::TEXT_X_CUCUMBER_GHERKIN_PLAIN) ⇒ Source

Returns a new instance of Source.



1325
1326
1327
1328
1329
1330
1331
1332
1333
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1325

def initialize(
  uri: '',
  data: '',
  media_type: SourceMediaType::TEXT_X_CUCUMBER_GHERKIN_PLAIN
)
  @uri = uri
  @data = data
  @media_type = media_type
end

Instance Attribute Details

#dataObject (readonly)

The contents of the file



1317
1318
1319
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1317

def data
  @data
end

#media_typeObject (readonly)

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

text/x.cucumber.gherkin+plain


1323
1324
1325
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1323

def media_type
  @media_type
end

#uriObject (readonly)

*

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


1312
1313
1314
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.dtos.rb', line 1312

def uri
  @uri
end

Class Method Details

.from_h(hash) ⇒ Object

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... ...>


774
775
776
777
778
779
780
781
782
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/cucumber-messages-18.0.0/lib/cucumber/messages.deserializers.rb', line 774

def self.from_h(hash)
  return nil if hash.nil?

  self.new(
    uri: hash[:uri],
    data: hash[:data],
    media_type: hash[:mediaType],
  )
end