Class: FTPMVC::Filter::Gpg
- Inherits:
-
Base
- Object
- Base
- FTPMVC::Filter::Gpg
- Defined in:
- lib/ftpmvc/filter/gpg.rb
Instance Method Summary collapse
- #directory?(path) ⇒ Boolean
- #exists?(path) ⇒ Boolean
- #get(path) ⇒ Object
- #index(path) ⇒ Object
-
#initialize(fs, chain, options = {}) ⇒ Gpg
constructor
A new instance of Gpg.
- #put(path, input) ⇒ Object
Constructor Details
#initialize(fs, chain, options = {}) ⇒ Gpg
Returns a new instance of Gpg.
8 9 10 11 12 13 |
# File 'lib/ftpmvc/filter/gpg.rb', line 8 def initialize(fs, chain, ={}) super fs, chain @crypto = GPGME::Crypto.new( password: [:passphrase], recipients: [:recipients], always_trust: true) import_keys([:keys]) if .include?(:keys) end |
Instance Method Details
#directory?(path) ⇒ Boolean
31 32 33 |
# File 'lib/ftpmvc/filter/gpg.rb', line 31 def directory?(path) @chain.directory?(remove_extension(path)) end |
#exists?(path) ⇒ Boolean
27 28 29 |
# File 'lib/ftpmvc/filter/gpg.rb', line 27 def exists?(path) @chain.exists?(remove_extension(path)) end |
#get(path) ⇒ Object
23 24 25 |
# File 'lib/ftpmvc/filter/gpg.rb', line 23 def get(path) StringIO.new(@crypto.encrypt(original_data(path)).read) end |
#index(path) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/ftpmvc/filter/gpg.rb', line 15 def index(path) @chain.index(path).each do |node| if node.kind_of?(File) and not ::File.extname(node.name) == '.gpg' node.name = "#{node.name}.gpg" end end end |
#put(path, input) ⇒ Object
35 36 37 |
# File 'lib/ftpmvc/filter/gpg.rb', line 35 def put(path, input) @chain.put(remove_extension(path), FTPMVC::GPG::Input.new(@crypto.decrypt(input.read_all))) end |