Class: ConfCtl::Generation::Unified

Inherits:
Object
  • Object
show all
Defined in:
lib/confctl/generation/unified.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, build_generation: nil, host_generation: nil) ⇒ Unified

Returns a new instance of Unified.

Parameters:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/confctl/generation/unified.rb', line 30

def initialize(host, build_generation: nil, host_generation: nil)
  @host = host
  @build_generation = build_generation
  @host_generation = host_generation
  @id = host_generation && host_generation.id

  if build_generation
    @name = build_generation.name
    @toplevel = build_generation.toplevel
    @date = build_generation.date
    @current ||= build_generation.current
  elsif host_generation
    @name = host_generation.approx_name
    @toplevel = host_generation.toplevel
    @date = host_generation.date
    @current ||= host_generation.current
  else
    raise ArgumentError, 'set build or host'
  end
end

Instance Attribute Details

#build_generationGeneration::Build

Returns:



22
23
24
# File 'lib/confctl/generation/unified.rb', line 22

def build_generation
  @build_generation
end

#currentBoolean (readonly)

Returns:

  • (Boolean)


19
20
21
# File 'lib/confctl/generation/unified.rb', line 19

def current
  @current
end

#dateTime (readonly)

Returns:

  • (Time)


16
17
18
# File 'lib/confctl/generation/unified.rb', line 16

def date
  @date
end

#hostString (readonly)

Returns:

  • (String)


4
5
6
# File 'lib/confctl/generation/unified.rb', line 4

def host
  @host
end

#host_generationGeneration::Host

Returns:



25
26
27
# File 'lib/confctl/generation/unified.rb', line 25

def host_generation
  @host_generation
end

#idInteger? (readonly)

Returns:

  • (Integer, nil)


10
11
12
# File 'lib/confctl/generation/unified.rb', line 10

def id
  @id
end

#nameString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/confctl/generation/unified.rb', line 7

def name
  @name
end

#toplevelString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/confctl/generation/unified.rb', line 13

def toplevel
  @toplevel
end

Instance Method Details

#current_strObject



86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/confctl/generation/unified.rb', line 86

def current_str
  build = build_generation && build_generation.current
  host = host_generation && host_generation.current

  if build && host
    'build+host'
  elsif build
    'build'
  elsif host
    'host'
  end
end

#destroyObject



111
112
113
114
115
# File 'lib/confctl/generation/unified.rb', line 111

def destroy
  build_generation.destroy if build_generation
  host_generation.destroy if host_generation
  true
end

#includes?(gen) ⇒ Boolean

Determines whether ‘gen` can be wrapped by this object

Parameters:

Returns:

  • (Boolean)


69
70
71
72
73
74
75
76
77
78
# File 'lib/confctl/generation/unified.rb', line 69

def includes?(gen)
  return false if host != gen.host || toplevel != gen.toplevel

  if build_generation && gen.is_a?(Generation::Build)
    build_generation.name == gen.name \
      && build_generation.swpin_paths == gen.swpin_paths
  else
    true
  end
end

#presence_strObject



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/confctl/generation/unified.rb', line 99

def presence_str
  if build_generation && host_generation
    'build+host'
  elsif build_generation
    'build'
  elsif host_generation
    'host'
  else
    raise 'programming error'
  end
end