ruby_gpg2 0.1.0.pre.6 → 0.1.0.pre.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ruby_gpg2/colon_output.rb +54 -4
- data/lib/ruby_gpg2/colon_record.rb +28 -0
- data/lib/ruby_gpg2/key.rb +58 -0
- data/lib/ruby_gpg2/user_id.rb +43 -0
- data/lib/ruby_gpg2/version.rb +1 -1
- data/lib/ruby_gpg2.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb0849638a19aa4b0403c24df4b3c7bc7f395a2d6d1b7f0eec28e0c87acdac4f
|
4
|
+
data.tar.gz: 6c5f98a82c15e4974c062f2aa606a1f908cc5454b1fc9a1869f79540ad557476
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbfb0b48c99ae4390987ff2a7ae7907745facb6a0fa677055eb9f83dbff03ab210a7772f0a35444a82c23a2f0867e96cdfc6f16346e3e74bffac39aafddc023e
|
7
|
+
data.tar.gz: bc23189fc6f9984a33f0bd956301c05767ecb9e4adbd72ba7c8f3541dab758c6b68dc50c9fe831c8ca2db93cfc1a13797c00024dc3904973da21fffa7062cd4e
|
data/Gemfile.lock
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative './colon_record'
|
2
|
+
require_relative './key'
|
2
3
|
|
3
4
|
module RubyGPG2
|
4
5
|
class ColonOutput
|
@@ -9,14 +10,63 @@ module RubyGPG2
|
|
9
10
|
.collect { |record| ColonRecord.parse(record) })
|
10
11
|
end
|
11
12
|
|
12
|
-
include Enumerable
|
13
|
-
|
14
13
|
def initialize(records)
|
15
14
|
@records = records
|
16
15
|
end
|
17
16
|
|
18
|
-
def
|
19
|
-
@records
|
17
|
+
def public_keys
|
18
|
+
public_key_indices = @records
|
19
|
+
.each_with_index
|
20
|
+
.collect { |record, index|
|
21
|
+
record.type == :public_key ? index : nil
|
22
|
+
}
|
23
|
+
.compact << @records.count
|
24
|
+
|
25
|
+
public_key_record_groups = []
|
26
|
+
public_key_indices.each_cons(2) do |index_pair|
|
27
|
+
public_key_record_groups <<
|
28
|
+
@records[index_pair[0]...index_pair[1]]
|
29
|
+
end
|
30
|
+
|
31
|
+
public_key_record_groups.map do |record_group|
|
32
|
+
records_in_group = record_group.count
|
33
|
+
public_key_record = record_group[0]
|
34
|
+
|
35
|
+
fingerprint_record =
|
36
|
+
(records_in_group > 1 && record_group[1].fingerprint_record?) ?
|
37
|
+
record_group[1] :
|
38
|
+
nil
|
39
|
+
fingerprint = fingerprint_record&.fingerprint
|
40
|
+
|
41
|
+
user_id_records = record_group
|
42
|
+
.drop_while { |r| !r.user_id_record? }
|
43
|
+
.take_while { |r| r.user_id_record? }
|
44
|
+
user_ids = user_id_records.map do |record|
|
45
|
+
UserID.new(
|
46
|
+
name: record.user_name,
|
47
|
+
comment: record.user_comment,
|
48
|
+
email: record.user_email,
|
49
|
+
validity: record.validity,
|
50
|
+
creation_date: record.creation_date,
|
51
|
+
expiration_date: record.expiration_date,
|
52
|
+
hash: record.user_id_hash,
|
53
|
+
origin: record.origin)
|
54
|
+
end
|
55
|
+
|
56
|
+
Key.new(
|
57
|
+
type: :public,
|
58
|
+
validity: public_key_record.validity,
|
59
|
+
length: public_key_record.key_length,
|
60
|
+
algorithm: public_key_record.key_algorithm,
|
61
|
+
id: public_key_record.key_id,
|
62
|
+
creation_date: public_key_record.creation_date,
|
63
|
+
owner_trust: public_key_record.owner_trust,
|
64
|
+
capabilities: public_key_record.key_capabilities,
|
65
|
+
compliance_modes: public_key_record.compliance_modes,
|
66
|
+
origin: public_key_record.origin,
|
67
|
+
fingerprint: fingerprint,
|
68
|
+
user_ids: user_ids)
|
69
|
+
end
|
20
70
|
end
|
21
71
|
|
22
72
|
def ==(other)
|
@@ -2,6 +2,8 @@ require 'date'
|
|
2
2
|
|
3
3
|
module RubyGPG2
|
4
4
|
class ColonRecord
|
5
|
+
USER_ID_REGEX = /^(.*?) (?:\((.*)\) )?<(.*)>$/
|
6
|
+
|
5
7
|
TYPES = {
|
6
8
|
'pub' => :public_key,
|
7
9
|
'crt' => :x509_certificate,
|
@@ -173,6 +175,32 @@ module RubyGPG2
|
|
173
175
|
@maximum_certificate_chain_depth = opts[:maximum_certificate_chain_depth]
|
174
176
|
end
|
175
177
|
|
178
|
+
def fingerprint_record?
|
179
|
+
type == :fingerprint
|
180
|
+
end
|
181
|
+
|
182
|
+
def user_id_record?
|
183
|
+
type == :user_id
|
184
|
+
end
|
185
|
+
|
186
|
+
def user_name
|
187
|
+
if (match = user_id&.match(USER_ID_REGEX))
|
188
|
+
match[1]
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def user_comment
|
193
|
+
if (match = user_id&.match(USER_ID_REGEX))
|
194
|
+
match[2]
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def user_email
|
199
|
+
if (match = user_id&.match(USER_ID_REGEX))
|
200
|
+
match[3]
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
176
204
|
def ==(other)
|
177
205
|
other.class == self.class && other.state == state
|
178
206
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module RubyGPG2
|
2
|
+
class Key
|
3
|
+
attr_reader(
|
4
|
+
:type,
|
5
|
+
:validity,
|
6
|
+
:length,
|
7
|
+
:algorithm,
|
8
|
+
:id,
|
9
|
+
:creation_date,
|
10
|
+
:owner_trust,
|
11
|
+
:capabilities,
|
12
|
+
:compliance_modes,
|
13
|
+
:origin,
|
14
|
+
:fingerprint,
|
15
|
+
:user_ids)
|
16
|
+
|
17
|
+
def initialize(opts)
|
18
|
+
@type = opts[:type]
|
19
|
+
@validity = opts[:validity]
|
20
|
+
@length = opts[:length]
|
21
|
+
@algorithm = opts[:algorithm]
|
22
|
+
@id = opts[:id]
|
23
|
+
@creation_date = opts[:creation_date]
|
24
|
+
@owner_trust = opts[:owner_trust]
|
25
|
+
@capabilities = opts[:capabilities]
|
26
|
+
@compliance_modes = opts[:compliance_modes]
|
27
|
+
@origin = opts[:origin]
|
28
|
+
@fingerprint = opts[:fingerprint]
|
29
|
+
@user_ids = opts[:user_ids]
|
30
|
+
end
|
31
|
+
|
32
|
+
def primary_user_id
|
33
|
+
@user_ids&.first
|
34
|
+
end
|
35
|
+
|
36
|
+
def ==(other)
|
37
|
+
other.class == self.class && other.state == state
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def state
|
43
|
+
[
|
44
|
+
@type,
|
45
|
+
@validity,
|
46
|
+
@length,
|
47
|
+
@algorithm,
|
48
|
+
@id,
|
49
|
+
@creation_date,
|
50
|
+
@owner_trust,
|
51
|
+
@capabilities,
|
52
|
+
@compliance_modes,
|
53
|
+
@origin,
|
54
|
+
@fingerprint
|
55
|
+
]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module RubyGPG2
|
2
|
+
class UserID
|
3
|
+
attr_reader(
|
4
|
+
:name,
|
5
|
+
:comment,
|
6
|
+
:email,
|
7
|
+
:validity,
|
8
|
+
:creation_date,
|
9
|
+
:expiration_date,
|
10
|
+
:hash,
|
11
|
+
:origin)
|
12
|
+
|
13
|
+
def initialize(opts)
|
14
|
+
@name = opts[:name]
|
15
|
+
@comment = opts[:comment]
|
16
|
+
@email = opts[:email]
|
17
|
+
@validity = opts[:validity]
|
18
|
+
@creation_date = opts[:creation_date]
|
19
|
+
@expiration_date = opts[:expiration_date]
|
20
|
+
@hash = opts[:hash]
|
21
|
+
@origin = opts[:origin]
|
22
|
+
end
|
23
|
+
|
24
|
+
def ==(other)
|
25
|
+
other.class == self.class && other.state == state
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def state
|
31
|
+
[
|
32
|
+
@name,
|
33
|
+
@comment,
|
34
|
+
@email,
|
35
|
+
@validity,
|
36
|
+
@creation_date,
|
37
|
+
@expiration_date,
|
38
|
+
@hash,
|
39
|
+
@origin
|
40
|
+
]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/ruby_gpg2/version.rb
CHANGED
data/lib/ruby_gpg2.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_gpg2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby Clemson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lino
|
@@ -170,7 +170,9 @@ files:
|
|
170
170
|
- lib/ruby_gpg2/commands/mixins/colon_config.rb
|
171
171
|
- lib/ruby_gpg2/commands/mixins/global_config.rb
|
172
172
|
- lib/ruby_gpg2/commands/mixins/with_captured_output.rb
|
173
|
+
- lib/ruby_gpg2/key.rb
|
173
174
|
- lib/ruby_gpg2/parameter_file.rb
|
175
|
+
- lib/ruby_gpg2/user_id.rb
|
174
176
|
- lib/ruby_gpg2/version.rb
|
175
177
|
- ruby_gpg2.gemspec
|
176
178
|
- scripts/ci/common/configure-git.sh
|