Class: Coat::Patch

Inherits:
Struct
  • Object
show all
Defined in:
lib/coat/patch.rb

Overview

One patch: what it is, who made it, and what it touched. A patch is only worth something with its origin still attached, so everything needed to judge it travels with it.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#agentObject

Returns the value of attribute agent

Returns:

  • (Object)

    the current value of agent



11
12
13
# File 'lib/coat/patch.rb', line 11

def agent
  @agent
end

#bodyObject

Returns the value of attribute body

Returns:

  • (Object)

    the current value of body



11
12
13
# File 'lib/coat/patch.rb', line 11

def body
  @body
end

#body_sha256Object

Returns the value of attribute body_sha256

Returns:

  • (Object)

    the current value of body_sha256



11
12
13
# File 'lib/coat/patch.rb', line 11

def body_sha256
  @body_sha256
end

#claimsObject

Returns the value of attribute claims

Returns:

  • (Object)

    the current value of claims



11
12
13
# File 'lib/coat/patch.rb', line 11

def claims
  @claims
end

#cmdObject

Returns the value of attribute cmd

Returns:

  • (Object)

    the current value of cmd



11
12
13
# File 'lib/coat/patch.rb', line 11

def cmd
  @cmd
end

#cwdObject

Returns the value of attribute cwd

Returns:

  • (Object)

    the current value of cwd



11
12
13
# File 'lib/coat/patch.rb', line 11

def cwd
  @cwd
end

#duration_sObject

Returns the value of attribute duration_s

Returns:

  • (Object)

    the current value of duration_s



11
12
13
# File 'lib/coat/patch.rb', line 11

def duration_s
  @duration_s
end

#exitObject

Returns the value of attribute exit

Returns:

  • (Object)

    the current value of exit



11
12
13
# File 'lib/coat/patch.rb', line 11

def exit
  @exit
end

#kindObject

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



11
12
13
# File 'lib/coat/patch.rb', line 11

def kind
  @kind
end

#labelObject

Returns the value of attribute label

Returns:

  • (Object)

    the current value of label



11
12
13
# File 'lib/coat/patch.rb', line 11

def label
  @label
end

#seqObject

Returns the value of attribute seq

Returns:

  • (Object)

    the current value of seq



11
12
13
# File 'lib/coat/patch.rb', line 11

def seq
  @seq
end

#tsObject

Returns the value of attribute ts

Returns:

  • (Object)

    the current value of ts



11
12
13
# File 'lib/coat/patch.rb', line 11

def ts
  @ts
end

Class Method Details

.all(entries) ⇒ Object



20
21
22
# File 'lib/coat/patch.rb', line 20

def self.all(entries)
  entries.select { |entry| PATCH_EVENTS.include?(entry["event"]) }.map { |entry| from(entry) }
end

.from(entry) ⇒ Object



16
17
18
# File 'lib/coat/patch.rb', line 16

def self.from(entry)
  new(**entry.slice(*members.map(&:to_s)).transform_keys(&:to_sym))
end

Instance Method Details

#command?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/coat/patch.rb', line 24

def command?
  kind == "command"
end

#failed?Boolean

A command that exited non-zero still belongs in the coat - a failed step is evidence too - but it gets marked rather than blending in.

Returns:

  • (Boolean)


36
37
38
# File 'lib/coat/patch.rb', line 36

def failed?
  ran? && !exit.zero?
end

#ran?Boolean

A patch cut from a command, whether coat ran it or was handed the result. Either way there is an exit status to show.

Returns:

  • (Boolean)


30
31
32
# File 'lib/coat/patch.rb', line 30

def ran?
  !exit.nil?
end