diff options
author | Azul <azul@leap.se> | 2014-04-08 11:49:14 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-04-08 11:49:14 +0200 |
commit | b6d14dc19dd350a807826e3e097738a36613e083 (patch) | |
tree | 093dc5f2f1e773e3ad009d28d1fd24667d3c0ba6 /users/app/models/pgp_key.rb | |
parent | 2e11e3ca2c7b02fdb5ff54f0bcd766cc5fa39975 (diff) |
moving users: app and test files
Diffstat (limited to 'users/app/models/pgp_key.rb')
-rw-r--r-- | users/app/models/pgp_key.rb | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/users/app/models/pgp_key.rb b/users/app/models/pgp_key.rb deleted file mode 100644 index 66f8660..0000000 --- a/users/app/models/pgp_key.rb +++ /dev/null @@ -1,48 +0,0 @@ -class PgpKey - include ActiveModel::Validations - - KEYBLOCK_IDENTIFIERS = [ - '-----BEGIN PGP PUBLIC KEY BLOCK-----', - '-----END PGP PUBLIC KEY BLOCK-----', - ] - - # mostly for testing. - attr_accessor :keyblock - - validate :validate_keyblock_format - - def initialize(keyblock = nil) - @keyblock = keyblock - end - - def to_s - @keyblock - end - - def present? - @keyblock.present? - end - - # allow comparison with plain keyblock strings. - def ==(other) - self.equal?(other) or - # relax the comparison on line ends. - self.to_s.tr_s("\n\r", '') == other.tr_s("\r\n", '') - end - - protected - - def validate_keyblock_format - if keyblock_identifier_missing? - errors.add :public_key_block, - "does not look like an armored pgp public key block" - end - end - - def keyblock_identifier_missing? - KEYBLOCK_IDENTIFIERS.find do |identify| - !@keyblock.include?(identify) - end - end - -end |