Class: Cucumber::Messages::Ci

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

Overview

Represents the Ci message in Cucumber’s message protocol.

CI environment

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(name: '', url: nil, build_number: nil, git: nil) ⇒ Ci

Returns a new instance of Ci.



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cucumber/messages/ci.rb', line 30

def initialize(
  name: '',
  url: nil,
  build_number: nil,
  git: nil
)
  @name = name
  @url = url
  @build_number = build_number
  @git = git
  super()
end

Instance Attribute Details

#build_numberObject (readonly)

The build number. Some CI servers use non-numeric build numbers, which is why this is a string



26
27
28
# File 'lib/cucumber/messages/ci.rb', line 26

def build_number
  @build_number
end

#gitObject (readonly)

Returns the value of attribute git.



28
29
30
# File 'lib/cucumber/messages/ci.rb', line 28

def git
  @git
end

#nameObject (readonly)

Name of the CI product, e.g. “Jenkins”, “CircleCI” etc.



16
17
18
# File 'lib/cucumber/messages/ci.rb', line 16

def name
  @name
end

#urlObject (readonly)

Link to the build



21
22
23
# File 'lib/cucumber/messages/ci.rb', line 21

def url
  @url
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


50
51
52
53
54
55
56
57
58
59
# File 'lib/cucumber/messages/ci.rb', line 50

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

  new(
    name: hash[:name],
    url: hash[:url],
    build_number: hash[:buildNumber],
    git: Git.from_h(hash[:git])
  )
end