gpg_status_parser 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data.tar.gz.asc +7 -7
  2. data/lib/gpg_status_parser.rb +36 -0
  3. metadata +3 -3
  4. metadata.gz.asc +7 -7
data.tar.gz.asc CHANGED
@@ -1,11 +1,11 @@
1
1
  -----BEGIN PGP SIGNATURE-----
2
2
  Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
3
3
 
4
- iQEcBAABCgAGBQJRKM7jAAoJEP5F5V2hilTW1jQH/1aQBu/JPu6M7C1UZ98NbkR7
5
- xkmooFS6+/lFkNs7JUczX9dfU9I4e/ukXAxn7TUaY4l/rmxzIyn51uMp937s0kky
6
- 6pyYGsiSmam+jQYZ5/g3BmNdX1TdErkLvhLeDum/ZaKWzmjlW8pJ4NZ4tyVguMoP
7
- vtT7vO0V0bbXdeKG4M9Kir4vY2n4H3wn1C+DAB7VBKRXqaTXuijC7Fv6Th8JIsa2
8
- TJ81aeM3l34XsO+Px+3VADmEHduwe81ge/hqi7WfTvWAc5QWHFc8DwH3fejgx5Yh
9
- 62dri9HGtthF5qlUjNX9JczHzfVCC01ZeX/NSHNkrHK11lkri6VuZBMW4X2bdDQ=
10
- =fP7T
4
+ iQEcBAABCgAGBQJRM49kAAoJEP5F5V2hilTWkP4H/AztOAn8ffWJ9zVLuwMVYuBi
5
+ 9vX3H9o9ie9s68NnfgE2BflTlj5ybij5H0Zw/D84TYiEIGRXXj/QkawW6Z4a1Xo/
6
+ Zhelu5iGO0L1i4oXxuWHsVnU1QYruBw6Yhuu0FeukUv6mpQ5jbK1VJcwVm+DI8bN
7
+ BRPj0YJ/q8XnGoNqMgZsXC9N4GoH7I5G4mrG2UVVRGxNlaoxyjAM2Pk7poi6hUpV
8
+ UU6Ys3dXGMeJVhGl4lPi/VJt6Dry7DKZqu5JwbqODuqTPucnK+9cNKtp6BhkEr62
9
+ G/1OGNFy2Rrmf82r/4LsKzqz4oYlWMHBNeAPUngM+BmF/29lfHfwfqP+yMdpaRM=
10
+ =fMM8
11
11
  -----END PGP SIGNATURE-----
@@ -1,4 +1,5 @@
1
1
  require 'gpg_status_parser/status_message'
2
+ require 'open3'
2
3
 
3
4
  module GPGStatusParser
4
5
 
@@ -17,4 +18,39 @@ module GPGStatusParser
17
18
  end
18
19
  end
19
20
 
21
+ # Run a gpg command, and take care of setting up and tearing down the
22
+ # required temporary files. Just pass in the arguments you want to send
23
+ # to gpg:
24
+ #
25
+ # GPGStatusParser.run_gpg("--verify foo.txt.asc foo.txt")
26
+ #
27
+ # and not:
28
+ #
29
+ # GPGStatusParser.run_gpg("gpg --verify foo.txt.asc foo.txt")
30
+ #
31
+ # It is highly advised that you escape and/or scrub any user
32
+ # generated input to make sure it is safe. See Shellwords#shell_escape
33
+ # in the ruby standard library.
34
+ def self.run_gpg args, data=nil, &block
35
+ exit_status = nil
36
+ status_file = Tempfile.new("status")
37
+
38
+ full_gpg_command = "gpg --status-file #{status_file.path} #{args}"
39
+ gpg_results = Open3.popen3(full_gpg_command) do |stdin, stdout, stderr, wait_thr|
40
+ stdin.write data if data
41
+ stdin.close
42
+ exit_status = wait_thr.value
43
+ parse(status_file, &block)
44
+ out = stdout.read()
45
+ err = stderr.read()
46
+ {:status => exit_status, :stdout => out, :err => err}
47
+ end
48
+ gpg_results
49
+ ensure
50
+ status_file.close
51
+ status_file.unlink
52
+ end
53
+
54
+
55
+
20
56
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpg_status_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-23 00:00:00.000000000 Z
12
+ date: 2013-03-03 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Turns structured status messages provided by gpg into ruby objects for
15
15
  easy manipulation in your code.
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  version: '0'
49
49
  requirements: []
50
50
  rubyforge_project:
51
- rubygems_version: 1.8.24
51
+ rubygems_version: 1.8.25
52
52
  signing_key:
53
53
  specification_version: 3
54
54
  summary: Turns gpg status messages into ruby objects.
metadata.gz.asc CHANGED
@@ -1,11 +1,11 @@
1
1
  -----BEGIN PGP SIGNATURE-----
2
2
  Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
3
3
 
4
- iQEcBAABCgAGBQJRKM7oAAoJEP5F5V2hilTWYm8H/0UcWUEJ96ns/iyzKxNS5kzt
5
- EapjQ+/6hYx8M8/5mjPC8gHkOrCJB6syJvx4N4F/vz83xc661A5ozEznqPNcM4CP
6
- +lsxN2B20LQ7rCOpDVFGi4e76BAUzwzKQqxLjzr1NGyrU4h+UE8K5/tkeSikXb9y
7
- NG2ivyZLvy/RM6UvN1lRnWR24zYQtXoMfqIImgjHTtPJ2h+sl5drUaYGkNy6UMYs
8
- C3JjrvAJ17eV4sHF5EJSMCD+jpsFc1lMdtL+Sr2581Al8vUtCWmJjp4H4o4kFxug
9
- bGEvTu/kcg8izG71j4/BTjknsZh4W/Ef12zkCiOy/6G0I6PbxVSGoucZqWhKeUM=
10
- =7DB2
4
+ iQEcBAABCgAGBQJRM49pAAoJEP5F5V2hilTWJ64H/1Mnou1BURVxDK05XbwBqkbN
5
+ bpZ2rhNowzi1r0qwwas6tWB59NUq4uuFvjNd+eNbJ4bbdoz3zlNJrHeb6GTw7RUZ
6
+ r/eHMSoTa3/EB3uZ+cKprvG5rXxfcyKnL4ZymlAQgym8j0LZ7PULDtKnU9FWNSVZ
7
+ qGUR1CPyrC8WvGH0MpQV6LxagIK66V5jGSGgdVmiG1ZtrlOiS0djzCey7XC0Wf1m
8
+ AudqxHG6qoTbPNw4tp87jd/LSpBSdxVM70fYorgiPYYF+VGmDvk8GZaGXDH49uQO
9
+ ieM14zkMejVEhFVjud+teozZcZ2psdVSzLbhLCWzp5K7/zkXpxY3K+mpGaznT/g=
10
+ =Jr8N
11
11
  -----END PGP SIGNATURE-----