Class: Moku::Instance

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

Overview

Represents a named instance within moku, as opposed to installed on destination servers.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, source:, deploy:, infrastructure:, dev:, releases: []) ⇒ Instance

Returns a new instance of Instance.

Parameters:


19
20
21
22
23
24
25
26
# File 'lib/moku/instance.rb', line 19

def initialize(name:, source:, deploy:, infrastructure:, dev:, releases: [])
  @name = name
  @source = source
  @deploy = deploy
  @infrastructure = infrastructure
  @dev = dev
  @releases = releases
end

Instance Attribute Details

#deployObject (readonly)

Returns the value of attribute deploy


29
30
31
# File 'lib/moku/instance.rb', line 29

def deploy
  @deploy
end

#devObject (readonly)

Returns the value of attribute dev


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

def dev
  @dev
end

#infrastructureObject (readonly)

Returns the value of attribute infrastructure


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

def infrastructure
  @infrastructure
end

#nameObject (readonly)

Returns the value of attribute name


28
29
30
# File 'lib/moku/instance.rb', line 28

def name
  @name
end

#sourceObject (readonly)

Returns the value of attribute source


29
30
31
# File 'lib/moku/instance.rb', line 29

def source
  @source
end

Instance Method Details

#cachesArray<LoggedRelease>

Returns:


59
60
61
62
# File 'lib/moku/instance.rb', line 59

def caches
  releases
    .slice(0, 5)
end

#default_branchString

Returns:

  • (String)

44
45
46
# File 'lib/moku/instance.rb', line 44

def default_branch
  source.commitish
end

#default_branch=(name) ⇒ Object

Parameters:

  • name (String)

49
50
51
# File 'lib/moku/instance.rb', line 49

def default_branch=(name)
  @source = source.branch(name)
end

#log_release(release) ⇒ Object

Parameters:


54
55
56
# File 'lib/moku/instance.rb', line 54

def log_release(release)
  @releases << release
end

#releasesArray<LoggedRelease>

Returns:


65
66
67
68
69
# File 'lib/moku/instance.rb', line 65

def releases
  @releases
    .sort_by(&:id)
    .reverse
end

#signature(commitish = nil) ⇒ ReleaseSignature

Parameters:

  • commitish (String) (defaults to: nil)

Returns:


34
35
36
37
38
39
40
41
# File 'lib/moku/instance.rb', line 34

def signature(commitish = nil)
  ReleaseSignature.new(
    deploy: deploy.latest,
    source: source.at(commitish),
    infrastructure: infrastructure.latest,
    dev: dev.latest
  )
end