Class: Property::Dovecot
- Inherits:
-
Property
- Object
- ActiveRecord::Base
- Property
- Property::Dovecot
show all
- Defined in:
- app/models/property/dovecot.rb
Instance Attribute Summary
Attributes inherited from Property
#collection, #multiple, #translate
Class Method Summary
collapse
Methods inherited from Property
add, all_new_values, all_new_values_for_write, all_to_show, #has_new_value?, #input_type, #set_value
Class Method Details
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/models/property/dovecot.rb', line 27
def self.(a, values)
a.edit :file => "#{etc_dovecot}/dovecot.conf", :backup => false do
values.each do |key, value|
param_name = key.split('__').last
rxp = /(\s*#\s#{key}\s+!!.*!!\s*$\s*#{param_name}\s*=\s*)(\d+)/
manipulate do |text|
text =~ rxp
text.gsub rxp, "#{$1}#{value}"
end
end
end
end
|
.etc_dovecot ⇒ Object
7
8
9
|
# File 'app/models/property/dovecot.rb', line 7
def self.etc_dovecot
'/etc/dovecot'
end
|
.service ⇒ Object
3
|
# File 'app/models/property/dovecot.rb', line 3
def self.service; DOVECOT ;end
|
.storage_template(a, values) ⇒ Object
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'app/models/property/dovecot.rb', line 40
def self.storage_template(a, values)
a.edit :file => "#{etc_dovecot}/dovecot.conf", :backup => false do
values.each do |key, value|
value += '%' if value =~ /%$/
manipulate do |text|
case key.to_sym
when :storage_size
text =~ rxp = /(\*:storage\s*=\s*).*$/
when :storage_trash
text =~ rxp = /(Trash:storage\s*=\s*).*$/
when :storage_spam
text =~ rxp = /(Spam:storage\s*=\s*).*$/
else
end
text.gsub rxp, "#{$1}#{value}"
end
end
end
end
|
.value_template(a, locals) ⇒ Object
11
12
13
14
15
16
17
|
# File 'app/models/property/dovecot.rb', line 11
def self.value_template(a, locals)
a.edit :file => "#{etc_dovecot}/dovecot.conf", :backup => false do
locals.each do |key, value|
replace /#{key}\s*=\s*.*/, "#{key} = #{value}"
end
end
end
|
.yes_no_template(a, values) ⇒ Object
19
20
21
22
23
24
25
|
# File 'app/models/property/dovecot.rb', line 19
def self.yes_no_template(a, values)
a.edit :file => "#{etc_dovecot}/dovecot.conf", :backup => false do
values.each do |key, value|
replace /^#{key}\s*=\s*.*$/, "#{key} = #{value}"
end
end
end
|