Class: Rc

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano-freebsd/rc.rb

Constant Summary collapse

@@path =
'/etc/rc.conf'

Class Method Summary collapse

Class Method Details

.configs(base, configs) ⇒ Object



23
24
25
26
# File 'lib/capistrano-freebsd/rc.rb', line 23

def self.configs base, configs
  section base
  print_lines(configs.map { |config| base + '_' + config })
end

.init(lines) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/capistrano-freebsd/rc.rb', line 8

def self.init lines
  as :root do
    execute :echo, "> #{@@path}"
  end

  print_lines [
    "# These configurations are automatically generated",
    "# at #{Datetime.now.to_s}.",
  ]
end


32
33
34
35
36
# File 'lib/capistrano-freebsd/rc.rb', line 32

def self.print_line line
  as :root do
    execute :echo, "#{line} >> #{@@path}"
  end
end


28
29
30
# File 'lib/capistrano-freebsd/rc.rb', line 28

def self.print_lines lines
  lines.map(&method(:print_line))
end

.section(title) ⇒ Object



19
20
21
# File 'lib/capistrano-freebsd/rc.rb', line 19

def self.section title
  print_lines ["", "# #{title}"]
end