ruby_gpg2 0.1.0.pre.18 → 0.1.0.pre.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61184dcaf6b7deed870ea7fda333741513ace486b6e3562f826fd2f12131418a
4
- data.tar.gz: 71d66927a34b518b0ced1151a53dd7d7828e22992a9c7713b743dcb8b378866b
3
+ metadata.gz: df0b9ee2a84c8dd0c62d4144fd19f121bfd5fe224ab868ecdfc69c1defbc220f
4
+ data.tar.gz: 1cdb7985e466380912a53f7714c16a3561d91d28d2dbd2ca1a1738654b79c08f
5
5
  SHA512:
6
- metadata.gz: 27fa7119e8dc8c7ff42ed2c44cd94c5e3d3779535f429407d35b75edc85f89edcd9d68e23d7924cf62e788828c616168c0516dcc6bcfce21914cb28050f3ceba
7
- data.tar.gz: bd60c0893362ccc82f30961e452153d2549fbe705f290d16cee79076f2bd3cc0b6b4319010c56344d9626945aafa477c646fc054a1cc5c6175e40ca593ba910e
6
+ metadata.gz: 1bdb40b2d7e24886fc12d9327fc64cf54a1eb4960ebb2f6e4c80f5fc38aa03926bc9f52e3d64e11e4bc090c35a12cba369fefe85eb36f2b1b4118974202e035e
7
+ data.tar.gz: 30ff8200b4a908083eda056b9a803be9d1a8f6c179cb6f4b0693e96ce0faf7126f88a306900d4429de8867356719177d9e968056c8a9e138e5db72ccf333ef64
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_gpg2 (0.1.0.pre.18)
4
+ ruby_gpg2 (0.1.0.pre.19)
5
5
  lino (= 1.3.0)
6
6
 
7
7
  GEM
@@ -15,62 +15,13 @@ module RubyGPG2
15
15
  end
16
16
 
17
17
  def secret_keys
18
- []
18
+ group_by_type(:secret_key)
19
+ .map { |record_group| extract_key(:secret, record_group) }
19
20
  end
20
21
 
21
22
  def public_keys
22
- public_key_indices = @records
23
- .each_with_index
24
- .collect { |record, index|
25
- record.type == :public_key ? index : nil
26
- }
27
- .compact << @records.count
28
-
29
- public_key_record_groups = []
30
- public_key_indices.each_cons(2) do |index_pair|
31
- public_key_record_groups <<
32
- @records[index_pair[0]...index_pair[1]]
33
- end
34
-
35
- public_key_record_groups.map do |record_group|
36
- records_in_group = record_group.count
37
- public_key_record = record_group[0]
38
-
39
- fingerprint_record =
40
- (records_in_group > 1 && record_group[1].fingerprint_record?) ?
41
- record_group[1] :
42
- nil
43
- fingerprint = fingerprint_record&.fingerprint
44
-
45
- user_id_records = record_group
46
- .drop_while { |r| !r.user_id_record? }
47
- .take_while { |r| r.user_id_record? }
48
- user_ids = user_id_records.map do |record|
49
- UserID.new(
50
- name: record.user_name,
51
- comment: record.user_comment,
52
- email: record.user_email,
53
- validity: record.validity,
54
- creation_date: record.creation_date,
55
- expiration_date: record.expiration_date,
56
- hash: record.user_id_hash,
57
- origin: record.origin)
58
- end
59
-
60
- Key.new(
61
- type: :public,
62
- validity: public_key_record.validity,
63
- length: public_key_record.key_length,
64
- algorithm: public_key_record.key_algorithm,
65
- id: public_key_record.key_id,
66
- creation_date: public_key_record.creation_date,
67
- owner_trust: public_key_record.owner_trust,
68
- capabilities: public_key_record.key_capabilities,
69
- compliance_modes: public_key_record.compliance_modes,
70
- origin: public_key_record.origin,
71
- fingerprint: fingerprint,
72
- user_ids: user_ids)
73
- end
23
+ group_by_type(:public_key)
24
+ .map { |record_group| extract_key(:public, record_group) }
74
25
  end
75
26
 
76
27
  def ==(other)
@@ -82,5 +33,66 @@ module RubyGPG2
82
33
  def state
83
34
  [@records]
84
35
  end
36
+
37
+ private
38
+
39
+ def indices_by_type(type)
40
+ @records
41
+ .each_with_index
42
+ .collect { |record, index| record.type == type ? index : nil }
43
+ .compact
44
+ end
45
+
46
+ def group_by_type(type)
47
+ indices = indices_by_type(type)
48
+ indices << @records.count
49
+
50
+ groups = []
51
+ indices.each_cons(2) do |index_pair|
52
+ groups << @records[index_pair[0]...index_pair[1]]
53
+ end
54
+ groups
55
+ end
56
+
57
+ def extract_key(type, record_group)
58
+ records_in_group = record_group.count
59
+ key_record = record_group[0]
60
+
61
+ fingerprint_record =
62
+ (records_in_group > 1 && record_group[1].fingerprint_record?) ?
63
+ record_group[1] :
64
+ nil
65
+ fingerprint = fingerprint_record&.fingerprint
66
+
67
+ user_id_records = record_group
68
+ .drop_while { |r| !r.user_id_record? }
69
+ .take_while { |r| r.user_id_record? }
70
+ user_ids = user_id_records.map do |record|
71
+ UserID.new(
72
+ name: record.user_name,
73
+ comment: record.user_comment,
74
+ email: record.user_email,
75
+ validity: record.validity,
76
+ creation_date: record.creation_date,
77
+ expiration_date: record.expiration_date,
78
+ hash: record.user_id_hash,
79
+ origin: record.origin)
80
+ end
81
+
82
+ Key.new(
83
+ type: type,
84
+ validity: key_record.validity,
85
+ length: key_record.key_length,
86
+ algorithm: key_record.key_algorithm,
87
+ id: key_record.key_id,
88
+ creation_date: key_record.creation_date,
89
+ owner_trust: key_record.owner_trust,
90
+ capabilities: key_record.key_capabilities,
91
+ serial_number: key_record.serial_number,
92
+ compliance_modes: key_record.compliance_modes,
93
+ origin: key_record.origin,
94
+ fingerprint: fingerprint,
95
+ user_ids: user_ids)
96
+ end
85
97
  end
86
98
  end
data/lib/ruby_gpg2/key.rb CHANGED
@@ -9,6 +9,7 @@ module RubyGPG2
9
9
  :creation_date,
10
10
  :owner_trust,
11
11
  :capabilities,
12
+ :serial_number,
12
13
  :compliance_modes,
13
14
  :origin,
14
15
  :fingerprint,
@@ -23,6 +24,7 @@ module RubyGPG2
23
24
  @creation_date = opts[:creation_date]
24
25
  @owner_trust = opts[:owner_trust]
25
26
  @capabilities = opts[:capabilities]
27
+ @serial_number = opts[:serial_number]
26
28
  @compliance_modes = opts[:compliance_modes]
27
29
  @origin = opts[:origin]
28
30
  @fingerprint = opts[:fingerprint]
@@ -49,6 +51,7 @@ module RubyGPG2
49
51
  @creation_date,
50
52
  @owner_trust,
51
53
  @capabilities,
54
+ @serial_number,
52
55
  @compliance_modes,
53
56
  @origin,
54
57
  @fingerprint
@@ -1,3 +1,3 @@
1
1
  module RubyGPG2
2
- VERSION = '0.1.0.pre.18'
2
+ VERSION = '0.1.0.pre.19'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_gpg2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.18
4
+ version: 0.1.0.pre.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson