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:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/confctl/generation/unified.rb', line 33

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
    @kernel_version = build_generation.kernel_version
    @current ||= build_generation.current
  elsif host_generation
    @name = host_generation.approx_name
    @toplevel = host_generation.toplevel
    @date = host_generation.date
    @kernel_version = host_generation.kernel_version
    @current ||= host_generation.current
  else
    raise ArgumentError, 'set build or host'
  end
end

Instance Attribute Details

#build_generationGeneration::Build

Returns:



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

def build_generation
  @build_generation
end

#currentBoolean (readonly)

Returns:

  • (Boolean)


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

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:



28
29
30
# File 'lib/confctl/generation/unified.rb', line 28

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

#kernel_versionString? (readonly)

Returns:

  • (String, nil)


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

def kernel_version
  @kernel_version
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



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/confctl/generation/unified.rb', line 91

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



116
117
118
119
120
# File 'lib/confctl/generation/unified.rb', line 116

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)


74
75
76
77
78
79
80
81
82
83
# File 'lib/confctl/generation/unified.rb', line 74

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



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/confctl/generation/unified.rb', line 104

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