Permalink
Browse files

Adapt to gpgme 2.0.0 gem.

  • Loading branch information...
1 parent 96f2bb2 commit 33424e54705bb6b9be5d94cf40564920e3f715f1 @mschuerig committed Oct 9, 2011
Showing with 16 additions and 17 deletions.
  1. +2 −2 README
  2. +12 −12 checksums
  3. +0 −1 test/checksums.rb
  4. +2 −2 test/checksums_test.rb
View
4 README
@@ -33,9 +33,9 @@ Prerequisites
-------------
- ruby
-- gpgme ruby bindings
+- gpgme ruby bindings version 2.0.0 (or possibly newer)
- either the gpgme gem
- - or the Debian package libgpgme-ruby
+ - or the Debian package ruby-gpgme
Usage
View
@@ -67,7 +67,7 @@ end
module Checksums
- VERSION = '0.1'
+ VERSION = '0.2'
CHECKSUM_FILENAME = '.checksums'
CALLBACKS = [
@@ -308,7 +308,7 @@ module Checksums
end
def signed_checksums
- GPGME::clearsign(checksums.formatted, :signers => @signer.signers)
+ GPGME::Crypto.clearsign(checksums.formatted, :signers => @signer.signers).read
end
def read_checksums(callbacks = VerificationCallbacks.new)
@@ -328,10 +328,10 @@ module Checksums
def verify_signature(sums)
{}.tap do |result|
- result[:checksums] = GPGME::verify(sums) do |signature|
+ result[:checksums] = GPGME::Crypto.verify(sums) do |signature|
result[:valid] = @signer.valid_signature?(signature)
result[:message] = signature.to_s
- end
+ end.read
end
end
@@ -389,18 +389,18 @@ module Checksums
end
def signer_key
- @signer_key ||= resolve_key(@signer)
- end
-
- def resolve_key(key_or_name)
- GPGME::check_version({}) # required to ensure GPGME is initialized properly
- GPGME::resolve_keys(key_or_name, true, [:sign]).first
+ acceptable_keys.first
end
def acceptable_keys
@acceptable_keys ||= begin
- GPGME::check_version({}) # required to ensure GPGME is initialized properly
- GPGME::list_keys(@signer || '', true, [:sign])
+ keys = []
+ GPGME::Ctx.new do |ctx|
+ ctx.each_key(@signer || '', true) do |k|
+ keys << k if k.usable_for?([:sign])
+ end
+ keys
+ end
end
end
View
View
@@ -1,14 +1,14 @@
require 'rubygems'
-require 'ruby-debug'
+#require 'ruby-debug'
require 'test/unit'
require 'contest'
require 'fileutils'
require 'set'
require 'tmpdir'
-require 'checksums'
+load File.join(File.dirname(__FILE__), '../checksums')
class ChecksumsTest < Test::Unit::TestCase

0 comments on commit 33424e5

Please sign in to comment.