ftpmvc 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7abd0e2a3bd146744e6bf6e96965d4745ba84bc7
4
- data.tar.gz: 2e079a93d919b52c2529de70de3a9bc7970594f9
3
+ metadata.gz: c44c716cbea576f3370d4ca4e9558cd6d574760d
4
+ data.tar.gz: b9df269b3d01e96c29aa18cb264f61fc3f7ad4e7
5
5
  SHA512:
6
- metadata.gz: 905e09c15e88c3267783b00f2e151eb5b2b8c5194366f9b38b0dbdca1b38833771c19e54ca918efdceb3059f82a4cf4274ba8a15b5f1e6cc9833b79feedfdcff
7
- data.tar.gz: 4b8272c171aaffb33c6df2a18b0336d035d04a3ffc4cefd0eefd47fdc33268d06a9214f78ab62f71d7af003e04f0cc0449a25e65417632895da9d51e7d8b8bb4
6
+ metadata.gz: 9d85dc01c5c985c153213a5619b9462748cd229cde5885ffe01e1a87d7db2c0782a0a1ca8ac1462c5d507ef608f6205dcb659d8eabaa71c6e146bbf22ba33f5e
7
+ data.tar.gz: 74aec4ff03549eebf18a81cd85c2dff53c35ef131520c89739fd71e0fa402afc53c5c8337ef605b3a0a0f5acd94a00660d234485f9f04d5e8d5b485a2b6643ad
@@ -2,25 +2,35 @@ require 'forwardable'
2
2
  require 'ftpmvc/directory'
3
3
  require 'ftpmvc/filter'
4
4
  require 'ftpmvc/access_filesystem_filter'
5
+ require 'ftpmvc/authenticator/promiscuous'
5
6
 
6
7
  module FTPMVC
7
8
  class Application
8
9
  extend Forwardable
9
10
 
10
11
  def_delegators :@filter_chain, :index, :size, :get, :directory?
12
+ def_delegators :auth, :authenticate
11
13
 
12
14
  def initialize(&block)
13
- @fs = FTPMVC::Directory.new('/')
15
+ @fs = Directory.new('/')
14
16
  @filter_chain = AccessFilesystemFilter.new(@fs, nil)
15
- instance_eval(&block)
17
+ instance_eval(&block) if block_given?
16
18
  end
17
19
 
18
20
  protected
19
21
 
22
+ def auth
23
+ @authenticator ||= Authenticator::Promiscuous.new
24
+ end
25
+
20
26
  def filter(filter_class, options={})
21
27
  @filter_chain = filter_class.new(@fs, @filter_chain, options)
22
28
  end
23
29
 
30
+ def authenticator(authenticator)
31
+ @authenticator = authenticator
32
+ end
33
+
24
34
  def filesystem(&block)
25
35
  @fs.instance_eval(&block)
26
36
  end
@@ -0,0 +1,13 @@
1
+ module FTPMVC
2
+ module Authenticator
3
+ class Basic
4
+ def initialize(options={})
5
+ @users = options[:users]
6
+ end
7
+
8
+ def authenticate(username, password)
9
+ @users[username] == password
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module FTPMVC
2
+ module Authenticator
3
+ class Promiscuous
4
+ def authenticate(username, password)
5
+ true
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ include 'ftpmvc/authenticator/promiscuous'
@@ -0,0 +1 @@
1
+ require 'ftpmvc/format/csv'
@@ -1,3 +1,3 @@
1
1
  module FTPMVC
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/ftpmvc.rb CHANGED
@@ -2,4 +2,5 @@ require 'ftpmvc/version'
2
2
  require 'ftpmvc/server'
3
3
  require 'ftpmvc/file'
4
4
  require 'ftpmvc/application'
5
- require 'ftpmvc/formats'
5
+ require 'ftpmvc/format'
6
+ require 'ftpmvc/authenticator'
@@ -37,4 +37,26 @@ describe FTPMVC::Application do
37
37
  end
38
38
  end
39
39
  end
40
+
41
+ describe '#authenticate' do
42
+ let(:custom_authenticator) { double('custom_authenticator') }
43
+ let(:application) do
44
+ auth = custom_authenticator
45
+ FTPMVC::Application.new do
46
+ authenticator auth
47
+ end
48
+ end
49
+ it 'forwards to authenticator' do
50
+ expect(custom_authenticator)
51
+ .to receive(:authenticate)
52
+ .with('fabio', 'iS2grails')
53
+ application.authenticate('fabio', 'iS2grails')
54
+ end
55
+ end
56
+ context 'when no authenticator is defined' do
57
+ let(:application) { FTPMVC::Application.new }
58
+ it 'returns always true' do
59
+ expect(application.authenticate('fabio', 'iS2grails')).to be true
60
+ end
61
+ end
40
62
  end
@@ -0,0 +1,28 @@
1
+ require './spec/spec_helper'
2
+
3
+ require 'ftpmvc/authenticator/basic'
4
+
5
+ describe FTPMVC::Authenticator::Basic do
6
+ describe '#authenticate' do
7
+ let(:authenticator) do
8
+ FTPMVC::Authenticator::Basic.new users: {
9
+ 'fabio' => 'iS2grails'
10
+ }
11
+ end
12
+ context 'when username and password are listed on users map' do
13
+ it 'returns true' do
14
+ expect(authenticator.authenticate('fabio', 'iS2grails')).to be true
15
+ end
16
+ end
17
+ context 'when username is not listed on users map' do
18
+ it 'returns false' do
19
+ expect(authenticator.authenticate('lucas', 'iS2grails')).to be false
20
+ end
21
+ end
22
+ context 'when username is listed on users map but password is incorrect' do
23
+ it 'returns false' do
24
+ expect(authenticator.authenticate('fabio', 'wrongpassword')).to be false
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,6 +1,6 @@
1
1
  require './spec/spec_helper'
2
2
 
3
- require 'ftpmvc/formats/csv'
3
+ require 'ftpmvc/format/csv'
4
4
  require 'ftpmvc/file'
5
5
 
6
6
  describe FTPMVC::Formats::CSV do
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.1.1
4
+ version: 0.2.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: 2014-10-30 00:00:00.000000000 Z
11
+ date: 2014-10-31 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: em-ftpd
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: :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: '0'
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
@@ -131,20 +131,24 @@ files:
131
131
  - lib/ftpmvc.rb
132
132
  - lib/ftpmvc/access_filesystem_filter.rb
133
133
  - lib/ftpmvc/application.rb
134
+ - lib/ftpmvc/authenticator.rb
135
+ - lib/ftpmvc/authenticator/basic.rb
136
+ - lib/ftpmvc/authenticator/promiscuous.rb
134
137
  - lib/ftpmvc/directory.rb
135
138
  - lib/ftpmvc/driver.rb
136
139
  - lib/ftpmvc/file.rb
137
140
  - lib/ftpmvc/filter.rb
138
- - lib/ftpmvc/formats.rb
139
- - lib/ftpmvc/formats/csv.rb
141
+ - lib/ftpmvc/format.rb
142
+ - lib/ftpmvc/format/csv.rb
140
143
  - lib/ftpmvc/server.rb
141
144
  - lib/ftpmvc/test_helpers.rb
142
145
  - lib/ftpmvc/version.rb
143
146
  - spec/integration/operation_spec.rb
144
147
  - spec/lib/ftpmvc/access_filesystem_filter_spec.rb
145
148
  - spec/lib/ftpmvc/application_spec.rb
149
+ - spec/lib/ftpmvc/authenticator/basic_spec.rb
146
150
  - spec/lib/ftpmvc/directory_spec.rb
147
- - spec/lib/ftpmvc/formats/csv_spec.rb
151
+ - spec/lib/ftpmvc/format/csv_spec.rb
148
152
  - spec/lib/ftpmvc/server_spec.rb
149
153
  - spec/spec_helper.rb
150
154
  homepage: https://github.com/investtools/ftpmvc
@@ -157,12 +161,12 @@ require_paths:
157
161
  - lib
158
162
  required_ruby_version: !ruby/object:Gem::Requirement
159
163
  requirements:
160
- - - ">="
164
+ - - '>='
161
165
  - !ruby/object:Gem::Version
162
166
  version: '0'
163
167
  required_rubygems_version: !ruby/object:Gem::Requirement
164
168
  requirements:
165
- - - ">="
169
+ - - '>='
166
170
  - !ruby/object:Gem::Version
167
171
  version: '0'
168
172
  requirements: []
@@ -175,7 +179,8 @@ test_files:
175
179
  - spec/integration/operation_spec.rb
176
180
  - spec/lib/ftpmvc/access_filesystem_filter_spec.rb
177
181
  - spec/lib/ftpmvc/application_spec.rb
182
+ - spec/lib/ftpmvc/authenticator/basic_spec.rb
178
183
  - spec/lib/ftpmvc/directory_spec.rb
179
- - spec/lib/ftpmvc/formats/csv_spec.rb
184
+ - spec/lib/ftpmvc/format/csv_spec.rb
180
185
  - spec/lib/ftpmvc/server_spec.rb
181
186
  - spec/spec_helper.rb
@@ -1 +0,0 @@
1
- require 'ftpmvc/formats/csv'
File without changes