Created
April 17, 2012 18:12
-
-
Save mklnz/2407925 to your computer and use it in GitHub Desktop.
Revisions
-
mklnz revised this gist
Apr 17, 2012 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,14 @@ # I got tired of uploading to /tmp then moving to the correct location, so these two convenience methods will save you a lot of time in the long run. # Helper method to upload to /tmp then use sudo to move to correct location. def put_sudo(data, to) filename = File.basename(to) to_directory = File.dirname(to) put data, "/tmp/#{filename}" run "#{sudo} mv /tmp/#{filename} #{to_directory}" end # Helper method to create ERB template then upload using sudo privileges (modified from rbates) def template_sudo(from, to) erb = File.read(File.expand_path("../templates/#{from}", __FILE__)) put_sudo ERB.new(erb).result(binding), to -
mklnz created this gist
Apr 17, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ #Helper method to upload to /tmp then use sudo to move to correct location. def put_sudo(data, to) filename = File.basename(to) to_directory = File.dirname(to) put data, "/tmp/#{filename}" run "#{sudo} mv /tmp/#{filename} #{to_directory}" end #Helper method to create ERB template then upload using sudo privileges (modified from rbates) def template_sudo(from, to) erb = File.read(File.expand_path("../templates/#{from}", __FILE__)) put_sudo ERB.new(erb).result(binding), to end