Module: Capistrano::ResqueMonit

Defined in:
lib/capistrano/resque_monit.rb,
lib/capistrano/resque_monit/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.file_name(name) ⇒ Object



10
11
12
# File 'lib/capistrano/resque_monit.rb', line 10

def self.file_name(name)
  "resque_worker_#{fetch(:resque_application)}_#{name}"
end

.put_as_root(content, destination, host, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/capistrano/resque_monit.rb', line 22

def self.put_as_root(content, destination, host, options = {})
  SSHKit::Coordinator.new(host).each do
    basename ||= File.basename(destination)
    tmp_path = "#{current_path}/tmp/#{basename}"
    upload! StringIO.new(content), tmp_path, options
    execute :sudo, "mv #{tmp_path} #{destination}"
    execute :sudo, "chown root:root #{destination}"
  end
end

.rootObject



6
7
8
# File 'lib/capistrano/resque_monit.rb', line 6

def self.root
  @root ||= Gem::Specification.find_by_name('capistrano-resque_monit').gem_dir
end

.template(filename, values = {}) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/capistrano/resque_monit.rb', line 14

def self.template(filename, values = {})
  template = File.open(File.join(Capistrano::ResqueMonit.root, 'templates', filename)).read
  unless values.empty?
    template.gsub!(/#\{([^}]+)\}/) { values[$1.to_sym] }
  end
  template
end