ruby_gpg2 0.9.0.pre.6 → 0.9.0.pre.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +37 -2
- data/Rakefile +83 -46
- data/bin/console +4 -3
- data/lib/ruby_gpg2/colon_output.rb +61 -42
- data/lib/ruby_gpg2/colon_record.rb +257 -222
- data/lib/ruby_gpg2/commands/base.rb +9 -13
- data/lib/ruby_gpg2/commands/decrypt.rb +3 -2
- data/lib/ruby_gpg2/commands/encrypt.rb +3 -2
- data/lib/ruby_gpg2/commands/export.rb +2 -0
- data/lib/ruby_gpg2/commands/export_secret_keys.rb +2 -0
- data/lib/ruby_gpg2/commands/generate_key.rb +5 -1
- data/lib/ruby_gpg2/commands/import.rb +2 -0
- data/lib/ruby_gpg2/commands/list_public_keys.rb +3 -2
- data/lib/ruby_gpg2/commands/list_secret_keys.rb +3 -2
- data/lib/ruby_gpg2/commands/mixins/armor_config.rb +2 -0
- data/lib/ruby_gpg2/commands/mixins/batch_config.rb +2 -0
- data/lib/ruby_gpg2/commands/mixins/colon_config.rb +2 -0
- data/lib/ruby_gpg2/commands/mixins/global_config.rb +7 -2
- data/lib/ruby_gpg2/commands/mixins/input_config.rb +2 -0
- data/lib/ruby_gpg2/commands/mixins/output_config.rb +7 -2
- data/lib/ruby_gpg2/commands/mixins/passphrase_config.rb +7 -2
- data/lib/ruby_gpg2/commands/mixins/pinentry_config.rb +7 -2
- data/lib/ruby_gpg2/commands/mixins/recipient_config.rb +7 -2
- data/lib/ruby_gpg2/commands/mixins/status_config.rb +7 -2
- data/lib/ruby_gpg2/commands/mixins/trust_mode_config.rb +7 -2
- data/lib/ruby_gpg2/commands/mixins/with_captured_output.rb +10 -5
- data/lib/ruby_gpg2/commands/mixins/with_captured_status.rb +11 -7
- data/lib/ruby_gpg2/commands/mixins/with_result.rb +2 -0
- data/lib/ruby_gpg2/commands/mixins/without_passphrase.rb +8 -3
- data/lib/ruby_gpg2/commands/result.rb +3 -3
- data/lib/ruby_gpg2/commands.rb +3 -2
- data/lib/ruby_gpg2/key.rb +34 -25
- data/lib/ruby_gpg2/parameter_file_contents.rb +101 -51
- data/lib/ruby_gpg2/status_line.rb +15 -12
- data/lib/ruby_gpg2/status_lines/import_ok.rb +29 -25
- data/lib/ruby_gpg2/status_lines/import_problem.rb +19 -15
- data/lib/ruby_gpg2/status_lines/imported.rb +13 -9
- data/lib/ruby_gpg2/status_lines/key_considered.rb +18 -14
- data/lib/ruby_gpg2/status_lines/key_created.rb +20 -16
- data/lib/ruby_gpg2/status_lines/unimplemented.rb +6 -3
- data/lib/ruby_gpg2/status_lines.rb +2 -1
- data/lib/ruby_gpg2/status_output.rb +2 -0
- data/lib/ruby_gpg2/user_id.rb +19 -16
- data/lib/ruby_gpg2/version.rb +3 -1
- data/lib/ruby_gpg2.rb +2 -0
- data/ruby_gpg2.gemspec +55 -0
- metadata +64 -6
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'lino'
|
2
4
|
|
3
5
|
require_relative 'base'
|
@@ -16,8 +18,7 @@ module RubyGPG2
|
|
16
18
|
|
17
19
|
def configure_command(builder, opts)
|
18
20
|
builder = builder.with_subcommand('--list-public-keys')
|
19
|
-
|
20
|
-
builder
|
21
|
+
super(builder, opts)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'lino'
|
2
4
|
|
3
5
|
require_relative 'base'
|
@@ -16,8 +18,7 @@ module RubyGPG2
|
|
16
18
|
|
17
19
|
def configure_command(builder, opts)
|
18
20
|
builder = builder.with_subcommand('--list-secret-keys')
|
19
|
-
|
20
|
-
builder
|
21
|
+
super(builder, opts)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyGPG2
|
2
4
|
module Commands
|
3
5
|
module Mixins
|
@@ -7,8 +9,11 @@ module RubyGPG2
|
|
7
9
|
without_tty = opts[:without_tty].nil? ? true : opts[:without_tty]
|
8
10
|
|
9
11
|
builder = super(builder, opts)
|
10
|
-
|
11
|
-
|
12
|
+
if home_directory
|
13
|
+
builder = builder.with_option(
|
14
|
+
'--homedir', home_directory, quoting: '"'
|
15
|
+
)
|
16
|
+
end
|
12
17
|
builder = builder.with_flag('--no-tty') if without_tty
|
13
18
|
builder
|
14
19
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyGPG2
|
2
4
|
module Commands
|
3
5
|
module Mixins
|
@@ -6,8 +8,11 @@ module RubyGPG2
|
|
6
8
|
output_file_path = opts[:output_file_path]
|
7
9
|
|
8
10
|
builder = super(builder, opts)
|
9
|
-
|
10
|
-
|
11
|
+
if output_file_path
|
12
|
+
builder = builder.with_option(
|
13
|
+
'--output', output_file_path, quoting: '"'
|
14
|
+
)
|
15
|
+
end
|
11
16
|
builder
|
12
17
|
end
|
13
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyGPG2
|
2
4
|
module Commands
|
3
5
|
module Mixins
|
@@ -6,8 +8,11 @@ module RubyGPG2
|
|
6
8
|
passphrase = opts[:passphrase]
|
7
9
|
|
8
10
|
builder = super(builder, opts)
|
9
|
-
|
10
|
-
|
11
|
+
if passphrase
|
12
|
+
builder = builder.with_option(
|
13
|
+
'--passphrase', passphrase, quoting: '"'
|
14
|
+
)
|
15
|
+
end
|
11
16
|
builder
|
12
17
|
end
|
13
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyGPG2
|
2
4
|
module Commands
|
3
5
|
module Mixins
|
@@ -6,8 +8,11 @@ module RubyGPG2
|
|
6
8
|
pinentry_mode = opts[:pinentry_mode]
|
7
9
|
|
8
10
|
builder = super(builder, opts)
|
9
|
-
|
10
|
-
|
11
|
+
if pinentry_mode
|
12
|
+
builder = builder.with_option(
|
13
|
+
'--pinentry-mode', pinentry_mode
|
14
|
+
)
|
15
|
+
end
|
11
16
|
builder
|
12
17
|
end
|
13
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyGPG2
|
2
4
|
module Commands
|
3
5
|
module Mixins
|
@@ -6,8 +8,11 @@ module RubyGPG2
|
|
6
8
|
recipient = opts[:recipient]
|
7
9
|
|
8
10
|
builder = super(builder, opts)
|
9
|
-
|
10
|
-
|
11
|
+
if recipient
|
12
|
+
builder = builder.with_option(
|
13
|
+
'--recipient', recipient
|
14
|
+
)
|
15
|
+
end
|
11
16
|
builder
|
12
17
|
end
|
13
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyGPG2
|
2
4
|
module Commands
|
3
5
|
module Mixins
|
@@ -6,8 +8,11 @@ module RubyGPG2
|
|
6
8
|
status_file = opts[:status_file]
|
7
9
|
|
8
10
|
builder = super(builder, opts)
|
9
|
-
|
10
|
-
|
11
|
+
if status_file
|
12
|
+
builder = builder.with_option(
|
13
|
+
'--status-file', status_file, quoting: '"'
|
14
|
+
)
|
15
|
+
end
|
11
16
|
builder
|
12
17
|
end
|
13
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyGPG2
|
2
4
|
module Commands
|
3
5
|
module Mixins
|
@@ -6,8 +8,11 @@ module RubyGPG2
|
|
6
8
|
trust_mode = opts[:trust_mode]
|
7
9
|
|
8
10
|
builder = super(builder, opts)
|
9
|
-
|
10
|
-
|
11
|
+
if trust_mode
|
12
|
+
builder = builder.with_option(
|
13
|
+
'--trust-mode', trust_mode
|
14
|
+
)
|
15
|
+
end
|
11
16
|
builder
|
12
17
|
end
|
13
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'stringio'
|
2
4
|
|
3
5
|
module RubyGPG2
|
@@ -7,15 +9,18 @@ module RubyGPG2
|
|
7
9
|
def initialize(*args)
|
8
10
|
super(*args)
|
9
11
|
@stdout = StringIO.new unless
|
10
|
-
|
12
|
+
defined?(@stdout) && @stdout.respond_to?(:string)
|
11
13
|
end
|
12
14
|
|
13
15
|
def do_after(opts)
|
16
|
+
super(opts.merge(output: resolve_output(stdout.string, opts)))
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def resolve_output(output, opts)
|
14
22
|
parse_output = opts[:parse_output].nil? ? true : opts[:parse_output]
|
15
|
-
|
16
|
-
output: parse_output ?
|
17
|
-
ColonOutput.parse(stdout.string) :
|
18
|
-
stdout.string))
|
23
|
+
parse_output ? ColonOutput.parse(output) : output
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'tempfile'
|
2
4
|
|
3
5
|
require_relative '../../status_output'
|
@@ -8,8 +10,7 @@ module RubyGPG2
|
|
8
10
|
module WithCapturedStatus
|
9
11
|
def do_around(opts)
|
10
12
|
if opts[:with_status]
|
11
|
-
Tempfile.create(
|
12
|
-
'status-file', opts[:work_directory]) do |f|
|
13
|
+
Tempfile.create('status-file', opts[:work_directory]) do |f|
|
13
14
|
yield opts.merge(status_file: f.path)
|
14
15
|
@status = File.read(f.path)
|
15
16
|
end
|
@@ -19,16 +20,19 @@ module RubyGPG2
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def do_after(opts)
|
22
|
-
parse_status = opts[:parse_status].nil? ? true : opts[:parse_status]
|
23
23
|
if opts[:with_status]
|
24
|
-
super(opts.merge(
|
25
|
-
status: parse_status ?
|
26
|
-
StatusOutput.parse(@status) :
|
27
|
-
@status))
|
24
|
+
super(opts.merge(status: resolve_status(@status, opts)))
|
28
25
|
else
|
29
26
|
super(opts)
|
30
27
|
end
|
31
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def resolve_status(status, opts)
|
33
|
+
parse_status = opts[:parse_status].nil? ? true : opts[:parse_status]
|
34
|
+
parse_status ? StatusOutput.parse(status) : status
|
35
|
+
end
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
@@ -1,12 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyGPG2
|
2
4
|
module Commands
|
3
5
|
module Mixins
|
4
6
|
module WithoutPassphrase
|
5
7
|
def configure_command(builder, opts)
|
6
8
|
without_passphrase = opts[:without_passphrase]
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
opts = if without_passphrase
|
10
|
+
opts.merge(passphrase: '', pinentry_mode: :loopback)
|
11
|
+
else
|
12
|
+
opts
|
13
|
+
end
|
14
|
+
super(builder, opts)
|
10
15
|
end
|
11
16
|
end
|
12
17
|
end
|
data/lib/ruby_gpg2/commands.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'commands/decrypt'
|
2
4
|
require_relative 'commands/encrypt'
|
3
5
|
require_relative 'commands/export'
|
@@ -9,6 +11,5 @@ require_relative 'commands/list_secret_keys'
|
|
9
11
|
|
10
12
|
module RubyGPG2
|
11
13
|
module Commands
|
12
|
-
|
13
14
|
end
|
14
|
-
end
|
15
|
+
end
|
data/lib/ruby_gpg2/key.rb
CHANGED
@@ -1,20 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RubyGPG2
|
2
4
|
class Key
|
3
5
|
attr_reader(
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
:type,
|
7
|
+
:validity,
|
8
|
+
:length,
|
9
|
+
:algorithm,
|
10
|
+
:id,
|
11
|
+
:creation_date,
|
12
|
+
:owner_trust,
|
13
|
+
:capabilities,
|
14
|
+
:serial_number,
|
15
|
+
:compliance_modes,
|
16
|
+
:origin,
|
17
|
+
:fingerprint,
|
18
|
+
:user_ids
|
19
|
+
)
|
17
20
|
|
21
|
+
# rubocop:disable Metrics/MethodLength
|
22
|
+
# rubocop:disable Metrics/AbcSize
|
18
23
|
def initialize(opts)
|
19
24
|
@type = opts[:type]
|
20
25
|
@validity = opts[:validity]
|
@@ -30,6 +35,8 @@ module RubyGPG2
|
|
30
35
|
@fingerprint = opts[:fingerprint]
|
31
36
|
@user_ids = opts[:user_ids]
|
32
37
|
end
|
38
|
+
# rubocop:enable Metrics/AbcSize
|
39
|
+
# rubocop:enable Metrics/MethodLength
|
33
40
|
|
34
41
|
def primary_user_id
|
35
42
|
@user_ids&.first
|
@@ -41,21 +48,23 @@ module RubyGPG2
|
|
41
48
|
|
42
49
|
protected
|
43
50
|
|
51
|
+
# rubocop:disable Metrics/MethodLength
|
44
52
|
def state
|
45
53
|
[
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
54
|
+
@type,
|
55
|
+
@validity,
|
56
|
+
@length,
|
57
|
+
@algorithm,
|
58
|
+
@id,
|
59
|
+
@creation_date,
|
60
|
+
@owner_trust,
|
61
|
+
@capabilities,
|
62
|
+
@serial_number,
|
63
|
+
@compliance_modes,
|
64
|
+
@origin,
|
65
|
+
@fingerprint
|
58
66
|
]
|
59
67
|
end
|
68
|
+
# rubocop:enable Metrics/MethodLength
|
60
69
|
end
|
61
70
|
end
|
@@ -1,53 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'tempfile'
|
2
4
|
|
3
5
|
module RubyGPG2
|
4
6
|
class ParameterFileContents
|
5
7
|
attr_reader(
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
:key_type,
|
9
|
+
:key_length,
|
10
|
+
:subkey_type,
|
11
|
+
:subkey_length,
|
12
|
+
:owner_name,
|
13
|
+
:owner_email,
|
14
|
+
:owner_comment,
|
15
|
+
:expiry,
|
16
|
+
:passphrase
|
17
|
+
)
|
15
18
|
|
16
19
|
def initialize(opts)
|
17
|
-
@key_type = opts
|
18
|
-
@key_length = opts
|
19
|
-
|
20
|
-
@
|
21
|
-
@
|
22
|
-
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
26
|
-
@expiry = opts.fetch(:expiry, :never)
|
27
|
-
@passphrase = opts.fetch(:passphrase, nil)
|
20
|
+
@key_type = resolve_key_type(opts)
|
21
|
+
@key_length = resolve_key_length(opts, @key_type)
|
22
|
+
@subkey_type = resolve_subkey_type(opts)
|
23
|
+
@subkey_length = resolve_subkey_length(opts, @subkey_type)
|
24
|
+
@owner_name = resolve_owner_name(opts)
|
25
|
+
@owner_email = resolve_owner_email(opts)
|
26
|
+
@owner_comment = resolve_owner_comment(opts)
|
27
|
+
@expiry = resolve_expiry(opts)
|
28
|
+
@passphrase = resolve_passphrase(opts)
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
].count(false)
|
35
|
-
missing_names = [
|
36
|
-
owner_name_present ? nil : :owner_name,
|
37
|
-
owner_email_present ? nil : :owner_email
|
38
|
-
].compact
|
39
|
-
|
40
|
-
unless missing_count == 0
|
41
|
-
raise RuntimeError.new(
|
42
|
-
"Missing required parameter#{missing_count > 1 ? 's' : ''}: " +
|
43
|
-
"#{missing_names}.")
|
44
|
-
end
|
30
|
+
assert_required_parameters_present
|
31
|
+
end
|
32
|
+
|
33
|
+
def expiry_date
|
34
|
+
expiry == :never ? 0 : expiry
|
45
35
|
end
|
46
36
|
|
47
37
|
def write_to(path)
|
48
|
-
File.open(path, 'w')
|
49
|
-
f.write(to_s)
|
50
|
-
end
|
38
|
+
File.open(path, 'w') { |f| f.write(to_s) }
|
51
39
|
end
|
52
40
|
|
53
41
|
def in_temp_file(tmpdir = nil)
|
@@ -59,22 +47,84 @@ module RubyGPG2
|
|
59
47
|
end
|
60
48
|
|
61
49
|
def to_s
|
62
|
-
|
63
|
-
parm("Key-Type", key_type),
|
64
|
-
parm("Key-Length", key_length),
|
65
|
-
parm("Subkey-Type", subkey_type),
|
66
|
-
parm('Subkey-Length', subkey_length),
|
67
|
-
parm('Name-Real', owner_name),
|
68
|
-
parm('Name-Comment', owner_comment),
|
69
|
-
parm('Name-Email', owner_email),
|
70
|
-
parm('Expire-Date',
|
71
|
-
expiry == :never ? 0 : expiry),
|
72
|
-
parm('Passphrase', passphrase),
|
73
|
-
].compact.join("\n") + "\n"
|
50
|
+
"#{to_parms.compact.join("\n")}\n"
|
74
51
|
end
|
75
52
|
|
76
53
|
private
|
77
54
|
|
55
|
+
def assert_required_parameters_present
|
56
|
+
owner_name_present = !@owner_name.nil?
|
57
|
+
owner_email_present = !@owner_email.nil?
|
58
|
+
missing_count = [owner_name_present, owner_email_present].count(false)
|
59
|
+
missing_names =
|
60
|
+
[to_error_code(owner_name_present, :owner_name),
|
61
|
+
to_error_code(owner_email_present, :owner_email)].compact
|
62
|
+
|
63
|
+
return if missing_count.zero?
|
64
|
+
|
65
|
+
raise "Missing required parameter#{missing_count > 1 ? 's' : ''}: " \
|
66
|
+
"#{missing_names}."
|
67
|
+
end
|
68
|
+
|
69
|
+
def to_error_code(present, code)
|
70
|
+
present ? nil : code
|
71
|
+
end
|
72
|
+
|
73
|
+
def resolve_key_type(opts)
|
74
|
+
opts.fetch(:key_type, 'RSA')
|
75
|
+
end
|
76
|
+
|
77
|
+
def resolve_key_length(opts, key_type)
|
78
|
+
opts.fetch(
|
79
|
+
:key_length, (key_type.to_s == 'default' ? nil : 2048)
|
80
|
+
)
|
81
|
+
end
|
82
|
+
|
83
|
+
def resolve_subkey_type(opts)
|
84
|
+
opts.fetch(:subkey_type, 'RSA')
|
85
|
+
end
|
86
|
+
|
87
|
+
def resolve_subkey_length(opts, subkey_type)
|
88
|
+
opts.fetch(
|
89
|
+
:subkey_length,
|
90
|
+
(subkey_type.nil? || subkey_type.to_s == 'default' ? nil : 2048)
|
91
|
+
)
|
92
|
+
end
|
93
|
+
|
94
|
+
def resolve_owner_name(opts)
|
95
|
+
opts.fetch(:owner_name, nil)
|
96
|
+
end
|
97
|
+
|
98
|
+
def resolve_owner_email(opts)
|
99
|
+
opts.fetch(:owner_email, nil)
|
100
|
+
end
|
101
|
+
|
102
|
+
def resolve_owner_comment(opts)
|
103
|
+
opts.fetch(:owner_comment, nil)
|
104
|
+
end
|
105
|
+
|
106
|
+
def resolve_expiry(opts)
|
107
|
+
opts.fetch(:expiry, :never)
|
108
|
+
end
|
109
|
+
|
110
|
+
def resolve_passphrase(opts)
|
111
|
+
opts.fetch(:passphrase, nil)
|
112
|
+
end
|
113
|
+
|
114
|
+
# rubocop:disable Metrics/AbcSize
|
115
|
+
def to_parms
|
116
|
+
[parm('Key-Type', key_type),
|
117
|
+
parm('Key-Length', key_length),
|
118
|
+
parm('Subkey-Type', subkey_type),
|
119
|
+
parm('Subkey-Length', subkey_length),
|
120
|
+
parm('Name-Real', owner_name),
|
121
|
+
parm('Name-Comment', owner_comment),
|
122
|
+
parm('Name-Email', owner_email),
|
123
|
+
parm('Expire-Date', expiry_date),
|
124
|
+
parm('Passphrase', passphrase)]
|
125
|
+
end
|
126
|
+
# rubocop:enable Metrics/AbcSize
|
127
|
+
|
78
128
|
def parm(name, value)
|
79
129
|
value ? "#{name}: #{value}" : nil
|
80
130
|
end
|
@@ -1,23 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'status_lines'
|
2
4
|
|
3
5
|
module RubyGPG2
|
4
6
|
class StatusLine
|
5
|
-
TYPE_REGEX = /^\[GNUPG:\] (.*?)(\s|$)
|
7
|
+
TYPE_REGEX = /^\[GNUPG:\] (.*?)(\s|$)/.freeze
|
6
8
|
|
7
9
|
TYPES = {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
}
|
10
|
+
'IMPORT_OK' => StatusLines::ImportOK,
|
11
|
+
'IMPORT_PROBLEM' => StatusLines::ImportProblem,
|
12
|
+
'IMPORTED' => StatusLines::Imported,
|
13
|
+
'KEY_CREATED' => StatusLines::KeyCreated,
|
14
|
+
'KEY_CONSIDERED' => StatusLines::KeyConsidered
|
15
|
+
}.freeze
|
14
16
|
|
15
17
|
def self.parse(line)
|
16
18
|
TYPES
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
.fetch(
|
20
|
+
line.match(TYPE_REGEX)[1],
|
21
|
+
StatusLines::Unimplemented
|
22
|
+
)
|
23
|
+
.parse(line)
|
21
24
|
end
|
22
25
|
end
|
23
|
-
end
|
26
|
+
end
|