ftpmvc 0.8.0 → 0.9.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: 5bc917bf062bc477474a6f8b1376c79689e04902
4
- data.tar.gz: 8f254536940d5ee5ddd35e095083f5fff1c1e21e
3
+ metadata.gz: 99e6b62e7638ae4f505f7c91665ec8eaa095605d
4
+ data.tar.gz: dc5cef1794af707277f782d773572b20c46f16de
5
5
  SHA512:
6
- metadata.gz: e33c6c0b4452e338d183fa1fd9152ff9fd7a8051b4e26b38ac7a2a898c13b9d9eb68afd169442b4b678d2cb91977356b9c4496fab7753982613332bff4dc6357
7
- data.tar.gz: 94bdfacbedaa060c50846bfb75159912fa08017b0b5a2eff35b57d6413c4ada58d84731a4942db08704a18b8923dbeca54ba4e4a019ce1996f8e3133e2c86b24
6
+ metadata.gz: 9fd37e86b63ff1f728736f66b2190dd4387bc2765164e77c86363ea371d8e8483fa3a259695151a9bd6e5737f240a764a3d2cbbab25369dab815a992833adb05
7
+ data.tar.gz: 98b8152bcdf05e8aa4a5b8b983c8720f714ce2ffa26529210505af5fa98f67930cd8a87bde4d4f37532f8ad9dc5ea1e51c20c8540f01fa71b5b103c32238662d
@@ -1,5 +1,6 @@
1
1
  require 'forwardable'
2
2
  require 'ftpmvc/directory'
3
+ require 'ftpmvc/logger'
3
4
  require 'ftpmvc/filter/filesystem_access'
4
5
  require 'ftpmvc/authenticator/promiscuous'
5
6
 
@@ -7,8 +7,17 @@ module FTPMVC
7
7
 
8
8
  def_delegators :@chain, :index, :get, :directory?, :exists?, :put
9
9
 
10
+ attr_reader :options
11
+
10
12
  def initialize(fs, chain, options={})
11
13
  @fs, @chain, @options = fs, chain, options
14
+ setup
15
+ end
16
+
17
+ protected
18
+
19
+ def setup
20
+ # may be implemented by children
12
21
  end
13
22
  end
14
23
  end
@@ -21,8 +21,8 @@ module FTPMVC
21
21
  not @fs.resolve(path).nil?
22
22
  end
23
23
 
24
- def put(path, stream)
25
- @fs.resolve(::File.dirname(path)).put(::File.basename(path), stream)
24
+ def put(path, input)
25
+ @fs.resolve(::File.dirname(path)).put(::File.basename(path), input)
26
26
  end
27
27
  end
28
28
  end
@@ -1,4 +1,5 @@
1
1
  require 'ftpmvc/logger'
2
+ require 'ftpmvc/ftpd/input'
2
3
 
3
4
  module FTPMVC
4
5
  module Ftpd
@@ -27,7 +28,7 @@ module FTPMVC
27
28
 
28
29
  def write(path, stream)
29
30
  logger.debug { "FTPMVC::Ftpd::FileSystem#write(#{path}, ...)" }
30
- @application.put(path, stream)
31
+ @application.put(path, Input.new(stream))
31
32
  end
32
33
 
33
34
  def accessible?(path)
@@ -0,0 +1,20 @@
1
+ require 'ftpmvc/input'
2
+
3
+ module FTPMVC
4
+ module Ftpd
5
+ class Input
6
+
7
+ include FTPMVC::Input
8
+
9
+ def initialize(stream)
10
+ @stream = stream
11
+ end
12
+
13
+ def read
14
+ while chunk = @stream.read
15
+ yield chunk
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
data/lib/ftpmvc/ftpd.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  require 'ftpmvc/ftpd/driver'
2
2
  require 'ftpmvc/ftpd/file_system'
3
+ require 'ftpmvc/ftpd/input'
@@ -0,0 +1,9 @@
1
+ module FTPMVC
2
+ module Input
3
+ def read_all
4
+ ''.tap do |content|
5
+ read { |chunk| content << chunk }
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module FTPMVC
2
+ class StringInput
3
+
4
+ include Input
5
+
6
+ def initialize(s)
7
+ @s = s
8
+ end
9
+
10
+ def read
11
+ yield @s
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module FTPMVC
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
data/lib/ftpmvc.rb CHANGED
@@ -5,3 +5,4 @@ require 'ftpmvc/application'
5
5
  require 'ftpmvc/format'
6
6
  require 'ftpmvc/authenticator'
7
7
  require 'ftpmvc/logger'
8
+ require 'ftpmvc/input'
@@ -59,12 +59,12 @@ describe FTPMVC::Filter::FilesystemAccess do
59
59
  end
60
60
 
61
61
  describe '#put' do
62
- let(:stream) { double('stream') }
62
+ let(:input) { double('input') }
63
63
  it 'forwards to directory' do
64
64
  expect_any_instance_of(MusicDirectory)
65
65
  .to receive(:put)
66
- .with 'songs.txt', stream
67
- filter.put('/music/songs.txt', stream)
66
+ .with 'songs.txt', input
67
+ filter.put('/music/songs.txt', input)
68
68
  end
69
69
  end
70
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftpmvc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.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
@@ -142,8 +142,11 @@ files:
142
142
  - lib/ftpmvc/ftpd.rb
143
143
  - lib/ftpmvc/ftpd/driver.rb
144
144
  - lib/ftpmvc/ftpd/file_system.rb
145
+ - lib/ftpmvc/ftpd/input.rb
146
+ - lib/ftpmvc/input.rb
145
147
  - lib/ftpmvc/logger.rb
146
148
  - lib/ftpmvc/server.rb
149
+ - lib/ftpmvc/string_input.rb
147
150
  - lib/ftpmvc/test_helpers.rb
148
151
  - lib/ftpmvc/version.rb
149
152
  - spec/integration/authentication_spec.rb