ruby_gpg2 0.1.0.pre.24 → 0.1.0.pre.25

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: 262fa5828445a8b815c8559edabfc8a9b37650490834736804d214635295e29c
4
- data.tar.gz: 9caa53e85f84f29d37644c2ef49453a6963a1dbfb3bd14b21951fac338ab8264
3
+ metadata.gz: 5a80ab1ed8962cd0c714ecdd9325045ed5752a3e76bb014592d42d45eac59a81
4
+ data.tar.gz: 49b777b75ac682a3f9a8fac1aac0a676b5cf73a38209ad3835901cc0c5ed5c07
5
5
  SHA512:
6
- metadata.gz: 5e92062433cef4ca2a705ea2949bc5491e79f8caa7c04638034e7db0bed21b902f70aa8e1c91a4e6ab96ea12cebd18ee1c0b33b5124f32e6382a70a12ae1473d
7
- data.tar.gz: c3750d44bc8d46a88ecf45748ff064f837605adaacb946606950f0b7a5e2c917d693b7ee13c723400fe997e90f5ea18dfe2bc2c899663677f1514810fb0089d0
6
+ metadata.gz: 4469e08c68aea7942e3f1fce9c66bc9e155a273a7b2fcc5b9ff7cbce8a24aa638efd3e27123fd8219900c2fdae342d6f25329b75142b954cbdd6eb7349eb2931
7
+ data.tar.gz: cb6661b93426cfd9f8e01edb6c1e0619eb6d20e88dbdcc4179bdb1b65e825a2bf64da95d71b9a803d2dd84aca810940699e49482c3e66d0e2224a3c2373b8f47
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby_gpg2 (0.1.0.pre.24)
4
+ ruby_gpg2 (0.1.0.pre.25)
5
5
  lino (= 1.3.0)
6
6
 
7
7
  GEM
@@ -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,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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module RubyGPG2
2
- VERSION = '0.1.0.pre.24'
2
+ VERSION = '0.1.0.pre.25'
3
3
  end
data/lib/ruby_gpg2.rb CHANGED
@@ -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
 
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.24
4
+ version: 0.1.0.pre.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
@@ -189,6 +189,13 @@ files:
189
189
  - lib/ruby_gpg2/key.rb
190
190
  - lib/ruby_gpg2/parameter_file_contents.rb
191
191
  - lib/ruby_gpg2/status_line.rb
192
+ - lib/ruby_gpg2/status_lines.rb
193
+ - lib/ruby_gpg2/status_lines/import_ok.rb
194
+ - lib/ruby_gpg2/status_lines/import_problem.rb
195
+ - lib/ruby_gpg2/status_lines/imported.rb
196
+ - lib/ruby_gpg2/status_lines/key_considered.rb
197
+ - lib/ruby_gpg2/status_lines/key_created.rb
198
+ - lib/ruby_gpg2/status_lines/unimplemented.rb
192
199
  - lib/ruby_gpg2/status_output.rb
193
200
  - lib/ruby_gpg2/user_id.rb
194
201
  - lib/ruby_gpg2/version.rb