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.



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

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.



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

def ci
  @ci
end

#cpuObject (readonly)

386, arm, amd64 etc



37
38
39
# File 'lib/cucumber/messages/meta.rb', line 37

def cpu
  @cpu
end

#implementationObject (readonly)

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



22
23
24
# File 'lib/cucumber/messages/meta.rb', line 22

def implementation
  @implementation
end

#osObject (readonly)

Windows, Linux, MacOS etc



32
33
34
# File 'lib/cucumber/messages/meta.rb', line 32

def os
  @os
end

#protocol_versionObject (readonly)

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



17
18
19
# File 'lib/cucumber/messages/meta.rb', line 17

def protocol_version
  @protocol_version
end

#runtimeObject (readonly)

Java, Ruby, Node.js etc



27
28
29
# File 'lib/cucumber/messages/meta.rb', line 27

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


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

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