sks_dump_parser 0.3 → 0.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/sks_parser.rb +13 -24
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d8b06b5a9dc6e7b1234b1357fded43c4b7a5a579
4
- data.tar.gz: 5952fc949175dc48d6bf5935f9a33f2c2b29968f
3
+ metadata.gz: 523b6e3ed43a257cccc18c99597c2742799a500b
4
+ data.tar.gz: ef7c860a0b3c780752d5cb46edc83b8e48698585
5
5
  SHA512:
6
- metadata.gz: 2eb2318c318c40cf86a1d0a5be66dd5201c5fdd76da91311c5a930da9dfb8ca7f1b1dfd7f1e29984d23727f3e948e6c6313b161cfdcbf2dd74ce61912e0eee49
7
- data.tar.gz: d42321a0cd6b05da3a64ce80541b1ac5fb187abcfcf6060276201ba34793e68257a7e80dd36fd4d9a028d7b8859df879eae740ec2a23fbed720785021384786f
6
+ metadata.gz: b56af18ad9066d3e6f259aec7848da53d8357334dc9b712831bb3b9572c9e73be3e0a04983e4443249897acca7e06e66ab859e40f97e3d85d1de40772e26d172
7
+ data.tar.gz: 32db228481463025a5f90a23f52d3076dc81903449bc8bb02a03e05d62567d9dee925053924a195dafbc6e72e72234162d3d3eee986d06f41f3d27f76b5fb12e
data/lib/sks_parser.rb CHANGED
@@ -11,9 +11,8 @@ class SksParser
11
11
 
12
12
  # enumerate states
13
13
  S_READING_UID = 0
14
- S_READING_USER = 1
15
- S_READING_SIGS = 2
16
- S_READING_SUBS = 3
14
+ S_READING_USER_OR_SIGS = 1
15
+ S_READING_SUBS = 2
17
16
 
18
17
  def self.get_dump_hash_from(dump)
19
18
  sm = StateMachine.new
@@ -31,10 +30,8 @@ class SksParser
31
30
  case @state
32
31
  when S_READING_UID
33
32
  process_uid_line(line)
34
- when S_READING_USER
35
- process_user_line(line)
36
- when S_READING_SIGS
37
- process_sig_line(line)
33
+ when S_READING_USER_OR_SIGS
34
+ process_user_or_sig_line(line)
38
35
  when S_READING_SUBS
39
36
  process_sub_line(line)
40
37
  else
@@ -45,29 +42,20 @@ class SksParser
45
42
  def process_uid_line(line)
46
43
  if line.start_with?("\tkeyid")
47
44
  @keyid = line.split(' ')[1]
48
- @dump_hash[@keyid] = {}
49
- self.state = S_READING_USER
50
- else
51
- return
45
+ @dump_hash[@keyid] = {:sigs => []}
46
+ self.state = S_READING_USER_OR_SIGS
52
47
  end
53
48
  end
54
49
 
55
- def process_user_line(line)
56
- @dump_hash[@keyid][:user] = line.split(' ', 4)[3][1..-2]
57
- @dump_hash[@keyid][:sigs] = []
58
- self.state = S_READING_SIGS
59
- end
60
-
61
- def process_sig_line(line)
62
- if line.start_with?(':signature')
50
+ def process_user_or_sig_line(line)
51
+ if line.start_with?(":user")
52
+ @dump_hash[@keyid][:user] = line.split(' ', 4)[3][1..-2]
53
+ elsif line.start_with?(":sig")
63
54
  @dump_hash[@keyid][:sigs] << line.split(' ')[5]
64
- end
65
- if line.start_with?(':public sub')
55
+ elsif line.start_with?(':public sub')
66
56
  self.state = S_READING_SUBS
67
57
  elsif line.start_with?(':public key')
68
58
  self.state = S_READING_UID
69
- elsif line.start_with?(':user')
70
- self.state = S_READING_UID
71
59
  end
72
60
  end
73
61
 
@@ -83,6 +71,7 @@ class SksParser
83
71
  output = []
84
72
  files = Dir.glob("#{directory}/*")
85
73
  files.each do |file|
74
+ puts file
86
75
  IO.popen("gpg --list-packets #{file}").each do |line|
87
76
  output << line
88
77
  end
@@ -90,6 +79,6 @@ class SksParser
90
79
  StateMachine.get_dump_hash_from(output)
91
80
  end
92
81
 
93
- puts SksParser.parse_dump('asdf')
82
+ #puts SksParser.parse_dump('/Users/sue/IdeaProjects/sks/')
94
83
 
95
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sks_dump_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sue White
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-15 00:00:00.000000000 Z
11
+ date: 2014-04-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: sue@mailworks.org