Module: Capistrano::Memcached::Helpers
- Defined in:
- lib/capistrano/memcached/helpers.rb
Instance Method Summary collapse
- #deploy_user ⇒ Object
- #file_exists?(path) ⇒ Boolean
- #mem_template(template_name) ⇒ Object
- #sudo_upload!(from, to) ⇒ Object
Instance Method Details
#deploy_user ⇒ Object
20 21 22 |
# File 'lib/capistrano/memcached/helpers.rb', line 20 def deploy_user capture :id, '-un' end |
#file_exists?(path) ⇒ Boolean
16 17 18 |
# File 'lib/capistrano/memcached/helpers.rb', line 16 def file_exists?(path) test "[ -e #{path} ]" end |
#mem_template(template_name) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/capistrano/memcached/helpers.rb', line 7 def mem_template(template_name) config_file = "#{fetch(:templates_path)}/#{template_name}" # if no customized file, proceed with default unless File.exists?(config_file) config_file = File.join(File.dirname(__FILE__), "../../generators/capistrano/memcached/templates/#{template_name}") end StringIO.new(ERB.new(File.read(config_file)).result(binding)) end |
#sudo_upload!(from, to) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/capistrano/memcached/helpers.rb', line 24 def sudo_upload!(from, to) filename = File.basename(to) to_dir = File.dirname(to) tmp_file = "#{fetch(:tmp_dir)}/#{filename}" upload! from, tmp_file sudo :mv, tmp_file, to_dir end |