Module: Initd::Export

Included in:
Foreman::Export::Initd, Foreman::Export::InitdMonit
Defined in:
lib/initd/export.rb

Instance Method Summary collapse

Instance Method Details

#cleanupObject



13
14
15
16
17
18
19
20
21
# File 'lib/initd/export.rb', line 13

def cleanup
  Dir.glob export_path.join("#{app}-*") do |filename|
    contents = File.new(filename, 'r').read
    next unless contents.match(/# Autogenerated by foreman/)
    next if @exported.include? filename.to_s
    say 'removing ' + filename
    File.unlink filename
  end
end

#concurrency(name) ⇒ Object



29
30
31
# File 'lib/initd/export.rb', line 29

def concurrency(name)
  engine.formation[name]
end

#export_file(path, contents) ⇒ Object



23
24
25
26
27
# File 'lib/initd/export.rb', line 23

def export_file (path, contents)
  write_file(path, contents)
  File.chmod(0755, path)
  @exported.push path.to_s
end

#export_pathObject



3
4
5
# File 'lib/initd/export.rb', line 3

def export_path
  Pathname.new location
end

#path(name) ⇒ Object



33
34
35
# File 'lib/initd/export.rb', line 33

def path(name)
  export_path.join("#{app}-#{name}")
end

#setupObject



7
8
9
10
11
# File 'lib/initd/export.rb', line 7

def setup
  @exported = []
  say "creating: #{export_path}"
  FileUtils.mkdir_p(export_path)
end