ruby_gpg2 0.11.0.pre.4 → 0.11.0.pre.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -7
- data/lib/ruby_gpg2/colon_output.rb +3 -3
- data/lib/ruby_gpg2/colon_record.rb +3 -3
- data/lib/ruby_gpg2/commands/base.rb +91 -23
- data/lib/ruby_gpg2/commands/decrypt.rb +2 -2
- data/lib/ruby_gpg2/commands/encrypt.rb +2 -2
- data/lib/ruby_gpg2/commands/export.rb +3 -3
- data/lib/ruby_gpg2/commands/export_secret_keys.rb +3 -3
- data/lib/ruby_gpg2/commands/generate_key.rb +3 -5
- data/lib/ruby_gpg2/commands/import.rb +3 -5
- data/lib/ruby_gpg2/commands/list_public_keys.rb +2 -4
- data/lib/ruby_gpg2/commands/list_secret_keys.rb +2 -4
- data/lib/ruby_gpg2/commands/mixins/armor_config.rb +5 -3
- data/lib/ruby_gpg2/commands/mixins/batch_config.rb +10 -3
- data/lib/ruby_gpg2/commands/mixins/colon_config.rb +10 -3
- data/lib/ruby_gpg2/commands/mixins/global_config.rb +11 -4
- data/lib/ruby_gpg2/commands/mixins/input_config.rb +5 -3
- data/lib/ruby_gpg2/commands/mixins/output_config.rb +5 -3
- data/lib/ruby_gpg2/commands/mixins/passphrase_config.rb +5 -3
- data/lib/ruby_gpg2/commands/mixins/pinentry_config.rb +5 -3
- data/lib/ruby_gpg2/commands/mixins/recipient_config.rb +5 -3
- data/lib/ruby_gpg2/commands/mixins/status_config.rb +5 -3
- data/lib/ruby_gpg2/commands/mixins/trust_mode_config.rb +5 -3
- data/lib/ruby_gpg2/commands/mixins/with_captured_output.rb +14 -11
- data/lib/ruby_gpg2/commands/mixins/with_captured_status.rb +22 -15
- data/lib/ruby_gpg2/commands/mixins/without_passphrase.rb +5 -5
- data/lib/ruby_gpg2/commands/result.rb +1 -1
- data/lib/ruby_gpg2/status_line.rb +1 -1
- data/lib/ruby_gpg2/version.rb +1 -1
- data/lib/ruby_gpg2.rb +1 -1
- data/ruby_gpg2.gemspec +2 -2
- metadata +8 -9
- data/lib/ruby_gpg2/commands/mixins/with_result.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c27de5d22cf3041ceb816286e96aacfa9bb9d645c8d17dad6f8320f316cc668b
|
4
|
+
data.tar.gz: 34240663967448aa6405be530bef5b64cddf649a1782bcaeab5a96666bf54032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 882dcf36deceef20058a336045cbab36d47780d968ef7a35cdf03233e97b5e7e300050aa87be6a4ec251185721688a6887e38cc03fecebebcebf1d1a88010a77
|
7
|
+
data.tar.gz: 26df8353e6c0df19f0cedd7e4793eaa4977fc9e54bdb0ae9b2037f3cb2798a12ec226f8c49d7d2934340dc34f0a49fc7b14f6c3579372d470883d6317dc4c11d
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
ruby_gpg2 (0.11.0.pre.
|
5
|
-
lino (
|
4
|
+
ruby_gpg2 (0.11.0.pre.5)
|
5
|
+
lino (= 3.2.0.pre.10)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
@@ -22,6 +22,7 @@ GEM
|
|
22
22
|
ast (2.4.2)
|
23
23
|
base64 (0.1.1)
|
24
24
|
bigdecimal (3.1.4)
|
25
|
+
childprocess (5.0.0)
|
25
26
|
colored2 (3.1.2)
|
26
27
|
concurrent-ruby (1.2.2)
|
27
28
|
connection_pool (2.4.1)
|
@@ -44,9 +45,10 @@ GEM
|
|
44
45
|
i18n (1.14.1)
|
45
46
|
concurrent-ruby (~> 1.0)
|
46
47
|
immutable-struct (2.4.1)
|
47
|
-
json (2.
|
48
|
+
json (2.7.1)
|
48
49
|
language_server-protocol (3.17.0.3)
|
49
|
-
lino (3.
|
50
|
+
lino (3.2.0.pre.10)
|
51
|
+
childprocess (~> 5.0.0)
|
50
52
|
hamster (~> 3.0)
|
51
53
|
open4 (~> 1.3)
|
52
54
|
minitest (5.20.0)
|
@@ -93,7 +95,7 @@ GEM
|
|
93
95
|
rake_factory (~> 0.23)
|
94
96
|
sshkey (~> 2.0)
|
95
97
|
rchardet (1.8.0)
|
96
|
-
regexp_parser (2.8.
|
98
|
+
regexp_parser (2.8.3)
|
97
99
|
rexml (3.2.6)
|
98
100
|
rspec (3.12.0)
|
99
101
|
rspec-core (~> 3.12.0)
|
@@ -108,7 +110,7 @@ GEM
|
|
108
110
|
diff-lcs (>= 1.2.0, < 2.0)
|
109
111
|
rspec-support (~> 3.12.0)
|
110
112
|
rspec-support (3.12.1)
|
111
|
-
rubocop (1.
|
113
|
+
rubocop (1.59.0)
|
112
114
|
json (~> 2.3)
|
113
115
|
language_server-protocol (>= 3.17.0)
|
114
116
|
parallel (~> 1.10)
|
@@ -116,7 +118,7 @@ GEM
|
|
116
118
|
rainbow (>= 2.2.2, < 4.0)
|
117
119
|
regexp_parser (>= 1.8, < 3.0)
|
118
120
|
rexml (>= 3.2.5, < 4.0)
|
119
|
-
rubocop-ast (>= 1.
|
121
|
+
rubocop-ast (>= 1.30.0, < 2.0)
|
120
122
|
ruby-progressbar (~> 1.7)
|
121
123
|
unicode-display_width (>= 2.4.0, < 3.0)
|
122
124
|
rubocop-ast (1.30.0)
|
@@ -97,7 +97,7 @@ module RubyGPG2
|
|
97
97
|
# rubocop:disable Metrics/MethodLength
|
98
98
|
def make_key(type, key_record, fingerprint, user_ids)
|
99
99
|
Key.new(
|
100
|
-
type
|
100
|
+
type:,
|
101
101
|
validity: key_record.validity,
|
102
102
|
length: key_record.key_length,
|
103
103
|
algorithm: key_record.key_algorithm,
|
@@ -108,8 +108,8 @@ module RubyGPG2
|
|
108
108
|
serial_number: key_record.serial_number,
|
109
109
|
compliance_modes: key_record.compliance_modes,
|
110
110
|
origin: key_record.origin,
|
111
|
-
fingerprint
|
112
|
-
user_ids:
|
111
|
+
fingerprint:,
|
112
|
+
user_ids:
|
113
113
|
)
|
114
114
|
end
|
115
115
|
# rubocop:enable Metrics/MethodLength
|
@@ -5,7 +5,7 @@ require 'date'
|
|
5
5
|
module RubyGPG2
|
6
6
|
# rubocop:disable Metrics/ClassLength
|
7
7
|
class ColonRecord
|
8
|
-
USER_ID_REGEX = /^(.*?) (?:\((.*)\) )?<(.*)
|
8
|
+
USER_ID_REGEX = /^(.*?) (?:\((.*)\) )?<(.*)>$/
|
9
9
|
|
10
10
|
TYPES = {
|
11
11
|
'pub' => :public_key,
|
@@ -225,7 +225,7 @@ module RubyGPG2
|
|
225
225
|
def make_standard_record(record, type, fields)
|
226
226
|
new(
|
227
227
|
raw: record,
|
228
|
-
type
|
228
|
+
type:,
|
229
229
|
validity: validity(fields[1]),
|
230
230
|
key_length: key_length(fields[2]),
|
231
231
|
key_algorithm: key_algorithm(fields[3]),
|
@@ -252,7 +252,7 @@ module RubyGPG2
|
|
252
252
|
def make_trust_base_record(record, type, fields)
|
253
253
|
new(
|
254
254
|
raw: record,
|
255
|
-
type
|
255
|
+
type:,
|
256
256
|
trust_model: trust_model(fields[2]),
|
257
257
|
creation_date: creation_date(fields[3]),
|
258
258
|
expiration_date: expiration_date(fields[4]),
|
@@ -1,51 +1,119 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'lino'
|
4
|
+
require 'tempfile'
|
4
5
|
|
5
6
|
require_relative 'result'
|
6
7
|
|
7
8
|
module RubyGPG2
|
8
9
|
module Commands
|
9
10
|
class Base
|
10
|
-
def initialize(
|
11
|
-
@binary = binary || RubyGPG2.configuration.binary
|
12
|
-
@stdin = stdin || RubyGPG2.configuration.stdin
|
13
|
-
@stdout = stdout || RubyGPG2.configuration.stdout
|
14
|
-
@stderr = stderr || RubyGPG2.configuration.stderr
|
15
|
-
end
|
16
|
-
|
17
|
-
def execute(
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
11
|
+
def initialize(opts = {})
|
12
|
+
@binary = opts[:binary] || RubyGPG2.configuration.binary
|
13
|
+
@stdin = opts[:stdin] || RubyGPG2.configuration.stdin
|
14
|
+
@stdout = opts[:stdout] || RubyGPG2.configuration.stdout
|
15
|
+
@stderr = opts[:stderr] || RubyGPG2.configuration.stderr
|
16
|
+
end
|
17
|
+
|
18
|
+
def execute(parameters = {}, invocation_options = {})
|
19
|
+
parameters = resolve_parameters(parameters)
|
20
|
+
invocation_options = resolve_invocation_options(invocation_options)
|
21
|
+
|
22
|
+
do_before(parameters, invocation_options)
|
23
|
+
result = do_around(parameters, invocation_options) do |p, io|
|
24
|
+
build_and_execute_command(p, io)
|
24
25
|
end
|
25
|
-
do_after(
|
26
|
+
result = do_after(result, parameters, invocation_options)
|
27
|
+
prepare_result(result, parameters, invocation_options)
|
26
28
|
end
|
27
29
|
|
28
|
-
|
30
|
+
private
|
29
31
|
|
30
32
|
attr_reader :binary, :stdin, :stdout, :stderr
|
31
33
|
|
34
|
+
def do_before(parameters, invocation_options); end
|
35
|
+
|
36
|
+
def do_around(parameters, invocation_options)
|
37
|
+
yield parameters, invocation_options
|
38
|
+
end
|
39
|
+
|
40
|
+
def do_after(result, _parameters, _invocation_options)
|
41
|
+
result
|
42
|
+
end
|
43
|
+
|
44
|
+
def build_and_execute_command(parameters, invocation_options)
|
45
|
+
command = configure_command(instantiate_builder, parameters).build
|
46
|
+
stdout = resolve_stdout(invocation_options)
|
47
|
+
stderr = resolve_stderr(invocation_options)
|
48
|
+
|
49
|
+
command.execute(stdin:, stdout:, stderr:)
|
50
|
+
|
51
|
+
process_streams(invocation_options, stdout, stderr)
|
52
|
+
end
|
53
|
+
|
32
54
|
def instantiate_builder
|
33
55
|
Lino::CommandLineBuilder
|
34
56
|
.for_command(binary)
|
35
57
|
end
|
36
58
|
|
37
|
-
def
|
38
|
-
|
39
|
-
def configure_command(builder, _opts)
|
59
|
+
def configure_command(builder, _parameters)
|
40
60
|
builder
|
41
61
|
end
|
42
62
|
|
43
|
-
def
|
44
|
-
|
63
|
+
def process_result(result, _parameters, _invocation_options)
|
64
|
+
result
|
65
|
+
end
|
66
|
+
|
67
|
+
def parameter_defaults(_parameters)
|
68
|
+
{}
|
69
|
+
end
|
70
|
+
|
71
|
+
def parameter_overrides(_parameters)
|
72
|
+
{}
|
45
73
|
end
|
46
74
|
|
47
|
-
def
|
48
|
-
|
75
|
+
def invocation_option_defaults(_invocation_options)
|
76
|
+
{ capture: [], result: :processed }
|
77
|
+
end
|
78
|
+
|
79
|
+
def resolve_parameters(parameters)
|
80
|
+
parameter_defaults(parameters)
|
81
|
+
.merge(parameters)
|
82
|
+
.merge(parameter_overrides(parameters))
|
83
|
+
end
|
84
|
+
|
85
|
+
def resolve_invocation_options(invocation_options)
|
86
|
+
invocation_option_defaults(invocation_options)
|
87
|
+
.merge(invocation_options)
|
88
|
+
end
|
89
|
+
|
90
|
+
def resolve_stdout(invocation_options)
|
91
|
+
invocation_options[:capture].include?(:stdout) ? Tempfile.new : @stdout
|
92
|
+
end
|
93
|
+
|
94
|
+
def resolve_stderr(invocation_options)
|
95
|
+
invocation_options[:capture].include?(:stderr) ? Tempfile.new : @stderr
|
96
|
+
end
|
97
|
+
|
98
|
+
def process_streams(invocation_options, stdout, stderr)
|
99
|
+
cap = invocation_options[:capture]
|
100
|
+
result = Result.new
|
101
|
+
add_contents_to_result(cap, result, :stdout, stdout, :output)
|
102
|
+
add_contents_to_result(cap, result, :stderr, stderr, :error)
|
103
|
+
result
|
104
|
+
end
|
105
|
+
|
106
|
+
def add_contents_to_result(capture, result, stream_name, stream, type)
|
107
|
+
return unless capture.include?(stream_name)
|
108
|
+
|
109
|
+
stream.rewind
|
110
|
+
result.send("#{type}=", stream.read)
|
111
|
+
end
|
112
|
+
|
113
|
+
def prepare_result(result, parameters, invocation_options)
|
114
|
+
return result if invocation_options[:result] == :raw
|
115
|
+
|
116
|
+
process_result(result, parameters, invocation_options)
|
49
117
|
end
|
50
118
|
end
|
51
119
|
end
|
@@ -24,8 +24,8 @@ module RubyGPG2
|
|
24
24
|
include Mixins::PinentryConfig
|
25
25
|
include Mixins::WithoutPassphrase
|
26
26
|
|
27
|
-
def configure_command(builder,
|
28
|
-
builder = super(builder,
|
27
|
+
def configure_command(builder, parameters)
|
28
|
+
builder = super(builder, parameters)
|
29
29
|
builder.with_subcommand('--decrypt')
|
30
30
|
end
|
31
31
|
end
|
@@ -22,8 +22,8 @@ module RubyGPG2
|
|
22
22
|
include Mixins::RecipientConfig
|
23
23
|
include Mixins::TrustModeConfig
|
24
24
|
|
25
|
-
def configure_command(builder,
|
26
|
-
builder = super(builder,
|
25
|
+
def configure_command(builder, parameters)
|
26
|
+
builder = super(builder, parameters)
|
27
27
|
builder.with_subcommand('--encrypt')
|
28
28
|
end
|
29
29
|
end
|
@@ -14,10 +14,10 @@ module RubyGPG2
|
|
14
14
|
include Mixins::ArmorConfig
|
15
15
|
include Mixins::OutputConfig
|
16
16
|
|
17
|
-
def configure_command(builder,
|
18
|
-
names =
|
17
|
+
def configure_command(builder, parameters)
|
18
|
+
names = parameters[:names] || []
|
19
19
|
|
20
|
-
builder = super(builder,
|
20
|
+
builder = super(builder, parameters)
|
21
21
|
builder = builder.with_subcommand('--export')
|
22
22
|
names.each do |name|
|
23
23
|
builder = builder.with_argument(name)
|
@@ -22,10 +22,10 @@ module RubyGPG2
|
|
22
22
|
include Mixins::OutputConfig
|
23
23
|
include Mixins::WithoutPassphrase
|
24
24
|
|
25
|
-
def configure_command(builder,
|
26
|
-
names =
|
25
|
+
def configure_command(builder, parameters)
|
26
|
+
names = parameters[:names] || []
|
27
27
|
|
28
|
-
builder = super(builder,
|
28
|
+
builder = super(builder, parameters)
|
29
29
|
builder = builder.with_subcommand('--export-secret-keys')
|
30
30
|
names.each do |name|
|
31
31
|
builder = builder.with_argument(name)
|
@@ -8,7 +8,6 @@ require_relative 'mixins/batch_config'
|
|
8
8
|
require_relative 'mixins/passphrase_config'
|
9
9
|
require_relative 'mixins/pinentry_config'
|
10
10
|
require_relative 'mixins/status_config'
|
11
|
-
require_relative 'mixins/with_result'
|
12
11
|
require_relative 'mixins/with_captured_status'
|
13
12
|
require_relative 'mixins/without_passphrase'
|
14
13
|
|
@@ -20,15 +19,14 @@ module RubyGPG2
|
|
20
19
|
include Mixins::PassphraseConfig
|
21
20
|
include Mixins::PinentryConfig
|
22
21
|
include Mixins::StatusConfig
|
23
|
-
include Mixins::WithResult
|
24
22
|
include Mixins::WithCapturedStatus
|
25
23
|
include Mixins::WithoutPassphrase
|
26
24
|
|
27
|
-
def configure_command(builder,
|
28
|
-
parameter_file_path =
|
25
|
+
def configure_command(builder, parameters)
|
26
|
+
parameter_file_path = parameters[:parameter_file_path]
|
29
27
|
|
30
28
|
builder = builder.with_subcommand('--generate-key')
|
31
|
-
builder = super(builder,
|
29
|
+
builder = super(builder, parameters)
|
32
30
|
if parameter_file_path
|
33
31
|
builder = builder.with_argument(parameter_file_path)
|
34
32
|
end
|
@@ -6,7 +6,6 @@ require_relative 'base'
|
|
6
6
|
require_relative 'mixins/global_config'
|
7
7
|
require_relative 'mixins/batch_config'
|
8
8
|
require_relative 'mixins/status_config'
|
9
|
-
require_relative 'mixins/with_result'
|
10
9
|
require_relative 'mixins/with_captured_status'
|
11
10
|
|
12
11
|
module RubyGPG2
|
@@ -15,13 +14,12 @@ module RubyGPG2
|
|
15
14
|
include Mixins::GlobalConfig
|
16
15
|
include Mixins::BatchConfig
|
17
16
|
include Mixins::StatusConfig
|
18
|
-
include Mixins::WithResult
|
19
17
|
include Mixins::WithCapturedStatus
|
20
18
|
|
21
|
-
def configure_command(builder,
|
22
|
-
key_file_paths =
|
19
|
+
def configure_command(builder, parameters)
|
20
|
+
key_file_paths = parameters[:key_file_paths] || []
|
23
21
|
|
24
|
-
builder = super(builder,
|
22
|
+
builder = super(builder, parameters)
|
25
23
|
builder = builder.with_subcommand('--import')
|
26
24
|
key_file_paths.each do |key_file_path|
|
27
25
|
builder = builder.with_argument(key_file_path)
|
@@ -5,7 +5,6 @@ require 'lino'
|
|
5
5
|
require_relative 'base'
|
6
6
|
require_relative 'mixins/global_config'
|
7
7
|
require_relative 'mixins/colon_config'
|
8
|
-
require_relative 'mixins/with_result'
|
9
8
|
require_relative 'mixins/with_captured_output'
|
10
9
|
|
11
10
|
module RubyGPG2
|
@@ -13,12 +12,11 @@ module RubyGPG2
|
|
13
12
|
class ListPublicKeys < Base
|
14
13
|
include Mixins::GlobalConfig
|
15
14
|
include Mixins::ColonConfig
|
16
|
-
include Mixins::WithResult
|
17
15
|
include Mixins::WithCapturedOutput
|
18
16
|
|
19
|
-
def configure_command(builder,
|
17
|
+
def configure_command(builder, parameters)
|
20
18
|
builder = builder.with_subcommand('--list-public-keys')
|
21
|
-
super(builder,
|
19
|
+
super(builder, parameters)
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
@@ -5,7 +5,6 @@ require 'lino'
|
|
5
5
|
require_relative 'base'
|
6
6
|
require_relative 'mixins/global_config'
|
7
7
|
require_relative 'mixins/colon_config'
|
8
|
-
require_relative 'mixins/with_result'
|
9
8
|
require_relative 'mixins/with_captured_output'
|
10
9
|
|
11
10
|
module RubyGPG2
|
@@ -13,12 +12,11 @@ module RubyGPG2
|
|
13
12
|
class ListSecretKeys < Base
|
14
13
|
include Mixins::GlobalConfig
|
15
14
|
include Mixins::ColonConfig
|
16
|
-
include Mixins::WithResult
|
17
15
|
include Mixins::WithCapturedOutput
|
18
16
|
|
19
|
-
def configure_command(builder,
|
17
|
+
def configure_command(builder, parameters)
|
20
18
|
builder = builder.with_subcommand('--list-secret-keys')
|
21
|
-
super(builder,
|
19
|
+
super(builder, parameters)
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
@@ -4,10 +4,12 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module ArmorConfig
|
7
|
-
|
8
|
-
armor = opts[:armor]
|
7
|
+
private
|
9
8
|
|
10
|
-
|
9
|
+
def configure_command(builder, parameters)
|
10
|
+
armor = parameters[:armor]
|
11
|
+
|
12
|
+
builder = super(builder, parameters)
|
11
13
|
builder = builder.with_flag('--armor') if armor
|
12
14
|
builder
|
13
15
|
end
|
@@ -4,10 +4,17 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module BatchConfig
|
7
|
-
|
8
|
-
batch = opts[:batch].nil? ? true : opts[:batch]
|
7
|
+
private
|
9
8
|
|
10
|
-
|
9
|
+
def parameter_defaults(parameters)
|
10
|
+
batch = parameters[:batch]
|
11
|
+
super.merge(batch: batch.nil? ? true : batch)
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure_command(builder, parameters)
|
15
|
+
batch = parameters[:batch]
|
16
|
+
|
17
|
+
builder = super(builder, parameters)
|
11
18
|
builder = builder.with_flag('--batch') if batch
|
12
19
|
builder
|
13
20
|
end
|
@@ -4,10 +4,17 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module ColonConfig
|
7
|
-
|
8
|
-
with_colons = opts[:with_colons].nil? ? true : opts[:with_colons]
|
7
|
+
private
|
9
8
|
|
10
|
-
|
9
|
+
def parameter_defaults(parameters)
|
10
|
+
with_colons = parameters[:with_colons]
|
11
|
+
super.merge(with_colons: with_colons.nil? ? true : with_colons)
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure_command(builder, parameters)
|
15
|
+
with_colons = parameters[:with_colons]
|
16
|
+
|
17
|
+
builder = super(builder, parameters)
|
11
18
|
builder = builder.with_flag('--with-colons') if with_colons
|
12
19
|
builder
|
13
20
|
end
|
@@ -4,11 +4,18 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module GlobalConfig
|
7
|
-
|
8
|
-
home_directory = opts[:home_directory]
|
9
|
-
without_tty = opts[:without_tty].nil? ? true : opts[:without_tty]
|
7
|
+
private
|
10
8
|
|
11
|
-
|
9
|
+
def parameter_defaults(parameters)
|
10
|
+
without_tty = parameters[:without_tty]
|
11
|
+
super.merge(without_tty: without_tty.nil? ? true : without_tty)
|
12
|
+
end
|
13
|
+
|
14
|
+
def configure_command(builder, parameters)
|
15
|
+
home_directory = parameters[:home_directory]
|
16
|
+
without_tty = parameters[:without_tty]
|
17
|
+
|
18
|
+
builder = super(builder, parameters)
|
12
19
|
if home_directory
|
13
20
|
builder = builder.with_option(
|
14
21
|
'--homedir', home_directory, quoting: '"'
|
@@ -4,10 +4,12 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module InputConfig
|
7
|
-
|
8
|
-
input_file_path = opts[:input_file_path]
|
7
|
+
private
|
9
8
|
|
10
|
-
|
9
|
+
def configure_command(builder, parameters)
|
10
|
+
input_file_path = parameters[:input_file_path]
|
11
|
+
|
12
|
+
builder = super(builder, parameters)
|
11
13
|
builder = builder.with_argument(input_file_path) if input_file_path
|
12
14
|
builder
|
13
15
|
end
|
@@ -4,10 +4,12 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module OutputConfig
|
7
|
-
|
8
|
-
output_file_path = opts[:output_file_path]
|
7
|
+
private
|
9
8
|
|
10
|
-
|
9
|
+
def configure_command(builder, parameters)
|
10
|
+
output_file_path = parameters[:output_file_path]
|
11
|
+
|
12
|
+
builder = super(builder, parameters)
|
11
13
|
if output_file_path
|
12
14
|
builder = builder.with_option(
|
13
15
|
'--output', output_file_path, quoting: '"'
|
@@ -4,10 +4,12 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module PassphraseConfig
|
7
|
-
|
8
|
-
passphrase = opts[:passphrase]
|
7
|
+
private
|
9
8
|
|
10
|
-
|
9
|
+
def configure_command(builder, parameters)
|
10
|
+
passphrase = parameters[:passphrase]
|
11
|
+
|
12
|
+
builder = super(builder, parameters)
|
11
13
|
if passphrase
|
12
14
|
builder = builder.with_option(
|
13
15
|
'--passphrase', passphrase, quoting: '"'
|
@@ -4,10 +4,12 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module PinentryConfig
|
7
|
-
|
8
|
-
pinentry_mode = opts[:pinentry_mode]
|
7
|
+
private
|
9
8
|
|
10
|
-
|
9
|
+
def configure_command(builder, parameters)
|
10
|
+
pinentry_mode = parameters[:pinentry_mode]
|
11
|
+
|
12
|
+
builder = super(builder, parameters)
|
11
13
|
if pinentry_mode
|
12
14
|
builder = builder.with_option(
|
13
15
|
'--pinentry-mode', pinentry_mode
|
@@ -4,10 +4,12 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module RecipientConfig
|
7
|
-
|
8
|
-
recipient = opts[:recipient]
|
7
|
+
private
|
9
8
|
|
10
|
-
|
9
|
+
def configure_command(builder, parameters)
|
10
|
+
recipient = parameters[:recipient]
|
11
|
+
|
12
|
+
builder = super(builder, parameters)
|
11
13
|
if recipient
|
12
14
|
builder = builder.with_option(
|
13
15
|
'--recipient', recipient
|
@@ -4,10 +4,12 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module StatusConfig
|
7
|
-
|
8
|
-
status_file = opts[:status_file]
|
7
|
+
private
|
9
8
|
|
10
|
-
|
9
|
+
def configure_command(builder, parameters)
|
10
|
+
status_file = parameters[:status_file]
|
11
|
+
|
12
|
+
builder = super(builder, parameters)
|
11
13
|
if status_file
|
12
14
|
builder = builder.with_option(
|
13
15
|
'--status-file', status_file, quoting: '"'
|
@@ -4,10 +4,12 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module TrustModeConfig
|
7
|
-
|
8
|
-
trust_mode = opts[:trust_mode]
|
7
|
+
private
|
9
8
|
|
10
|
-
|
9
|
+
def configure_command(builder, parameters)
|
10
|
+
trust_mode = parameters[:trust_mode]
|
11
|
+
|
12
|
+
builder = super(builder, parameters)
|
11
13
|
if trust_mode
|
12
14
|
builder = builder.with_option(
|
13
15
|
'--trust-mode', trust_mode
|
@@ -6,21 +6,24 @@ module RubyGPG2
|
|
6
6
|
module Commands
|
7
7
|
module Mixins
|
8
8
|
module WithCapturedOutput
|
9
|
-
|
10
|
-
super(*args)
|
11
|
-
@stdout = StringIO.new unless
|
12
|
-
defined?(@stdout) && @stdout.respond_to?(:string)
|
13
|
-
end
|
9
|
+
private
|
14
10
|
|
15
|
-
def
|
16
|
-
|
11
|
+
def parameter_defaults(parameters)
|
12
|
+
parse_output = parameters[:parse_output]
|
13
|
+
super.merge(parse_output: parse_output.nil? ? true : parse_output)
|
17
14
|
end
|
18
15
|
|
19
|
-
|
16
|
+
def invocation_option_defaults(_invocation_options)
|
17
|
+
super.merge(capture: [:stdout])
|
18
|
+
end
|
20
19
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
20
|
+
def process_result(result, parameters, invocation_options)
|
21
|
+
result = super(result, parameters, invocation_options)
|
22
|
+
if parameters[:parse_output]
|
23
|
+
result.output =
|
24
|
+
ColonOutput.parse(result.output)
|
25
|
+
end
|
26
|
+
result
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
@@ -8,30 +8,37 @@ module RubyGPG2
|
|
8
8
|
module Commands
|
9
9
|
module Mixins
|
10
10
|
module WithCapturedStatus
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
private
|
12
|
+
|
13
|
+
# rubocop:disable Metrics/MethodLength
|
14
|
+
def do_around(parameters, invocation_options)
|
15
|
+
if parameters[:with_status]
|
16
|
+
Tempfile.create('status-file', parameters[:work_directory]) do |f|
|
17
|
+
result = yield(
|
18
|
+
parameters.merge(status_file: f.path), invocation_options
|
19
|
+
)
|
15
20
|
@status = File.read(f.path)
|
21
|
+
result
|
16
22
|
end
|
17
23
|
else
|
18
|
-
yield
|
24
|
+
yield parameters, invocation_options
|
19
25
|
end
|
20
26
|
end
|
27
|
+
# rubocop:enable Metrics/MethodLength
|
21
28
|
|
22
|
-
def
|
23
|
-
|
24
|
-
super(opts.merge(status: resolve_status(@status, opts)))
|
25
|
-
else
|
26
|
-
super(opts)
|
27
|
-
end
|
29
|
+
def status(parameters)
|
30
|
+
parameters[:parse_status] ? StatusOutput.parse(@status) : @status
|
28
31
|
end
|
29
32
|
|
30
|
-
|
33
|
+
def parameter_defaults(parameters)
|
34
|
+
parse_status = parameters[:parse_status]
|
35
|
+
super.merge(parse_status: parse_status.nil? ? true : parse_status)
|
36
|
+
end
|
31
37
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
38
|
+
def process_result(result, parameters, invocation_options)
|
39
|
+
result = super(result, parameters, invocation_options)
|
40
|
+
result.status = status(parameters) if parameters[:with_status]
|
41
|
+
result
|
35
42
|
end
|
36
43
|
end
|
37
44
|
end
|
@@ -4,13 +4,13 @@ module RubyGPG2
|
|
4
4
|
module Commands
|
5
5
|
module Mixins
|
6
6
|
module WithoutPassphrase
|
7
|
-
def configure_command(builder,
|
8
|
-
without_passphrase =
|
7
|
+
def configure_command(builder, parameters)
|
8
|
+
without_passphrase = parameters[:without_passphrase]
|
9
9
|
if without_passphrase
|
10
|
-
|
11
|
-
|
10
|
+
parameters = parameters.merge(passphrase: '',
|
11
|
+
pinentry_mode: :loopback)
|
12
12
|
end
|
13
|
-
super(builder,
|
13
|
+
super(builder, parameters)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
data/lib/ruby_gpg2/version.rb
CHANGED
data/lib/ruby_gpg2.rb
CHANGED
data/ruby_gpg2.gemspec
CHANGED
@@ -34,9 +34,9 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
35
35
|
spec.require_paths = ['lib']
|
36
36
|
|
37
|
-
spec.required_ruby_version = '>=
|
37
|
+
spec.required_ruby_version = '>= 3.1'
|
38
38
|
|
39
|
-
spec.add_dependency 'lino', '
|
39
|
+
spec.add_dependency 'lino', '3.2.0.pre.10'
|
40
40
|
|
41
41
|
spec.add_development_dependency 'bundler'
|
42
42
|
spec.add_development_dependency 'gem-release'
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_gpg2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.0.pre.
|
4
|
+
version: 0.11.0.pre.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- InfraBlocks Maintainers
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lino
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.2.0.pre.10
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.2.0.pre.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -262,7 +262,6 @@ files:
|
|
262
262
|
- lib/ruby_gpg2/commands/mixins/trust_mode_config.rb
|
263
263
|
- lib/ruby_gpg2/commands/mixins/with_captured_output.rb
|
264
264
|
- lib/ruby_gpg2/commands/mixins/with_captured_status.rb
|
265
|
-
- lib/ruby_gpg2/commands/mixins/with_result.rb
|
266
265
|
- lib/ruby_gpg2/commands/mixins/without_passphrase.rb
|
267
266
|
- lib/ruby_gpg2/commands/result.rb
|
268
267
|
- lib/ruby_gpg2/key.rb
|
@@ -292,14 +291,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
292
291
|
requirements:
|
293
292
|
- - ">="
|
294
293
|
- !ruby/object:Gem::Version
|
295
|
-
version: '
|
294
|
+
version: '3.1'
|
296
295
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
297
296
|
requirements:
|
298
297
|
- - ">"
|
299
298
|
- !ruby/object:Gem::Version
|
300
299
|
version: 1.3.1
|
301
300
|
requirements: []
|
302
|
-
rubygems_version: 3.
|
301
|
+
rubygems_version: 3.3.7
|
303
302
|
signing_key:
|
304
303
|
specification_version: 4
|
305
304
|
summary: A simple Ruby wrapper for invoking gpg (>= 2.0) commands.
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'stringio'
|
4
|
-
|
5
|
-
module RubyGPG2
|
6
|
-
module Commands
|
7
|
-
module Mixins
|
8
|
-
module WithResult
|
9
|
-
def do_after(opts)
|
10
|
-
result = super(opts)
|
11
|
-
result.output = opts[:output] if opts[:output]
|
12
|
-
result.status = opts[:status] if opts[:status]
|
13
|
-
result
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|