Class: Cucumber::Messages::Git

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

Overview

Represents the Git message in Cucumber’s message protocol.

Information about Git, provided by the Build/CI server as environment

variables.

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(remote: '', revision: '', branch: nil, tag: nil) ⇒ Git

Returns a new instance of Git.



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cucumber/messages/git.rb', line 22

def initialize(
  remote: '',
  revision: '',
  branch: nil,
  tag: nil
)
  @remote = remote
  @revision = revision
  @branch = branch
  @tag = tag
  super()
end

Instance Attribute Details

#branchObject (readonly)

Returns the value of attribute branch.



18
19
20
# File 'lib/cucumber/messages/git.rb', line 18

def branch
  @branch
end

#remoteObject (readonly)

Returns the value of attribute remote.



14
15
16
# File 'lib/cucumber/messages/git.rb', line 14

def remote
  @remote
end

#revisionObject (readonly)

Returns the value of attribute revision.



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

def revision
  @revision
end

#tagObject (readonly)

Returns the value of attribute tag.



20
21
22
# File 'lib/cucumber/messages/git.rb', line 20

def tag
  @tag
end

Class Method Details

.from_h(hash) ⇒ Object

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

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


42
43
44
45
46
47
48
49
50
51
# File 'lib/cucumber/messages/git.rb', line 42

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

  new(
    remote: hash[:remote],
    revision: hash[:revision],
    branch: hash[:branch],
    tag: hash[:tag]
  )
end