Class: Puppet::Cleaner::Worker
- Inherits:
-
Object
- Object
- Puppet::Cleaner::Worker
show all
- Defined in:
- lib/puppet-cleaner/workers.rb
Instance Method Summary
collapse
Instance Method Details
#get_param(line, param_name, pos) ⇒ Object
11
12
13
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
52
53
54
55
56
57
|
# File 'lib/puppet-cleaner/workers.rb', line 11
def get_param(line, param_name, pos)
depth = 1
loop do
pos += 1
break if depth == 0 || pos >= line.parts.size
case line.parts[pos].name
when :LBRACE, :COLON
depth += 1
when :RBRACE
depth -= 1
when :SEMIC
depth -= 1
when :FARROW
next if depth != 1
parampos = pos - 1
parampos -= 1 while [:BLANK, :RETURN].include?(line.parts[parampos].name)
next unless line.parts[parampos].name == :NAME && line.parts[parampos].value == param_name
start = parampos - 1
start -= 1 while [:BLANK, :RETURN].include?(line.parts[start].name)
start += 1
loop do
pos += 1
break if depth < 0 || pos >= line.parts.size
case line.parts[pos].name
when :LBRACE
depth += 1
when :COMMA, :SEMIC, :RBRACE
depth -= 1 if line.parts[pos].name == :RBRACE
next if depth > 1
pos += 1 if line.parts[pos].name == :RBRACE && depth == 1
pos += 1 while pos < line.parts.size && ![:COMMA, :SEMIC, :RBRACE].include?(line.parts[pos].name)
break
end
end
return nil if pos >= line.parts.size
pos -= 1 unless line.parts[pos].name == :COMMA
pos -= 1 while [:BLANK, :RETURN].include?(line.parts[pos].name)
return [start, pos]
end
end
nil
end
|
#operate ⇒ Object
7
8
9
|
# File 'lib/puppet-cleaner/workers.rb', line 7
def operate
raise "Must be implemented in subclass"
end
|
#part_names ⇒ Object
3
4
5
|
# File 'lib/puppet-cleaner/workers.rb', line 3
def part_names
raise "Must be implemented in subclass"
end
|