Created
September 14, 2011 20:21
-
-
Save jmileham/1217668 to your computer and use it in GitHub Desktop.
Minimal GPG Paperclip processor
This file contains 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 characters
# You'll need to pregenerate a keyring with your pubkey in it and add to your repo. | |
# GPG does this automatically when you import keys to a non-existant keyring file. | |
module Paperclip | |
class Encrypt < Processor | |
def make | |
raise ArgumentError.new("no :encrypt_to address provided. (#{@options.inspect})") unless @options[:encrypt_to] | |
Tempfile.new(['attachment','.pgp']).tap do |outfile| | |
Paperclip.run('gpg', '--batch --always-trust --keyring :keyring --no-default-keyring -o :out -r :recipient -e :in', :in => @file.path, :out => outfile.path, :recipient => @options[:encrypt_to], :keyring => PATH_TO_MY_KEYRING) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment