Class: Bitferry::Rclone::Encryption
- Inherits:
-
Object
- Object
- Bitferry::Rclone::Encryption
- Defined in:
- lib/bitferry.rb
Constant Summary collapse
- PROCESS =
{ default: ['--crypt-filename-encoding', :base32, '--crypt-filename-encryption', :standard], extended: ['--crypt-filename-encoding', :base32768, '--crypt-filename-encryption', :standard] }
Class Method Summary collapse
Instance Method Summary collapse
- #arguments(task) ⇒ Object
- #configure(task) ⇒ Object
- #create(password, **opts) ⇒ Object
- #externalize ⇒ Object
-
#initialize(token, process: nil) ⇒ Encryption
constructor
A new instance of Encryption.
- #install_token(task) ⇒ Object
- #obtain_token(task) ⇒ Object
- #process(task) ⇒ Object
-
#process_options ⇒ Object
As a mandatory option it should never be nil.
- #restore(hash) ⇒ Object
Constructor Details
#initialize(token, process: nil) ⇒ Encryption
Returns a new instance of Encryption.
725 726 727 728 |
# File 'lib/bitferry.rb', line 725 def initialize(token, process: nil) @process_options = Bitferry.optional(process, PROCESS) @token = token end |
Class Method Details
.new(*args, **opts) ⇒ Object
759 760 761 762 763 |
# File 'lib/bitferry.rb', line 759 def self.new(*args, **opts) obj = allocate obj.send(:create, *args, **opts) obj end |
.restore(hash) ⇒ Object
766 767 768 769 770 |
# File 'lib/bitferry.rb', line 766 def self.restore(hash) obj = ROUTE.fetch(hash.fetch(:operation).intern).allocate obj.send(:restore, hash) obj end |
Instance Method Details
#arguments(task) ⇒ Object
746 |
# File 'lib/bitferry.rb', line 746 def arguments(task) = + ['--crypt-remote', encrypted(task).root.to_s] |
#configure(task) ⇒ Object
740 |
# File 'lib/bitferry.rb', line 740 def configure(task) = install_token(task) |
#create(password, **opts) ⇒ Object
731 |
# File 'lib/bitferry.rb', line 731 def create(password, **opts) = initialize(Rclone.obscure(password), **opts) |
#externalize ⇒ Object
737 |
# File 'lib/bitferry.rb', line 737 def externalize = .empty? ? {} : { rclone: } |
#install_token(task) ⇒ Object
749 750 751 752 753 |
# File 'lib/bitferry.rb', line 749 def install_token(task) x = decrypted(task) raise TypeError, 'unsupported unencrypted endpoint type' unless x.is_a?(Endpoint::Bitferry) Volume[x.volume_tag].vault[task.tag] = @token # Token is stored on the decrypted end only end |
#obtain_token(task) ⇒ Object
756 |
# File 'lib/bitferry.rb', line 756 def obtain_token(task) = Volume[decrypted(task).volume_tag].vault.fetch(task.tag) |
#process(task) ⇒ Object
743 |
# File 'lib/bitferry.rb', line 743 def process(task) = ENV['RCLONE_CRYPT_PASSWORD'] = obtain_token(task) |
#process_options ⇒ Object
As a mandatory option it should never be nil
722 |
# File 'lib/bitferry.rb', line 722 def = @process_options.nil? ? [] : @process_options # As a mandatory option it should never be nil |
#restore(hash) ⇒ Object
734 |
# File 'lib/bitferry.rb', line 734 def restore(hash) = @process_options = hash[:rclone] |