Class: Cucumber::Messages::GherkinDocument
- Defined in:
- lib/cucumber/messages/gherkin_document.rb
Overview
Represents the GherkinDocument message in Cucumber’s message protocol.
The [AST](en.wikipedia.org/wiki/Abstract_syntax_tree) of a Gherkin document. Cucumber implementations should not depend on ‘GherkinDocument` or any of its children for execution - use [Pickle](#io.cucumber.messages.Pickle) instead.
The only consumers of ‘GherkinDocument` should only be formatters that produce “rich” output, resembling the original Gherkin document.
Instance Attribute Summary collapse
-
#comments ⇒ Object
readonly
All the comments in the Gherkin document.
-
#feature ⇒ Object
readonly
Returns the value of attribute feature.
-
#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 GherkinDocument from the given hash.
Instance Method Summary collapse
-
#initialize(uri: nil, feature: nil, comments: []) ⇒ GherkinDocument
constructor
A new instance of GherkinDocument.
Methods inherited from Message
camelize, from_json, #to_h, #to_json
Constructor Details
#initialize(uri: nil, feature: nil, comments: []) ⇒ GherkinDocument
Returns a new instance of GherkinDocument.
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cucumber/messages/gherkin_document.rb', line 31 def initialize( uri: nil, feature: nil, comments: [] ) @uri = uri @feature = feature @comments = comments super() end |
Instance Attribute Details
#comments ⇒ Object (readonly)
All the comments in the Gherkin document
29 30 31 |
# File 'lib/cucumber/messages/gherkin_document.rb', line 29 def comments @comments end |
#feature ⇒ Object (readonly)
Returns the value of attribute feature.
24 25 26 |
# File 'lib/cucumber/messages/gherkin_document.rb', line 24 def feature @feature end |
#uri ⇒ Object (readonly)
The [URI](en.wikipedia.org/wiki/Uniform_Resource_Identifier) of the source, typically a file path relative to the root directory
22 23 24 |
# File 'lib/cucumber/messages/gherkin_document.rb', line 22 def uri @uri end |
Class Method Details
.from_h(hash) ⇒ Object
Returns a new GherkinDocument from the given hash. If the hash keys are camelCased, they are properly assigned to the corresponding snake_cased attributes.
Cucumber::Messages::GherkinDocument.from_h(some_hash) # => #<Cucumber::Messages::GherkinDocument:0x... ...>
49 50 51 52 53 54 55 56 57 |
# File 'lib/cucumber/messages/gherkin_document.rb', line 49 def self.from_h(hash) return nil if hash.nil? new( uri: hash[:uri], feature: Feature.from_h(hash[:feature]), comments: hash[:comments]&.map { |item| Comment.from_h(item) } ) end |