diff options
| author | Mike McQuaid | 2017-12-23 16:52:50 +0000 |
|---|---|---|
| committer | Mike McQuaid | 2017-12-23 16:53:25 +0000 |
| commit | e8fa6f9ad198f3746aaa86512708b95ea0c49d39 (patch) | |
| tree | e4461992f5eaeab9c50fe455149571ec4b47a46d | |
| parent | 08a452fead3c7418a7409a5ae651c13498e97f7e (diff) | |
| download | brew-e8fa6f9ad198f3746aaa86512708b95ea0c49d39.tar.bz2 | |
gpg: cleanup and simplify.
| -rw-r--r-- | Library/Homebrew/gpg.rb | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/Library/Homebrew/gpg.rb b/Library/Homebrew/gpg.rb index 83b525b44..f1b989a16 100644 --- a/Library/Homebrew/gpg.rb +++ b/Library/Homebrew/gpg.rb @@ -1,29 +1,17 @@ require "utils" class Gpg - def self.find_gpg(executable) - which_all(executable).detect do |gpg| - gpg_short_version = Utils.popen_read(gpg, "--version")[/\d\.\d/, 0] - next unless gpg_short_version - gpg_version = Version.create(gpg_short_version.to_s) - @version = gpg_version - gpg_version >= Version.create("2.0") - end - end + module_function - def self.executable - find_gpg("gpg") || find_gpg("gpg2") + def executable + which "gpg" end - def self.available? + def available? File.executable?(executable.to_s) end - def self.version - @version if available? - end - - def self.create_test_key(path) + def create_test_key(path) odie "No GPG present to test against!" unless available? (path/"batch.gpg").write <<~EOS @@ -40,8 +28,9 @@ class Gpg system executable, "--batch", "--gen-key", "batch.gpg" end - def self.cleanup_test_processes! + def cleanup_test_processes! odie "No GPG present to test against!" unless available? + gpgconf = Pathname.new(executable).parent/"gpgconf" system gpgconf, "--kill", "gpg-agent" @@ -49,7 +38,7 @@ class Gpg "gpg-agent" end - def self.test(path) + def test(path) create_test_key(path) begin yield |
