ftpmvc 0.6.0 → 0.7.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: c1ce45b7b3c0fff939bd7cc90a3806c70b41eb18
4
- data.tar.gz: 45757c6f7f22060f65a9862bb965e0800df7f937
3
+ metadata.gz: 6696ff1bddf6f75d9672d0204132a12796e3fba9
4
+ data.tar.gz: b15c4843e0990bdbafd9798d25c5e0ab38237c83
5
5
  SHA512:
6
- metadata.gz: 454896b3e3856d5ab9dc01035d002acb2d9b5962c424574e1e77fe621b86e48ff4dd5fe1c7ebb71124e6b9d317d1e2c04292951328a717e3af4c7e83adf31482
7
- data.tar.gz: ff6da3c34fa074407dce7f2601ad0445b73b6002ce31fed4f05feab0a9096df96be7bdd66b9611cf9b9b3b853cdfbffa50cabb5f975ff43b608ed1265c53af32
6
+ metadata.gz: 728265569fd9b89de5813500922b834e767708b4b2627f75527f281d632aab7516a68a91da2c367ebbd1438f15e510625358f0e1ab6dfa2ed9babaa508badce7
7
+ data.tar.gz: 9b11c9548e0d017e567f56ff2f219a0a7e6fdb98033fdb3f8e570c2d047fc611ca58669d404d18e5a21a70010391df6dbc71fec182f0d1630f86b92c4d40ab0c
@@ -1,7 +1,6 @@
1
1
  require 'forwardable'
2
2
  require 'ftpmvc/directory'
3
- require 'ftpmvc/filter'
4
- require 'ftpmvc/access_filesystem_filter'
3
+ require 'ftpmvc/filter/filesystem_access'
5
4
  require 'ftpmvc/authenticator/promiscuous'
6
5
 
7
6
  module FTPMVC
@@ -14,7 +13,7 @@ module FTPMVC
14
13
 
15
14
  def initialize(&block)
16
15
  @fs = Directory.new('/')
17
- @filter_chain = AccessFilesystemFilter.new(@fs, nil)
16
+ @filter_chain = Filter::FilesystemAccess.new(@fs, nil)
18
17
  instance_eval(&block) if block_given?
19
18
  end
20
19
 
@@ -33,8 +32,11 @@ module FTPMVC
33
32
  @exception_handler = block
34
33
  end
35
34
 
36
- def filter(filter_class, options={})
37
- @filter_chain = filter_class.new(@fs, @filter_chain, options)
35
+ def filter(filter, options={})
36
+ if filter.kind_of?(Symbol)
37
+ filter = FTPMVC::Filter.const_get(filter.to_s.camelize)
38
+ end
39
+ @filter_chain = filter.new(@fs, @filter_chain, options)
38
40
  end
39
41
 
40
42
  def authenticator(authenticator, options={})
@@ -0,0 +1,15 @@
1
+ require 'forwardable'
2
+
3
+ module FTPMVC
4
+ module Filter
5
+ class Base
6
+ extend Forwardable
7
+
8
+ def_delegators :@chain, :index, :get, :directory?, :exists?, :put
9
+
10
+ def initialize(fs, chain, options={})
11
+ @fs, @chain, @options = fs, chain, options
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ require 'ftpmvc/directory'
2
+ require 'ftpmvc/filter/base'
3
+
4
+ module FTPMVC
5
+ module Filter
6
+ class FilesystemAccess < FTPMVC::Filter::Base
7
+
8
+ def get(path)
9
+ @fs.resolve(::File.dirname(path)).get(::File.basename(path))
10
+ end
11
+
12
+ def index(path)
13
+ @fs.resolve(path).index
14
+ end
15
+
16
+ def directory?(path)
17
+ @fs.resolve(path).kind_of?(Directory)
18
+ end
19
+
20
+ def exists?(path)
21
+ not @fs.resolve(path).nil?
22
+ end
23
+
24
+ def put(path, stream)
25
+ @fs.resolve(::File.dirname(path)).put(::File.basename(path), stream)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module FTPMVC
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -3,19 +3,20 @@ require './spec/spec_helper'
3
3
  require 'ftpmvc/application'
4
4
  require 'ftpmvc/file'
5
5
  require 'ftpmvc/authenticator/basic'
6
+ require 'ftpmvc/filter/base'
6
7
 
7
8
  describe FTPMVC::Application do
8
9
  describe '#filter' do
9
10
  before do
10
- stub_const 'FooFilter', Class.new(FTPMVC::Filter)
11
- allow_any_instance_of(FooFilter)
11
+ stub_const 'FTPMVC::Filter::Foo', Class.new(FTPMVC::Filter::Base)
12
+ allow_any_instance_of(FTPMVC::Filter::Foo)
12
13
  .to receive(:index)
13
14
  .and_return [ foo_file ]
14
15
  end
15
16
  let(:foo_file) { FTPMVC::File.new('foo') }
16
17
  let(:application) do
17
18
  FTPMVC::Application.new do
18
- filter FooFilter
19
+ filter FTPMVC::Filter::Foo
19
20
  filesystem do
20
21
  directory :music
21
22
  end
@@ -27,7 +28,7 @@ describe FTPMVC::Application do
27
28
  context 'when filter chains' do
28
29
  let(:application) do
29
30
  FTPMVC::Application.new do
30
- filter FTPMVC::Filter
31
+ filter FTPMVC::Filter::Base
31
32
  filesystem do
32
33
  directory :music
33
34
  end
@@ -37,6 +38,26 @@ describe FTPMVC::Application do
37
38
  expect(application.index('/').first.name).to eq 'music'
38
39
  end
39
40
  end
41
+ context 'when a symbol is given' do
42
+ let(:application) do
43
+ FTPMVC::Application.new do
44
+ filter :foo
45
+ end
46
+ end
47
+ it 'initializes a class on FTPMVC::Filter with given options' do
48
+ expect(application.index('/')).to eq [ foo_file ]
49
+ end
50
+ end
51
+ context 'when a class is given' do
52
+ let(:application) do
53
+ FTPMVC::Application.new do
54
+ filter FTPMVC::Filter::Foo
55
+ end
56
+ end
57
+ it 'initializes that class with given options' do
58
+ expect(application.index('/')).to eq [ foo_file ]
59
+ end
60
+ end
40
61
  end
41
62
 
42
63
  describe '#authenticator' do
@@ -1,15 +1,15 @@
1
1
  require './spec/spec_helper'
2
2
 
3
- require 'ftpmvc/access_filesystem_filter'
3
+ require 'ftpmvc/filter/filesystem_access'
4
4
  require 'ftpmvc/file'
5
5
 
6
- describe FTPMVC::AccessFilesystemFilter do
6
+ describe FTPMVC::Filter::FilesystemAccess do
7
7
  let(:filesystem) do
8
8
  FTPMVC::Directory.new('/') do
9
9
  directory :music
10
10
  end
11
11
  end
12
- let(:filter) { FTPMVC::AccessFilesystemFilter.new(filesystem, nil) }
12
+ let(:filter) { FTPMVC::Filter::FilesystemAccess.new(filesystem, nil) }
13
13
  before do
14
14
  stub_const 'MusicDirectory', Class.new(FTPMVC::Directory)
15
15
  end
metadata CHANGED
@@ -1,111 +1,111 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ftpmvc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.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-01-05 00:00:00.000000000 Z
11
+ date: 2015-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :development
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.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
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: guard-rspec
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: terminal-notifier-guard
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: codeclimate-test-reporter
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: ftpd
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: 1.1.1
90
90
  type: :runtime
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: 1.1.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: activesupport
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: :runtime
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
  description: FTP MVC framework
@@ -115,9 +115,9 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
- - .gitignore
119
- - .rspec
120
- - .travis.yml
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
121
  - Gemfile
122
122
  - Guardfile
123
123
  - LICENSE.txt
@@ -129,14 +129,14 @@ files:
129
129
  - examples/env/env_file.rb
130
130
  - ftpmvc.gemspec
131
131
  - lib/ftpmvc.rb
132
- - lib/ftpmvc/access_filesystem_filter.rb
133
132
  - lib/ftpmvc/application.rb
134
133
  - lib/ftpmvc/authenticator.rb
135
134
  - lib/ftpmvc/authenticator/basic.rb
136
135
  - lib/ftpmvc/authenticator/promiscuous.rb
137
136
  - lib/ftpmvc/directory.rb
138
137
  - lib/ftpmvc/file.rb
139
- - lib/ftpmvc/filter.rb
138
+ - lib/ftpmvc/filter/base.rb
139
+ - lib/ftpmvc/filter/filesystem_access.rb
140
140
  - lib/ftpmvc/format.rb
141
141
  - lib/ftpmvc/format/csv.rb
142
142
  - lib/ftpmvc/ftpd.rb
@@ -148,10 +148,10 @@ files:
148
148
  - lib/ftpmvc/version.rb
149
149
  - spec/integration/authentication_spec.rb
150
150
  - spec/integration/operation_spec.rb
151
- - spec/lib/ftpmvc/access_filesystem_filter_spec.rb
152
151
  - spec/lib/ftpmvc/application_spec.rb
153
152
  - spec/lib/ftpmvc/authenticator/basic_spec.rb
154
153
  - spec/lib/ftpmvc/directory_spec.rb
154
+ - spec/lib/ftpmvc/filter/filesystem_access.rb
155
155
  - spec/lib/ftpmvc/format/csv_spec.rb
156
156
  - spec/lib/ftpmvc/server_spec.rb
157
157
  - spec/spec_helper.rb
@@ -165,12 +165,12 @@ require_paths:
165
165
  - lib
166
166
  required_ruby_version: !ruby/object:Gem::Requirement
167
167
  requirements:
168
- - - '>='
168
+ - - ">="
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  required_rubygems_version: !ruby/object:Gem::Requirement
172
172
  requirements:
173
- - - '>='
173
+ - - ">="
174
174
  - !ruby/object:Gem::Version
175
175
  version: '0'
176
176
  requirements: []
@@ -182,10 +182,10 @@ summary: FTP MVC framework
182
182
  test_files:
183
183
  - spec/integration/authentication_spec.rb
184
184
  - spec/integration/operation_spec.rb
185
- - spec/lib/ftpmvc/access_filesystem_filter_spec.rb
186
185
  - spec/lib/ftpmvc/application_spec.rb
187
186
  - spec/lib/ftpmvc/authenticator/basic_spec.rb
188
187
  - spec/lib/ftpmvc/directory_spec.rb
188
+ - spec/lib/ftpmvc/filter/filesystem_access.rb
189
189
  - spec/lib/ftpmvc/format/csv_spec.rb
190
190
  - spec/lib/ftpmvc/server_spec.rb
191
191
  - spec/spec_helper.rb
@@ -1,27 +0,0 @@
1
- require 'ftpmvc/directory'
2
- require 'ftpmvc/filter'
3
-
4
- module FTPMVC
5
- class AccessFilesystemFilter < FTPMVC::Filter
6
-
7
- def get(path)
8
- @fs.resolve(::File.dirname(path)).get(::File.basename(path))
9
- end
10
-
11
- def index(path)
12
- @fs.resolve(path).index
13
- end
14
-
15
- def directory?(path)
16
- @fs.resolve(path).kind_of?(Directory)
17
- end
18
-
19
- def exists?(path)
20
- not @fs.resolve(path).nil?
21
- end
22
-
23
- def put(path, stream)
24
- @fs.resolve(::File.dirname(path)).put(::File.basename(path), stream)
25
- end
26
- end
27
- end
data/lib/ftpmvc/filter.rb DELETED
@@ -1,13 +0,0 @@
1
- require 'forwardable'
2
-
3
- module FTPMVC
4
- class Filter
5
- extend Forwardable
6
-
7
- def_delegators :@chain, :index, :get, :directory?, :exists?, :put
8
-
9
- def initialize(fs, chain, options={})
10
- @fs, @chain, @options = fs, chain, options
11
- end
12
- end
13
- end