Class: Cucumber::Messages::Source
- Defined in:
- lib/cucumber/messages/source.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
-
#data ⇒ Object
readonly
The contents of the file.
-
#media_type ⇒ Object
readonly
The media type of the file.
-
#uri ⇒ Object
readonly
-
The [URI](en.wikipedia.org/wiki/Uniform_Resource_Identifier) of the source, typically a file path relative to the root directory.
-
Class Method Summary collapse
-
.from_h(hash) ⇒ Object
Returns a new Source from the given hash.
Instance Method Summary collapse
-
#initialize(uri: '', data: '', media_type: SourceMediaType::TEXT_X_CUCUMBER_GHERKIN_PLAIN) ⇒ Source
constructor
A new instance of Source.
Methods inherited from Message
camelize, from_json, #to_h, #to_json
Constructor Details
#initialize(uri: '', data: '', media_type: SourceMediaType::TEXT_X_CUCUMBER_GHERKIN_PLAIN) ⇒ Source
Returns a new instance of Source.
34 35 36 37 38 39 40 41 42 43 |
# 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 |
Instance Attribute Details
#data ⇒ Object (readonly)
The contents of the file
26 27 28 |
# File 'lib/cucumber/messages/source.rb', line 26 def data @data end |
#media_type ⇒ Object (readonly)
The media type of the file. Can be used to specify custom types, such as
text/x.cucumber.gherkin+plain
32 33 34 |
# File 'lib/cucumber/messages/source.rb', line 32 def media_type @media_type end |
#uri ⇒ Object (readonly)
*
The [URI](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier)
of the source, typically a file path relative to the root directory
21 22 23 |
# File 'lib/cucumber/messages/source.rb', line 21 def uri @uri end |
Class Method Details
.from_h(hash) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# 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 |