Module: RSpec::PGPMatchers::GPGRunner
- Defined in:
- lib/rspec/pgp_matchers/gpg_runner.rb
Class Method Summary collapse
- .run_command(gpg_cmd) ⇒ Object
- .run_decrypt(encrypted_string) ⇒ Object
- .run_verify(cleartext, signature_string) ⇒ Object
Class Method Details
.run_command(gpg_cmd) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/rspec/pgp_matchers/gpg_runner.rb', line 11 def run_command(gpg_cmd) env = { "LC_ALL" => "C" } # Gettext English locale homedir_path = Shellwords.escape(RSpec::PGPMatchers.homedir) Open3.capture3(env, " gpg \\\n --homedir \#{homedir_path} \\\n --no-permission-warning \\\n \#{gpg_cmd}\n SH\nend\n") |
.run_decrypt(encrypted_string) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/rspec/pgp_matchers/gpg_runner.rb', line 24 def run_decrypt(encrypted_string) enc_file = make_tempfile_containing(encrypted_string) cmd = gpg_decrypt_command(enc_file) run_command(cmd) ensure File.unlink(enc_file.path) end |
.run_verify(cleartext, signature_string) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/rspec/pgp_matchers/gpg_runner.rb', line 32 def run_verify(cleartext, signature_string) sig_file = make_tempfile_containing(signature_string) data_file = make_tempfile_containing(cleartext) cmd = gpg_verify_command(sig_file, data_file) run_command(cmd) ensure File.unlink(sig_file.path, data_file.path) end |