ftpd 0.16.0 → 0.17.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.
@@ -1,6 +1,6 @@
1
1
  module Ftpd
2
2
 
3
- # This module tranlates exceptions to FileSystemError exceptions.
3
+ # This module translates exceptions to FileSystemError exceptions.
4
4
  #
5
5
  # A disk file system (such as Ftpd::DiskFileSystem) is expected to
6
6
  # raise only FileSystemError exceptions, but many common operations
@@ -40,9 +40,9 @@ module Ftpd
40
40
 
41
41
  def translate_exceptions(method_name)
42
42
  original_method = instance_method(method_name)
43
- define_method method_name do |*args|
43
+ define_method method_name do |*args, &block|
44
44
  exception_translator.translate_exceptions do
45
- original_method.bind(self).call *args
45
+ original_method.bind(self).call *args, &block
46
46
  end
47
47
  end
48
48
  end
@@ -3,7 +3,9 @@ require File.expand_path('spec_helper', File.dirname(__FILE__))
3
3
  module Ftpd
4
4
  describe CommandSequenceChecker do
5
5
 
6
- let(:sequence_error) {[CommandError, '503 Bad sequence of commands']}
6
+ let(:sequence_error_verification) do
7
+ lambda {|e| e.code == 503 && e.message == "Bad sequence of commands"}
8
+ end
7
9
  subject(:checker) {CommandSequenceChecker.new}
8
10
 
9
11
  context 'initial' do
@@ -25,7 +27,7 @@ module Ftpd
25
27
  it 'rejects any other command' do
26
28
  expect {
27
29
  checker.check 'NOOP'
28
- }.to raise_error *sequence_error
30
+ }.to raise_error(FtpServerError, &sequence_error_verification)
29
31
  end
30
32
 
31
33
  end
@@ -49,7 +51,7 @@ module Ftpd
49
51
  checker.expect 'PASS'
50
52
  expect {
51
53
  checker.check 'NOOP'
52
- }.to raise_error *sequence_error
54
+ }.to raise_error(FtpServerError, &sequence_error_verification)
53
55
  end
54
56
 
55
57
  it 'accepts any other command' do
@@ -67,7 +69,7 @@ module Ftpd
67
69
  it 'rejects that command if not expected' do
68
70
  expect {
69
71
  checker.check 'PASS'
70
- }.to raise_error *sequence_error
72
+ }.to raise_error(FtpServerError, &sequence_error_verification)
71
73
  end
72
74
 
73
75
  it 'accepts that command when it is accepted' do
@@ -128,14 +128,17 @@ module Ftpd
128
128
  context '(success)' do
129
129
  let(:path) {'file'}
130
130
  specify do
131
- disk_file_system.read(path).should == canned_contents(path)
131
+ disk_file_system.read(path) do |file|
132
+ file.should be_a(IO)
133
+ file.read.should == canned_contents(path)
134
+ end
132
135
  end
133
136
  end
134
137
 
135
138
  context '(error)' do
136
139
  specify do
137
140
  expect {
138
- disk_file_system.read(missing_path)
141
+ disk_file_system.read(missing_path) {}
139
142
  }.to raise_error *missing_file_error
140
143
  end
141
144
  end
@@ -145,11 +148,12 @@ module Ftpd
145
148
  describe '#write' do
146
149
 
147
150
  let(:contents) {'file contents'}
151
+ let(:stream) {Ftpd::Stream.new(StringIO.new(contents), nil)}
148
152
 
149
153
  context '(success)' do
150
154
  let(:path) {'file_path'}
151
155
  specify do
152
- disk_file_system.write(path, contents)
156
+ disk_file_system.write(path, stream)
153
157
  read_file(path).should == contents
154
158
  end
155
159
  end
@@ -157,7 +161,7 @@ module Ftpd
157
161
  context '(error)' do
158
162
  specify do
159
163
  expect {
160
- disk_file_system.write('dir', contents)
164
+ disk_file_system.write('dir', stream)
161
165
  }.to raise_error *is_a_directory_error
162
166
  end
163
167
  end
@@ -167,11 +171,12 @@ module Ftpd
167
171
  describe '#append' do
168
172
 
169
173
  let(:contents) {'file contents'}
174
+ let(:stream) {Ftpd::Stream.new(StringIO.new(contents), nil)}
170
175
 
171
176
  context '(destination missing)' do
172
177
  let(:path) {'file_path'}
173
178
  specify do
174
- disk_file_system.append(path, contents)
179
+ disk_file_system.append(path, stream)
175
180
  read_file(path).should == contents
176
181
  end
177
182
  end
@@ -179,7 +184,7 @@ module Ftpd
179
184
  context '(destination exists)' do
180
185
  let(:path) {'file'}
181
186
  specify do
182
- disk_file_system.append(path, contents)
187
+ disk_file_system.append(path, stream)
183
188
  read_file(path).should == canned_contents(path) + contents
184
189
  end
185
190
  end
@@ -187,7 +192,7 @@ module Ftpd
187
192
  context '(error)' do
188
193
  specify do
189
194
  expect {
190
- disk_file_system.append('dir', contents)
195
+ disk_file_system.append('dir', stream)
191
196
  }.to raise_error *is_a_directory_error
192
197
  end
193
198
  end
@@ -0,0 +1,13 @@
1
+ require File.expand_path('spec_helper', File.dirname(__FILE__))
2
+
3
+ module Ftpd
4
+ describe FtpServerError do
5
+
6
+ it "won't instantiate with an invalid error code" do
7
+ expect { described_class.new("Nooooooooo", 665) }.to(
8
+ raise_error(ArgumentError, "Invalid response code")
9
+ )
10
+ end
11
+
12
+ end
13
+ end
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftpd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wayne Conrad
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-19 00:00:00.000000000 Z
11
+ date: 2014-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: memoizer
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: cucumber
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: double-bag-ftps
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: jeweler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: redcarpet
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: timecop
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: yard
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: ftpd is a pure Ruby FTP server library. It supports implicit and explicit
@@ -146,8 +146,8 @@ extra_rdoc_files:
146
146
  - LICENSE.md
147
147
  - README.md
148
148
  files:
149
- - .travis.yml
150
- - .yardopts
149
+ - ".travis.yml"
150
+ - ".yardopts"
151
151
  - Changelog.md
152
152
  - Gemfile
153
153
  - Gemfile.lock
@@ -268,7 +268,6 @@ files:
268
268
  - ftpd.gemspec
269
269
  - insecure-test-cert.pem
270
270
  - lib/ftpd.rb
271
- - lib/ftpd/ascii_helper.rb
272
271
  - lib/ftpd/auth_levels.rb
273
272
  - lib/ftpd/cmd_abor.rb
274
273
  - lib/ftpd/cmd_allo.rb
@@ -323,7 +322,6 @@ files:
323
322
  - lib/ftpd/exception_translator.rb
324
323
  - lib/ftpd/exceptions.rb
325
324
  - lib/ftpd/file_info.rb
326
- - lib/ftpd/file_system_error_translator.rb
327
325
  - lib/ftpd/file_system_helper.rb
328
326
  - lib/ftpd/ftp_server.rb
329
327
  - lib/ftpd/insecure_certificate.rb
@@ -336,6 +334,7 @@ files:
336
334
  - lib/ftpd/server.rb
337
335
  - lib/ftpd/session.rb
338
336
  - lib/ftpd/session_config.rb
337
+ - lib/ftpd/stream.rb
339
338
  - lib/ftpd/telnet.rb
340
339
  - lib/ftpd/temp_dir.rb
341
340
  - lib/ftpd/tls_server.rb
@@ -352,7 +351,7 @@ files:
352
351
  - spec/disk_file_system_spec.rb
353
352
  - spec/exception_translator_spec.rb
354
353
  - spec/file_info_spec.rb
355
- - spec/file_system_error_translator_spec.rb
354
+ - spec/ftp_server_error_spec.rb
356
355
  - spec/list_format/eplf_spec.rb
357
356
  - spec/list_format/ls_spec.rb
358
357
  - spec/list_path_spec.rb
@@ -372,17 +371,17 @@ require_paths:
372
371
  - lib
373
372
  required_ruby_version: !ruby/object:Gem::Requirement
374
373
  requirements:
375
- - - '>='
374
+ - - ">="
376
375
  - !ruby/object:Gem::Version
377
376
  version: '0'
378
377
  required_rubygems_version: !ruby/object:Gem::Requirement
379
378
  requirements:
380
- - - '>='
379
+ - - ">="
381
380
  - !ruby/object:Gem::Version
382
381
  version: '0'
383
382
  requirements: []
384
383
  rubyforge_project:
385
- rubygems_version: 2.1.11
384
+ rubygems_version: 2.2.2
386
385
  signing_key:
387
386
  specification_version: 4
388
387
  summary: Pure Ruby FTP server library
@@ -1,16 +0,0 @@
1
- module Ftpd
2
-
3
- module AsciiHelper
4
-
5
- def unix_to_nvt_ascii(s)
6
- return s if s =~ /\r\n/
7
- s.gsub(/\n/, "\r\n")
8
- end
9
-
10
- def nvt_ascii_to_unix(s)
11
- s.gsub(/\r\n/, "\n")
12
- end
13
-
14
- end
15
-
16
- end
@@ -1,29 +0,0 @@
1
- module Ftpd
2
-
3
- # A proxy file system driver that sends a "450" or "550" error
4
- # reply in response to FileSystemError exceptions.
5
-
6
- class FileSystemErrorTranslator
7
-
8
- include Error
9
-
10
- def initialize(file_system)
11
- @file_system = file_system
12
- end
13
-
14
- def respond_to?(method)
15
- @file_system.respond_to?(method) || super
16
- end
17
-
18
- def method_missing(method, *args)
19
- @file_system.send(method, *args)
20
- rescue PermanentFileSystemError => e
21
- permanent_error e
22
- rescue TransientFileSystemError => e
23
- transient_error e
24
- rescue FileSystemError => e
25
- permanent_error e
26
- end
27
-
28
- end
29
- end
@@ -1,59 +0,0 @@
1
- require File.expand_path('spec_helper', File.dirname(__FILE__))
2
-
3
- module Ftpd
4
- describe FileSystemErrorTranslator do
5
-
6
- class MockFileSystem
7
-
8
- def with_error(klass)
9
- raise klass, 'An error occurred'
10
- end
11
-
12
- def without_error
13
- 123
14
- end
15
-
16
- end
17
-
18
- subject(:translator) do
19
- FileSystemErrorTranslator.new(MockFileSystem.new)
20
- end
21
-
22
- context 'missing method' do
23
- specify do
24
- expect {
25
- translator.no_such_method
26
- }.to raise_error NoMethodError, /no_such_method/
27
- end
28
- end
29
-
30
- context 'no exception' do
31
- its(:without_error) {should == 123}
32
- end
33
-
34
- context 'FileSystemError' do
35
- specify do
36
- expect {
37
- translator.with_error(FileSystemError)
38
- }.to raise_error CommandError, '550 An error occurred'
39
- end
40
- end
41
-
42
- context 'PermanentFileSystemError' do
43
- specify do
44
- expect {
45
- translator.with_error(PermanentFileSystemError)
46
- }.to raise_error CommandError, '550 An error occurred'
47
- end
48
- end
49
-
50
- context 'TransientFileSystemError' do
51
- specify do
52
- expect {
53
- translator.with_error(TransientFileSystemError)
54
- }.to raise_error CommandError, '450 An error occurred'
55
- end
56
- end
57
-
58
- end
59
- end