- def self.key_line_regexp
- # This regexp is trying to match the following output
- # pub 4096R/4BD6EC30 2010-07-10 [expires: 2016-07-08]
- # pub 1024D/CD2EFD2A 2009-12-15
- regexp = /\A
- pub # match only the public key, not signatures
- \s+ # bunch of spaces after that
- (#{KEY_LINE[:key_size]}) # size of the key, usually a multiple of 1024
- #{KEY_LINE[:key_type]} # type of the key, usually R or D
- \/ # separator between key_type and key_id
- (#{KEY_LINE[:key_id]}) # hex id of the key
- \s+ # bunch of spaces after that
- (#{KEY_LINE[:date]}) # date the key was added to the keyring
- # following an optional block which indicates if the key has an expiration
- # date and if it has expired yet
- (
- \s+ # again with thes paces
- \[ # we open with a square bracket
- #{KEY_LINE[:expires]} # expires or expired
- \: # a colon
- \s+ # more spaces
- (#{KEY_LINE[:date]}) # date indicating key expiry
- \] # we close with a square bracket
- )? # end of the optional block
- \Z/x
- regexp