ftpmvc-gpg 0.2.0 → 0.3.0

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
  SHA1:
3
- metadata.gz: 4e496802a7d34286f1ee248f9015e53516c62167
4
- data.tar.gz: 7040b38ea69dbe17320ee88f0f68f942f3836adf
3
+ metadata.gz: 46d0c3cb7a9f589b541eeeed74100c71ed3b5fac
4
+ data.tar.gz: ab39079c0dd1e4cf3422095ea1f7d9f11a44bfb0
5
5
  SHA512:
6
- metadata.gz: 5232706bcf4a74d7675d685ddb080789cd0772d9772b5d22f5be9275e1ab7cd3303bd0e66f6ee67e61ace52b5e3bd8f9dfc3918ccf5eacb75644fb4f1818cd02
7
- data.tar.gz: f1b49f3732872892026ae81d679ed5bacf5621223dc831b59bd04c2c3be566952504c5f926cda5bb6a4fb9d43709efa01bad0b5ed2a021f7a8d077e9d0d8fcb8
6
+ metadata.gz: 3b9cf85cc40517a6793c10bc45fed0dccde27a5d95caa4f9658e3ca18bad8fc86a530385ed643007848c15630ee037a033b3ab6f5234840bcf1aa9493c9ac620
7
+ data.tar.gz: 5c51f19670e91ecb200157c5e2d8afbd9e6669241d0fd1fbecdc25112f719cbb837d45f8df5edd04be40062f975b6b74e73f88518576013f406c72e27ddbca41
data/ftpmvc-gpg.gemspec CHANGED
@@ -21,6 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "guard-rspec"
24
- spec.add_dependency "ftpmvc", '>= 0.8.0'
24
+ spec.add_dependency "ftpmvc", '>= 0.9.0'
25
25
  spec.add_dependency "gpgme"
26
26
  end
@@ -1,6 +1,6 @@
1
1
  require 'ftpmvc/filter/base'
2
+ require 'ftpmvc/gpg/input'
2
3
  require 'gpgme'
3
- require 'ftpd/stream'
4
4
 
5
5
  module FTPMVC
6
6
  module Filter
@@ -32,12 +32,8 @@ module FTPMVC
32
32
  @chain.directory?(remove_extension(path))
33
33
  end
34
34
 
35
- def put(path, stream)
36
- buffer = ''
37
- while bytes = stream.read
38
- buffer << bytes
39
- end
40
- @chain.put(remove_extension(path), ::Ftpd::Stream.new(@crypto.decrypt(buffer), 'B'))
35
+ def put(path, input)
36
+ @chain.put(remove_extension(path), FTPMVC::GPG::Input.new(@crypto.decrypt(input.read_all)))
41
37
  end
42
38
 
43
39
  protected
data/lib/ftpmvc/gpg.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  require 'ftpmvc/gpg/version'
2
+ require 'ftpmvc/gpg/input'
2
3
  require 'ftpmvc/filter/gpg'
@@ -0,0 +1,20 @@
1
+ require 'ftpmvc/input'
2
+
3
+ module FTPMVC
4
+ module GPG
5
+ class Input
6
+
7
+ include FTPMVC::Input
8
+
9
+ def initialize(data)
10
+ @data = data
11
+ end
12
+
13
+ def read
14
+ while chunk = @data.read(GPGME::Data::BLOCK_SIZE)
15
+ yield chunk
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,5 +1,5 @@
1
1
  module FTPMVC
2
2
  module GPG
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
@@ -85,8 +85,8 @@ describe FTPMVC::Filter::Gpg do
85
85
  StringIO.new('secret')
86
86
  end
87
87
 
88
- def put(path, stream)
89
- @received_data = stream.read
88
+ def put(path, input)
89
+ @received_data = input.read_all
90
90
  end
91
91
  end
92
92
  end
@@ -1,14 +1,14 @@
1
1
  require 'ftpmvc/filter/gpg'
2
+ require 'ftpmvc/string_input'
2
3
  require 'ftpmvc/file'
3
4
  require 'ftpmvc/directory'
4
- require 'ftpd/stream'
5
5
 
6
6
  describe FTPMVC::Filter::Gpg do
7
7
  let(:other_filter_class) do
8
8
  Class.new(FTPMVC::Filter::Base) do
9
- attr_reader :received_stream
10
- def put(path, stream)
11
- @received_stream = stream
9
+ attr_reader :input
10
+ def put(path, input)
11
+ @input = input
12
12
  end
13
13
  end
14
14
  end
@@ -100,7 +100,7 @@ describe FTPMVC::Filter::Gpg do
100
100
  end
101
101
 
102
102
  describe '#put' do
103
- let(:stream) { Ftpd::Stream.new(StringIO.new('encrypted content'), 'B') }
103
+ let(:input) { FTPMVC::StringInput.new('encrypted content') }
104
104
  before do
105
105
  allow_any_instance_of(GPGME::Crypto)
106
106
  .to receive(:decrypt)
@@ -110,12 +110,12 @@ describe FTPMVC::Filter::Gpg do
110
110
  it 'removes .pgp extension from filename' do
111
111
  expect(other_filter)
112
112
  .to receive(:put)
113
- .with('/secret/passwords.txt', kind_of(Ftpd::Stream))
114
- gpg_filter.put('/secret/passwords.txt.pgp', stream)
113
+ .with('/secret/passwords.txt', kind_of(FTPMVC::Input))
114
+ gpg_filter.put('/secret/passwords.txt.pgp', input)
115
115
  end
116
- it 'decrypts the stream' do
117
- gpg_filter.put('/secret/passwords.txt.pgp', stream)
118
- expect(other_filter.received_stream.read).to eq 'decrypted content'
116
+ it 'decrypts the input' do
117
+ gpg_filter.put('/secret/passwords.txt.pgp', input)
118
+ expect(other_filter.input.read_all).to eq 'decrypted content'
119
119
  end
120
120
  end
121
121
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftpmvc-gpg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - André Aizim Kelmanson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-24 00:00:00.000000000 Z
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '>='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.8.0
61
+ version: 0.9.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.8.0
68
+ version: 0.9.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: gpgme
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -98,6 +98,7 @@ files:
98
98
  - ftpmvc-gpg.gemspec
99
99
  - lib/ftpmvc/filter/gpg.rb
100
100
  - lib/ftpmvc/gpg.rb
101
+ - lib/ftpmvc/gpg/input.rb
101
102
  - lib/ftpmvc/gpg/version.rb
102
103
  - spec/fixtures/data.gpg
103
104
  - spec/integration/ftpmvc/filter/gpg_spec.rb