Skip to content

Commit

Permalink
Add Key#expires? and fix SubKex#expires
Browse files Browse the repository at this point in the history
- Add SubKey#expires?

  Returns true if the subkey has an expiration date, else false

- Fix SubKey#expires

  Returns nil if the key has no expiration date

- Add Key#expires?

  Returns true if the key has an expiration data, else false
  • Loading branch information
ushis committed Sep 15, 2014
1 parent 5b3069d commit 9046bb5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/gpgme/key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ def delete!(allow_secret = false)
end
end

##
# Returns true if the key has an expiry date else false
def expires?
primary_subkey.expires?
end

##
# Returns the expiry date for this key
def expires
Expand Down
9 changes: 6 additions & 3 deletions lib/gpgme/sub_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ def timestamp
Time.at(@timestamp)
end

def expires?
@expires != 0
end

def expires
Time.at(@expires)
expires? ? Time.at(@expires) : nil
end

def expired
return false if @expires == 0
@expires < Time.now.to_i
expires? && @expires < Time.now.to_i
end

def sha
Expand Down

0 comments on commit 9046bb5

Please sign in to comment.