Class: Moku::LoggedRelease

Inherits:
Object
  • Object
show all
Defined in:
lib/moku/logged_release.rb

Overview

A representation of a release within a log that includes additional metadata.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, signature:, time:, user:, version:) ⇒ LoggedRelease

Returns a new instance of LoggedRelease.

Parameters:

  • id (String)
  • signature (ReleaseSignature)
  • time (Time)
  • user (String)
  • version (String)

37
38
39
40
41
42
43
# File 'lib/moku/logged_release.rb', line 37

def initialize(id:, signature:, time:, user:, version:)
  @id = id
  @signature = signature
  @time = time
  @user = user
  @version = version
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id


30
31
32
# File 'lib/moku/logged_release.rb', line 30

def id
  @id
end

#signatureObject (readonly)

Returns the value of attribute signature


30
31
32
# File 'lib/moku/logged_release.rb', line 30

def signature
  @signature
end

Class Method Details

.from_hash(hash) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/moku/logged_release.rb', line 13

def from_hash(hash)
  time = Time.strptime(hash[:time], time_format)
  signature = ReleaseSignature.from_hash(hash[:signature])
  new(
    id: hash[:id] || (time+0.001).strftime(Moku.release_time_format),
    user: hash[:user],
    time: time,
    version: hash[:version] || signature.source.commitish,
    signature: signature
  )
end

.time_formatObject


25
26
27
# File 'lib/moku/logged_release.rb', line 25

def time_format
  "%FT%T"
end

Instance Method Details

#to_brief_hashObject


45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/moku/logged_release.rb', line 45

def to_brief_hash
  {
    id:             id,
    version:        version,
    time:           formatted_time,
    user:           user,
    source:         source,
    deploy:         deploy,
    dev:            dev,
    infrastructure: infrastructure
  }
end

#to_hashObject


65
66
67
68
69
70
71
72
73
# File 'lib/moku/logged_release.rb', line 65

def to_hash
  {
    id:        id,
    version:   version,
    user:      user,
    time:      formatted_time,
    signature: signature.to_hash
  }
end

#to_sObject


58
59
60
61
62
63
# File 'lib/moku/logged_release.rb', line 58

def to_s
  "#{formatted_time}: #{user} #{id} #{version} w/ #{deploy}\n" \
    "  #{source}\n" \
    "  #{dev}\n" \
    "  #{infrastructure}"
end