Module: Capistrano::Cluster::Packages::DSL
- Defined in:
- lib/capistrano/cluster/packages.rb
Defined Under Namespace
Classes: TemplateContext
Instance Method Summary collapse
- #file(source, locals = {}) ⇒ Object
- #file_path(source) ⇒ Object
- #install(*packages) ⇒ Object
- #update_apt_source_list(forced: false) ⇒ Object
Instance Method Details
#file(source, locals = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/capistrano/cluster/packages.rb', line 26 def file(source, locals={}) if file = file_path(source) content = if file =~ /\.erb$/ ERB.new(File.read(file)).result(TemplateContext.new(self, locals).instance_eval { binding }) else File.read(file) end StringIO.new(content) else raise "File #{source} not found" end end |
#file_path(source) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/capistrano/cluster/packages.rb', line 41 def file_path(source) lookup_paths = [fetch(:files_path), fetch(:default_templates_path)].compact lookup_paths.map do |path| [File.join(path, "#{source}"), File.join(path, "#{source}.erb")] end.flatten.select do |file| File.exists? file end.first end |
#install(*packages) ⇒ Object
10 11 12 13 |
# File 'lib/capistrano/cluster/packages.rb', line 10 def install(*packages) update_apt_source_list sudo "apt-get", "-q", "-y", "--force-yes","install", *packages.flatten end |
#update_apt_source_list(forced: false) ⇒ Object
50 51 52 |
# File 'lib/capistrano/cluster/packages.rb', line 50 def update_apt_source_list(forced: false) sudo "apt-get", "-q", "-y", "update" if forced or test "[ ! -z $(find /var/lib/apt/periodic/update-success-stamp -mmin +120) ]" end |