ruby-pgp 0.0.2 → 0.0.3

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: 6fa376eee6905851682992f1a483dbb669d6180b2b3eea5db2ce7dcf8476aad6
4
- data.tar.gz: 78be3caee14c1a49d5d088d1c3e1ecc3f7e0802765e883b1c3a94fcb781f7cc7
3
+ metadata.gz: a2f20309e0bba2ee5b6f21a6147dfd3b718abf796e5e43df145a6cebdd4946a3
4
+ data.tar.gz: c0cdba253d3b1b8c7c31b69630f7396855bf0073280826c18ad6646a84d35bd8
5
5
  SHA512:
6
- metadata.gz: 11a3b1c30f823d33330aab439ee1724ab8b6bba8f848f59055950d326770d8725856c68e683de95d245feb5054c7714e3ee795307908c2fa6be0b6323650ae9b
7
- data.tar.gz: b7efc4e3fcba5d9bb39a1b671a4e72603ae8b7ea72825df89fe513fd793069d98c64636cad999da11962ec2389c0d20c5ebfa806fb795782645c5ab1ff623234
6
+ metadata.gz: ce0777ec36e513bb1960811b7d70597d4a493a9056c58b7e9d6f89c52e719545b553f6d3dc643697180146d48c318344096369ff17d580fa7f8062674d62dadf
7
+ data.tar.gz: 8d1bf0b32fe44113730c528bade31d882c83449231c5617c16b01cfc1f52c74bdd111f95a51289f63299ff778fb43bbe2f126966ef8a942baedf440d0da1435f
@@ -1,6 +1,3 @@
1
- require 'tempfile'
2
- require 'tmpdir'
3
-
4
1
  module GPG
5
2
  class Engine
6
3
  include PGP::LogCapable
@@ -13,13 +10,17 @@ module GPG
13
10
 
14
11
  def import_key(key_contents)
15
12
  log("Import Key")
13
+
16
14
  validate_gpg_version
17
- Tempfile.open do |f|
18
- f.write(key_contents)
19
- f.rewind
20
15
 
21
- runner.import_key_from_file(f.path)
16
+ result = []
17
+
18
+ GPG::TempPathHelper.create do |path1|
19
+ File.write(path1, key_contents)
20
+ result = runner.import_key_from_file(path1)
22
21
  end
22
+
23
+ result
23
24
  end
24
25
 
25
26
  def verify_signature(signature_data)
@@ -1,3 +1,5 @@
1
+ require 'tmpdir'
2
+
1
3
  module GPG
2
4
  class TempPathHelper
3
5
  def self.create(&block)
data/lib/pgp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PGP
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -1,23 +1,4 @@
1
1
  module TempHelper
2
- def setup_temp_file(contents='')
3
- stub = create_temp_file_stub(contents)
4
- allow(Tempfile).to receive(:open).and_yield(stub)
5
- stub
6
- end
7
-
8
- def create_temp_file_stub(contents='')
9
- stub = double
10
- allow(stub).to receive(:path).and_return(random_string)
11
- allow(stub).to receive(:write).with(contents)
12
- allow(stub).to receive(:read).and_return(contents)
13
- allow(stub).to receive(:rewind)
14
- stub
15
- end
16
-
17
- def random_string(length=20)
18
- (0...length).map { (65 + rand(26)).chr }.join
19
- end
20
-
21
2
  def setup_temp_paths(paths)
22
3
  allow(GPG::TempPathHelper).to receive(:create) do |&block|
23
4
  p = paths.pop
@@ -75,16 +75,13 @@ describe GPG::Engine do
75
75
  describe :import_key do
76
76
  it 'creates a temporary file and imports the key' do
77
77
  setup_valid_gpg_version
78
- temp_file_stub = setup_temp_file('key contents aaaaa')
79
- allow(runner).to receive(:import_key_from_file).with(temp_file_stub.path).and_return([
80
- 'email1@gmail.com',
81
- 'email2@gmail.com'
82
- ])
78
+ setup_temp_paths(['path1'])
79
+ allow(File).to receive(:write).with('path1', 'key contents aaaaa')
80
+ allow(runner).to receive(:import_key_from_file).with('path1').and_return(['email1@gmail.com', 'email2@gmail.com'])
83
81
 
84
82
  expect(engine.import_key('key contents aaaaa')).to eq(['email1@gmail.com', 'email2@gmail.com'])
85
83
 
86
- expect(temp_file_stub).to have_received(:write)
87
- expect(temp_file_stub).to have_received(:rewind)
84
+ expect(File).to have_received(:write)
88
85
  expect(runner).to have_received(:import_key_from_file)
89
86
  end
90
87
 
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'tempfile'
2
3
 
3
4
  describe 'RSpec multiple yields quirks' do
4
5
  ##
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-pgp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Camilo Sanchez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-13 00:00:00.000000000 Z
11
+ date: 2020-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake