Class: Encruby::CLI
- Inherits:
-
Thor
- Object
- Thor
- Encruby::CLI
- Defined in:
- lib/encruby/cli.rb
Instance Method Summary collapse
Instance Method Details
#decrypt(path) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/encruby/cli.rb', line 20 def decrypt(path) hash = [:signaturee] if !hash && [:verify] hash = "Please, provide signature for this file! [Enter to skip verification]:" hash = ask(hash).strip hash = nil if hash.empty? end opts = .dup.merge(signature: hash, save: true) key = opts.delete(:identity_file) response = Encruby::File.new(path, key, opts).decrypt say_status "Success", "Done!", :green say_status "Digest", response[:signature], :cyan end |
#encrypt(path) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/encruby/cli.rb', line 7 def encrypt(path) opts = .dup.merge(save: true) key = opts.delete(:identity_file) response = Encruby::File.new(path, key, opts).encrypt say_status "Success", "Done!", :green say_status "Digest", response[:signature], :cyan end |
#exec(path) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/encruby/cli.rb', line 39 def exec(path) hash = [:signature] if !hash && [:verify] hash = "Please, provide signature for this file! [Enter to skip verification]:" hash = ask(hash).strip hash = nil if hash.empty? end opts = .dup.merge(signature: hash, save: true) key = opts.delete(:identity_file) response = Encruby::File.new(path, key, opts).decrypt path = response[:path] command = response[:path] command = "ruby #{command}" unless response[:path].readlines[0] =~ /^#\!/ command = "#{command}; rm -f #{response[:path]}" Kernel.exec(command.to_s) end |