Class: Cucumber::Messages::Meta

Inherits:
Message
  • Object
show all
Defined in:
lib/cucumber/messages/meta.rb

Overview

Represents the Meta message in Cucumber’s message protocol.

*

This message contains meta information about the environment. Consumers can use
this for various purposes.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

camelize, from_json, #to_h, #to_json

Constructor Details

#initialize(protocol_version: '', implementation: Product.new, runtime: Product.new, os: Product.new, cpu: Product.new, ci: nil) ⇒ Meta

Returns a new instance of Meta.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cucumber/messages/meta.rb', line 43

def initialize(
  protocol_version: '',
  implementation: Product.new,
  runtime: Product.new,
  os: Product.new,
  cpu: Product.new,
  ci: nil
)
  @protocol_version = protocol_version
  @implementation = implementation
  @runtime = runtime
  @os = os
  @cpu = cpu
  @ci = ci
  super()
end

Instance Attribute Details

#ciObject (readonly)

Returns the value of attribute ci.



41
42
43
# File 'lib/cucumber/messages/meta.rb', line 41

def ci
  @ci
end

#cpuObject (readonly)

386, arm, amd64 etc



39
40
41
# File 'lib/cucumber/messages/meta.rb', line 39

def cpu
  @cpu
end

#implementationObject (readonly)

SpecFlow, Cucumber-JVM, Cucumber.js, Cucumber-Ruby, Behat etc.



24
25
26
# File 'lib/cucumber/messages/meta.rb', line 24

def implementation
  @implementation
end

#osObject (readonly)

Windows, Linux, MacOS etc



34
35
36
# File 'lib/cucumber/messages/meta.rb', line 34

def os
  @os
end

#protocol_versionObject (readonly)

*

The [SEMVER](https://semver.org/) version number of the protocol


19
20
21
# File 'lib/cucumber/messages/meta.rb', line 19

def protocol_version
  @protocol_version
end

#runtimeObject (readonly)

Java, Ruby, Node.js etc



29
30
31
# File 'lib/cucumber/messages/meta.rb', line 29

def runtime
  @runtime
end

Class Method Details

.from_h(hash) ⇒ Object

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

Cucumber::Messages::Meta.from_h(some_hash) # => #<Cucumber::Messages::Meta:0x... ...>


67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cucumber/messages/meta.rb', line 67

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

  new(
    protocol_version: hash[:protocolVersion],
    implementation: Product.from_h(hash[:implementation]),
    runtime: Product.from_h(hash[:runtime]),
    os: Product.from_h(hash[:os]),
    cpu: Product.from_h(hash[:cpu]),
    ci: Ci.from_h(hash[:ci])
  )
end