ruby_gpg2 0.1.0.pre.24 → 0.3.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 262fa5828445a8b815c8559edabfc8a9b37650490834736804d214635295e29c
4
- data.tar.gz: 9caa53e85f84f29d37644c2ef49453a6963a1dbfb3bd14b21951fac338ab8264
3
+ metadata.gz: fe873b22790b6394af48855ac313beac4bf2096b6d40aa5eb5cd8da8193b8bb3
4
+ data.tar.gz: 61efacada4cdc48579621494897e889355eb103f3ece6f06e08a5d8d3eb0fa94
5
5
  SHA512:
6
- metadata.gz: 5e92062433cef4ca2a705ea2949bc5491e79f8caa7c04638034e7db0bed21b902f70aa8e1c91a4e6ab96ea12cebd18ee1c0b33b5124f32e6382a70a12ae1473d
7
- data.tar.gz: c3750d44bc8d46a88ecf45748ff064f837605adaacb946606950f0b7a5e2c917d693b7ee13c723400fe997e90f5ea18dfe2bc2c899663677f1514810fb0089d0
6
+ metadata.gz: ebe36ef0c3a388f124c66dbf4c8c672d8326ad2b79428a4f9f42989b428982d9dd07da5d33da4157f54f995cc8656b66168ab701f800896fa5b607e2392c29ef
7
+ data.tar.gz: 747aabae36d659cb9e8109c11acb1ef3bd11f6b3f0ed6676dde13002bf2051cde60bfb3f2922fb6fdc0123e60e7be1b15c40b84e5e1561f854bcf2d4663481bb
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_gpg2 (0.1.0.pre.24)
4
+ ruby_gpg2 (0.3.0.pre.1)
5
5
  lino (= 1.3.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (6.0.2.2)
10
+ activesupport (6.0.3.1)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 0.7, < 2)
13
13
  minitest (~> 5.1)
14
14
  tzinfo (~> 1.1)
15
- zeitwerk (~> 2.2)
15
+ zeitwerk (~> 2.2, >= 2.2.2)
16
16
  addressable (2.7.0)
17
17
  public_suffix (>= 2.0.2, < 5.0)
18
18
  colored2 (3.1.2)
@@ -29,13 +29,13 @@ GEM
29
29
  lino (1.3.0)
30
30
  hamster (~> 3.0)
31
31
  open4 (~> 1.3)
32
- minitest (5.14.0)
32
+ minitest (5.14.1)
33
33
  multipart-post (2.1.1)
34
34
  octokit (4.18.0)
35
35
  faraday (>= 0.9)
36
36
  sawyer (~> 0.8.0, >= 0.5.3)
37
37
  open4 (1.3.4)
38
- public_suffix (4.0.4)
38
+ public_suffix (4.0.5)
39
39
  rake (13.0.1)
40
40
  rake_circle_ci (0.7.0)
41
41
  colored2 (~> 3.1)
@@ -58,15 +58,15 @@ GEM
58
58
  rspec-core (~> 3.9.0)
59
59
  rspec-expectations (~> 3.9.0)
60
60
  rspec-mocks (~> 3.9.0)
61
- rspec-core (3.9.1)
62
- rspec-support (~> 3.9.1)
63
- rspec-expectations (3.9.1)
61
+ rspec-core (3.9.2)
62
+ rspec-support (~> 3.9.3)
63
+ rspec-expectations (3.9.2)
64
64
  diff-lcs (>= 1.2.0, < 2.0)
65
65
  rspec-support (~> 3.9.0)
66
66
  rspec-mocks (3.9.1)
67
67
  diff-lcs (>= 1.2.0, < 2.0)
68
68
  rspec-support (~> 3.9.0)
69
- rspec-support (3.9.2)
69
+ rspec-support (3.9.3)
70
70
  sawyer (0.8.2)
71
71
  addressable (>= 2.3.5)
72
72
  faraday (> 0.8, < 2.0)
@@ -3,6 +3,7 @@ require 'ruby_gpg2/commands'
3
3
  require 'ruby_gpg2/parameter_file_contents'
4
4
  require 'ruby_gpg2/colon_output'
5
5
  require 'ruby_gpg2/status_output'
6
+ require 'ruby_gpg2/status_lines'
6
7
  require 'ruby_gpg2/key'
7
8
  require 'ruby_gpg2/user_id'
8
9
 
@@ -5,6 +5,7 @@ require_relative 'mixins/global_config'
5
5
  require_relative 'mixins/batch_config'
6
6
  require_relative 'mixins/input_config'
7
7
  require_relative 'mixins/output_config'
8
+ require_relative 'mixins/trust_mode_config'
8
9
  require_relative 'mixins/passphrase_config'
9
10
  require_relative 'mixins/pinentry_config'
10
11
  require_relative 'mixins/without_passphrase'
@@ -16,6 +17,7 @@ module RubyGPG2
16
17
  include Mixins::BatchConfig
17
18
  include Mixins::InputConfig
18
19
  include Mixins::OutputConfig
20
+ include Mixins::TrustModeConfig
19
21
  include Mixins::PassphraseConfig
20
22
  include Mixins::PinentryConfig
21
23
  include Mixins::WithoutPassphrase
@@ -7,6 +7,7 @@ require_relative 'mixins/armor_config'
7
7
  require_relative 'mixins/input_config'
8
8
  require_relative 'mixins/output_config'
9
9
  require_relative 'mixins/recipient_config'
10
+ require_relative 'mixins/trust_mode_config'
10
11
 
11
12
  module RubyGPG2
12
13
  module Commands
@@ -17,6 +18,7 @@ module RubyGPG2
17
18
  include Mixins::InputConfig
18
19
  include Mixins::OutputConfig
19
20
  include Mixins::RecipientConfig
21
+ include Mixins::TrustModeConfig
20
22
 
21
23
  def configure_command(builder, opts)
22
24
  builder = super(builder, opts)
@@ -3,12 +3,18 @@ require 'lino'
3
3
  require_relative 'base'
4
4
  require_relative 'mixins/global_config'
5
5
  require_relative 'mixins/batch_config'
6
+ require_relative 'mixins/status_config'
7
+ require_relative 'mixins/with_result'
8
+ require_relative 'mixins/with_captured_status'
6
9
 
7
10
  module RubyGPG2
8
11
  module Commands
9
12
  class Import < Base
10
13
  include Mixins::GlobalConfig
11
14
  include Mixins::BatchConfig
15
+ include Mixins::StatusConfig
16
+ include Mixins::WithResult
17
+ include Mixins::WithCapturedStatus
12
18
 
13
19
  def configure_command(builder, opts)
14
20
  key_file_paths = opts[:key_file_paths] || []
@@ -0,0 +1,16 @@
1
+ module RubyGPG2
2
+ module Commands
3
+ module Mixins
4
+ module TrustModeConfig
5
+ def configure_command(builder, opts)
6
+ trust_mode = opts[:trust_mode]
7
+
8
+ builder = super(builder, opts)
9
+ builder = builder.with_option(
10
+ '--trust-mode', trust_mode) if trust_mode
11
+ builder
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,139 +1,22 @@
1
+ require_relative 'status_lines'
2
+
1
3
  module RubyGPG2
2
4
  class StatusLine
3
- class KeyCreated
4
- KEY_TYPES = {
5
- 'B' => :primary_and_subkey,
6
- 'P' => :primary,
7
- 'S' => :subkey
8
- }
9
-
10
- def self.parse(line)
11
- match = line.match(/^\[GNUPG:\] KEY_CREATED (.) (.*?)(?: (.*))?$/)
12
- new(
13
- raw: line,
14
- key_type: KEY_TYPES[match[1]],
15
- key_fingerprint: match[2],
16
- handle: match[3])
17
- end
18
-
19
- attr_reader(
20
- :raw,
21
- :key_type,
22
- :key_fingerprint,
23
- :handle)
24
-
25
- def initialize(opts)
26
- @raw = opts[:raw]
27
- @key_type = opts[:key_type]
28
- @key_fingerprint = opts[:key_fingerprint]
29
- @handle = opts[:handle]
30
- end
31
-
32
- def type
33
- :key_created
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
- @raw,
45
- @key_type,
46
- @key_fingerprint
47
- ]
48
- end
49
- end
50
-
51
- class KeyConsidered
52
- FLAGS = {
53
- '0' => [],
54
- '1' => [:key_not_selected],
55
- '2' => [:all_subkeys_expired_or_revoked]
56
- }
57
-
58
- def self.parse(line)
59
- match = line.match(/^\[GNUPG:\] KEY_CONSIDERED (.*) (.*)$/)
60
- new(
61
- raw: line,
62
- key_fingerprint: match[1],
63
- flags: FLAGS[match[2]])
64
- end
65
-
66
- attr_reader(
67
- :raw,
68
- :key_fingerprint,
69
- :flags)
70
-
71
- def initialize(opts)
72
- @raw = opts[:raw]
73
- @key_fingerprint = opts[:key_fingerprint]
74
- @flags = opts[:flags]
75
- end
76
-
77
- def type
78
- :key_considered
79
- end
80
-
81
- def ==(other)
82
- other.class == self.class && other.state == state
83
- end
84
-
85
- protected
86
-
87
- def state
88
- [
89
- @raw,
90
- @key_fingerprint,
91
- @flags
92
- ]
93
- end
94
- end
95
-
96
- class Unimplemented
97
- def self.parse(line)
98
- new(raw: line)
99
- end
100
-
101
- attr_reader(
102
- :raw)
103
-
104
- def initialize(opts)
105
- @raw = opts[:raw]
106
- end
107
-
108
- def type
109
- :unknown
110
- end
111
-
112
- def ==(other)
113
- other.class == self.class && other.state == state
114
- end
115
-
116
- protected
117
-
118
- def state
119
- [
120
- @raw
121
- ]
122
- end
123
- end
124
-
125
5
  TYPE_REGEX = /^\[GNUPG:\] (.*?)(\s|$)/
126
6
 
127
7
  TYPES = {
128
- "KEY_CREATED" => KeyCreated,
129
- "KEY_CONSIDERED" => KeyConsidered
8
+ "IMPORT_OK" => StatusLines::ImportOK,
9
+ "IMPORT_PROBLEM" => StatusLines::ImportProblem,
10
+ "IMPORTED" => StatusLines::Imported,
11
+ "KEY_CREATED" => StatusLines::KeyCreated,
12
+ "KEY_CONSIDERED" => StatusLines::KeyConsidered
130
13
  }
131
14
 
132
15
  def self.parse(line)
133
16
  TYPES
134
17
  .fetch(
135
18
  line.match(TYPE_REGEX)[1],
136
- Unimplemented)
19
+ StatusLines::Unimplemented)
137
20
  .parse(line)
138
21
  end
139
22
  end
@@ -0,0 +1,12 @@
1
+ require_relative 'status_lines/import_ok'
2
+ require_relative 'status_lines/import_problem'
3
+ require_relative 'status_lines/imported'
4
+ require_relative 'status_lines/key_considered'
5
+ require_relative 'status_lines/key_created'
6
+ require_relative 'status_lines/unimplemented'
7
+
8
+ module RubyGPG2
9
+ module StatusLines
10
+
11
+ end
12
+ end
@@ -0,0 +1,65 @@
1
+ module RubyGPG2
2
+ module StatusLines
3
+ class ImportOK
4
+ REASONS = {
5
+ 1 => :new_key,
6
+ 2 => :new_user_ids,
7
+ 4 => :new_signatures,
8
+ 8 => :new_subkeys,
9
+ 16 => :private_key
10
+ }
11
+
12
+ def self.parse(line)
13
+ match = line.match(/^\[GNUPG:\] IMPORT_OK (\d+) (.*)$/)
14
+ new(
15
+ raw: line,
16
+ reasons: reasons(match[1]),
17
+ key_fingerprint: match[2])
18
+ end
19
+
20
+ attr_reader(
21
+ :raw,
22
+ :reasons,
23
+ :key_fingerprint)
24
+
25
+ def initialize(opts)
26
+ @raw = opts[:raw]
27
+ @reasons = opts[:reasons]
28
+ @key_fingerprint = opts[:key_fingerprint]
29
+ end
30
+
31
+ def type
32
+ :import_ok
33
+ end
34
+
35
+ def ==(other)
36
+ other.class == self.class && other.state == state
37
+ end
38
+
39
+ protected
40
+
41
+ def state
42
+ [
43
+ @raw,
44
+ @reasons,
45
+ @key_fingerprint
46
+ ]
47
+ end
48
+
49
+ private
50
+
51
+ def self.reasons(value)
52
+ value = value.to_i
53
+ if value == 0
54
+ [:no_change]
55
+ else
56
+ REASONS.inject([]) do |r, entry|
57
+ (value & entry[0]) > 0 ?
58
+ (r << entry[1]) :
59
+ r
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,50 @@
1
+ module RubyGPG2
2
+ module StatusLines
3
+ class ImportProblem
4
+ REASONS = {
5
+ 0 => :no_reason_given,
6
+ 1 => :invalid_certificate,
7
+ 2 => :issuer_certificate_missing,
8
+ 3 => :certificate_chain_too_long,
9
+ 4 => :error_storing_certificate
10
+ }
11
+
12
+ def self.parse(line)
13
+ match = line.match(/^\[GNUPG:\] IMPORT_PROBLEM (\d+) (.*)$/)
14
+ new(
15
+ raw: line,
16
+ reason: REASONS[match[1].to_i],
17
+ key_fingerprint: match[2])
18
+ end
19
+
20
+ attr_reader(
21
+ :raw,
22
+ :reason,
23
+ :key_fingerprint)
24
+
25
+ def initialize(opts)
26
+ @raw = opts[:raw]
27
+ @reason = opts[:reason]
28
+ @key_fingerprint = opts[:key_fingerprint]
29
+ end
30
+
31
+ def type
32
+ :import_problem
33
+ end
34
+
35
+ def ==(other)
36
+ other.class == self.class && other.state == state
37
+ end
38
+
39
+ protected
40
+
41
+ def state
42
+ [
43
+ @raw,
44
+ @reason,
45
+ @key_fingerprint
46
+ ]
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,42 @@
1
+ module RubyGPG2
2
+ module StatusLines
3
+ class Imported
4
+ def self.parse(line)
5
+ match = line.match(/^\[GNUPG:\] IMPORTED (.*?) (.*)$/)
6
+ new(
7
+ raw: line,
8
+ key_id: match[1],
9
+ user_id: match[2])
10
+ end
11
+
12
+ attr_reader(
13
+ :raw,
14
+ :key_id,
15
+ :user_id)
16
+
17
+ def initialize(opts)
18
+ @raw = opts[:raw]
19
+ @key_id = opts[:key_id]
20
+ @user_id = opts[:user_id]
21
+ end
22
+
23
+ def type
24
+ :imported
25
+ end
26
+
27
+ def ==(other)
28
+ other.class == self.class && other.state == state
29
+ end
30
+
31
+ protected
32
+
33
+ def state
34
+ [
35
+ @raw,
36
+ @key_id,
37
+ @user_id
38
+ ]
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,48 @@
1
+ module RubyGPG2
2
+ module StatusLines
3
+ class KeyConsidered
4
+ FLAGS = {
5
+ '0' => [],
6
+ '1' => [:key_not_selected],
7
+ '2' => [:all_subkeys_expired_or_revoked]
8
+ }
9
+
10
+ def self.parse(line)
11
+ match = line.match(/^\[GNUPG:\] KEY_CONSIDERED (.*) (.*)$/)
12
+ new(
13
+ raw: line,
14
+ key_fingerprint: match[1],
15
+ flags: FLAGS[match[2]])
16
+ end
17
+
18
+ attr_reader(
19
+ :raw,
20
+ :key_fingerprint,
21
+ :flags)
22
+
23
+ def initialize(opts)
24
+ @raw = opts[:raw]
25
+ @key_fingerprint = opts[:key_fingerprint]
26
+ @flags = opts[:flags]
27
+ end
28
+
29
+ def type
30
+ :key_considered
31
+ end
32
+
33
+ def ==(other)
34
+ other.class == self.class && other.state == state
35
+ end
36
+
37
+ protected
38
+
39
+ def state
40
+ [
41
+ @raw,
42
+ @key_fingerprint,
43
+ @flags
44
+ ]
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,51 @@
1
+ module RubyGPG2
2
+ module StatusLines
3
+ class KeyCreated
4
+ KEY_TYPES = {
5
+ 'B' => :primary_and_subkey,
6
+ 'P' => :primary,
7
+ 'S' => :subkey
8
+ }
9
+
10
+ def self.parse(line)
11
+ match = line.match(/^\[GNUPG:\] KEY_CREATED (.) (.*?)(?: (.*))?$/)
12
+ new(
13
+ raw: line,
14
+ key_type: KEY_TYPES[match[1]],
15
+ key_fingerprint: match[2],
16
+ handle: match[3])
17
+ end
18
+
19
+ attr_reader(
20
+ :raw,
21
+ :key_type,
22
+ :key_fingerprint,
23
+ :handle)
24
+
25
+ def initialize(opts)
26
+ @raw = opts[:raw]
27
+ @key_type = opts[:key_type]
28
+ @key_fingerprint = opts[:key_fingerprint]
29
+ @handle = opts[:handle]
30
+ end
31
+
32
+ def type
33
+ :key_created
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
+ @raw,
45
+ @key_type,
46
+ @key_fingerprint
47
+ ]
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,32 @@
1
+ module RubyGPG2
2
+ module StatusLines
3
+ class Unimplemented
4
+ def self.parse(line)
5
+ new(raw: line)
6
+ end
7
+
8
+ attr_reader(
9
+ :raw)
10
+
11
+ def initialize(opts)
12
+ @raw = opts[:raw]
13
+ end
14
+
15
+ def type
16
+ :unknown
17
+ end
18
+
19
+ def ==(other)
20
+ other.class == self.class && other.state == state
21
+ end
22
+
23
+ protected
24
+
25
+ def state
26
+ [
27
+ @raw
28
+ ]
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module RubyGPG2
2
- VERSION = '0.1.0.pre.24'
2
+ VERSION = '0.3.0.pre.1'
3
3
  end
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.24
4
+ version: 0.3.0.pre.1
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-05-05 00:00:00.000000000 Z
11
+ date: 2020-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lino
@@ -181,6 +181,7 @@ files:
181
181
  - lib/ruby_gpg2/commands/mixins/pinentry_config.rb
182
182
  - lib/ruby_gpg2/commands/mixins/recipient_config.rb
183
183
  - lib/ruby_gpg2/commands/mixins/status_config.rb
184
+ - lib/ruby_gpg2/commands/mixins/trust_mode_config.rb
184
185
  - lib/ruby_gpg2/commands/mixins/with_captured_output.rb
185
186
  - lib/ruby_gpg2/commands/mixins/with_captured_status.rb
186
187
  - lib/ruby_gpg2/commands/mixins/with_result.rb
@@ -189,6 +190,13 @@ files:
189
190
  - lib/ruby_gpg2/key.rb
190
191
  - lib/ruby_gpg2/parameter_file_contents.rb
191
192
  - lib/ruby_gpg2/status_line.rb
193
+ - lib/ruby_gpg2/status_lines.rb
194
+ - lib/ruby_gpg2/status_lines/import_ok.rb
195
+ - lib/ruby_gpg2/status_lines/import_problem.rb
196
+ - lib/ruby_gpg2/status_lines/imported.rb
197
+ - lib/ruby_gpg2/status_lines/key_considered.rb
198
+ - lib/ruby_gpg2/status_lines/key_created.rb
199
+ - lib/ruby_gpg2/status_lines/unimplemented.rb
192
200
  - lib/ruby_gpg2/status_output.rb
193
201
  - lib/ruby_gpg2/user_id.rb
194
202
  - lib/ruby_gpg2/version.rb