Class: ConfCtl::Generation::BuildList
- Inherits:
-
Object
- Object
- ConfCtl::Generation::BuildList
show all
- Includes:
- Utils::File
- Defined in:
- lib/confctl/generation/build_list.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#replace_symlink, #unlink_if_exists
Constructor Details
#initialize(host) ⇒ String
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/confctl/generation/build_list.rb', line 14
def initialize(host)
@host = host
@generations = []
@index = {}
return unless Dir.exist?(dir)
Dir.entries(dir).each do |v|
abs_path = File.join(dir, v)
next if %w[. ..].include?(v) || !Dir.exist?(abs_path) || File.symlink?(abs_path)
gen = Generation::Build.new(host)
begin
gen.load(v)
rescue Error => e
warn "Ignoring invalid generation #{gen.dir}"
next
end
generations << gen
index[gen.name] = gen
end
generations.sort! do |a, b|
a.date <=> b.date
end
current_gen =
if File.exist?(current_symlink)
name = File.basename(File.readlink(current_symlink))
index[name] || generations.last
else
generations.last
end
change_current(current_gen) if current_gen
end
|
Instance Attribute Details
11
12
13
|
# File 'lib/confctl/generation/build_list.rb', line 11
def current
@current
end
|
#host ⇒ String
8
9
10
|
# File 'lib/confctl/generation/build_list.rb', line 8
def host
@host
end
|
Instance Method Details
#[](name) ⇒ Object
54
55
56
|
# File 'lib/confctl/generation/build_list.rb', line 54
def [](name)
index[name]
end
|
#count ⇒ Integer
68
69
70
|
# File 'lib/confctl/generation/build_list.rb', line 68
def count
generations.length
end
|
#each ⇒ Object
58
59
60
|
# File 'lib/confctl/generation/build_list.rb', line 58
def each(&)
generations.each(&)
end
|
82
83
84
85
86
|
# File 'lib/confctl/generation/build_list.rb', line 82
def find(toplevel, swpin_paths)
generations.detect do |gen|
gen.toplevel == toplevel && gen.swpin_paths == swpin_paths
end
end
|
63
64
65
|
# File 'lib/confctl/generation/build_list.rb', line 63
def to_a
generations.clone
end
|