ftpmvc-async-upload 0.0.1
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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/Guardfile +77 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +2 -0
- data/ftpmvc-async-upload.gemspec +29 -0
- data/lib/ftpmvc/async/upload.rb +16 -0
- data/lib/ftpmvc/async/upload/config.rb +22 -0
- data/lib/ftpmvc/async/upload/default_job.rb +22 -0
- data/lib/ftpmvc/async/upload/input.rb +21 -0
- data/lib/ftpmvc/async/upload/job.rb +20 -0
- data/lib/ftpmvc/async/upload/version.rb +7 -0
- data/lib/ftpmvc/filter/async_upload.rb +26 -0
- data/spec/integration/async_upload_spec.rb +77 -0
- data/spec/lib/ftpmvc/async/upload/default_job_spec.rb +42 -0
- data/spec/lib/ftpmvc/async/upload/input_spec.rb +26 -0
- data/spec/lib/ftpmvc/async/upload/job_spec.rb +36 -0
- data/spec/lib/ftpmvc/filter/async_upload_spec.rb +35 -0
- metadata +181 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 67f72c4e49af56f61d4bf71c97776904e4220801
|
4
|
+
data.tar.gz: 354e84173f1e31d17eb36641e07cd7f28b660271
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d65edcad83ec46b51962d48f27ffd3c87136caee2a35b2efb280fb1fa85d722008a5f72849cbcf67acee7286be292435dc4b03a5bb4ed5af164d1c79edc246e9
|
7
|
+
data.tar.gz: 9ebcbe7b2c75a0f92fb7a7f5d8eb876aa48f65dccf26c2b74a006dac2e40fdbe33d8063aa557209cb720f95fe428444f4698c159ca23b64875c2297bba6b301e
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec feature)
|
6
|
+
|
7
|
+
## Uncomment to clear the screen before every task
|
8
|
+
# clearing :on
|
9
|
+
|
10
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
+
## If you want Guard to automatically start up again, run guard in a
|
12
|
+
## shell loop, e.g.:
|
13
|
+
##
|
14
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
+
##
|
16
|
+
## Note: if you are using the `directories` clause above and you are not
|
17
|
+
## watching the project directory ('.'), the you will want to move the Guardfile
|
18
|
+
## to a watched dir and symlink it back, e.g.
|
19
|
+
#
|
20
|
+
# $ mkdir config
|
21
|
+
# $ mv Guardfile config/
|
22
|
+
# $ ln -s config/Guardfile .
|
23
|
+
#
|
24
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
+
|
26
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
27
|
+
# rspec may be run, below are examples of the most common uses.
|
28
|
+
# * bundler: 'bundle exec rspec'
|
29
|
+
# * bundler binstubs: 'bin/rspec'
|
30
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
31
|
+
# installed the spring binstubs per the docs)
|
32
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
33
|
+
# * 'just' rspec: 'rspec'
|
34
|
+
|
35
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
36
|
+
require "guard/rspec/dsl"
|
37
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
38
|
+
|
39
|
+
# Feel free to open issues for suggestions and improvements
|
40
|
+
|
41
|
+
# RSpec files
|
42
|
+
rspec = dsl.rspec
|
43
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
44
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
45
|
+
watch(rspec.spec_files)
|
46
|
+
|
47
|
+
# Ruby files
|
48
|
+
ruby = dsl.ruby
|
49
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
50
|
+
|
51
|
+
# Rails files
|
52
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
53
|
+
dsl.watch_spec_files_for(rails.app_files)
|
54
|
+
dsl.watch_spec_files_for(rails.views)
|
55
|
+
|
56
|
+
watch(rails.controllers) do |m|
|
57
|
+
[
|
58
|
+
rspec.spec.("routing/#{m[1]}_routing"),
|
59
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
60
|
+
rspec.spec.("acceptance/#{m[1]}")
|
61
|
+
]
|
62
|
+
end
|
63
|
+
|
64
|
+
# Rails config changes
|
65
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
66
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
67
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
68
|
+
|
69
|
+
# Capybara features specs
|
70
|
+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
71
|
+
|
72
|
+
# Turnip features and steps
|
73
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
74
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
75
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
76
|
+
end
|
77
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 André Aizim Kelmanson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Ftpmvc::Async::Upload
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ftpmvc-async-upload'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ftpmvc-async-upload
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/ftpmvc-async-upload/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ftpmvc/async/upload/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ftpmvc-async-upload"
|
8
|
+
spec.version = Ftpmvc::Async::Upload::VERSION
|
9
|
+
spec.authors = ["André Aizim Kelmanson"]
|
10
|
+
spec.email = ["akelmanson@gmail.com"]
|
11
|
+
spec.summary = %q{FTPMVC asynchronous upload using resque}
|
12
|
+
spec.description = %q{FTPMVC asynchronous upload using resque}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "vfs"
|
24
|
+
spec.add_development_dependency "guard-rspec"
|
25
|
+
spec.add_development_dependency "resque_spec"
|
26
|
+
spec.add_dependency "ftpmvc", ">= 0.9.0"
|
27
|
+
spec.add_dependency "resque"
|
28
|
+
spec.add_dependency "app"
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'vfs'
|
2
|
+
require 'ftpmvc/async/upload/version'
|
3
|
+
require 'ftpmvc/async/upload/config'
|
4
|
+
require 'ftpmvc/async/upload/job'
|
5
|
+
require 'ftpmvc/async/upload/default_job'
|
6
|
+
require 'ftpmvc/filter/async_upload'
|
7
|
+
|
8
|
+
module FTPMVC
|
9
|
+
module Async
|
10
|
+
module Upload
|
11
|
+
def self.storage
|
12
|
+
FTPMVC::Async::Upload.config.dir.to_dir
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'app'
|
3
|
+
|
4
|
+
module FTPMVC
|
5
|
+
module Async
|
6
|
+
module Upload
|
7
|
+
class Config < Configurable
|
8
|
+
config.dir = Dir.tmpdir
|
9
|
+
config.job = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.configure(&block)
|
13
|
+
config.configure(&block)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.config
|
17
|
+
Config
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'ftpmvc/async/upload/job'
|
2
|
+
require 'ftpmvc/async/upload/config'
|
3
|
+
|
4
|
+
module FTPMVC
|
5
|
+
module Async
|
6
|
+
module Upload
|
7
|
+
class DefaultJob
|
8
|
+
@queue = :ftpmvc
|
9
|
+
|
10
|
+
extend Job
|
11
|
+
|
12
|
+
def self.perform(path, id)
|
13
|
+
FTPMVC::Async::Upload.config.application.put(path, input(id))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
FTPMVC::Async::Upload.configure do
|
21
|
+
config.job = config.job || FTPMVC::Async::Upload::DefaultJob
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'ftpmvc/async/upload'
|
2
|
+
require 'ftpmvc/input'
|
3
|
+
|
4
|
+
module FTPMVC
|
5
|
+
module Async
|
6
|
+
module Upload
|
7
|
+
class Input
|
8
|
+
|
9
|
+
include FTPMVC::Input
|
10
|
+
|
11
|
+
def initialize(id)
|
12
|
+
@file = FTPMVC::Async::Upload.storage[id]
|
13
|
+
end
|
14
|
+
|
15
|
+
def read
|
16
|
+
@file.read { |chunk| yield chunk }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'ftpmvc/async/upload'
|
2
|
+
require 'ftpmvc/async/upload/input'
|
3
|
+
|
4
|
+
module FTPMVC
|
5
|
+
module Async
|
6
|
+
module Upload
|
7
|
+
module Job
|
8
|
+
def after_perform_delete_uploaded_file(path, id)
|
9
|
+
FTPMVC::Async::Upload.storage[id].delete
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def input(id)
|
15
|
+
FTPMVC::Async::Upload::Input.new(id)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'ftpmvc/async/upload'
|
2
|
+
require 'ftpmvc/filter/base'
|
3
|
+
require 'vfs'
|
4
|
+
require 'resque'
|
5
|
+
|
6
|
+
module FTPMVC
|
7
|
+
module Filter
|
8
|
+
class AsyncUpload < FTPMVC::Filter::Base
|
9
|
+
def put(path, input)
|
10
|
+
return super if input.kind_of?(FTPMVC::Async::Upload::Input)
|
11
|
+
SecureRandom.uuid.tap do |id|
|
12
|
+
file(id).write do |out|
|
13
|
+
input.read { |chunk| out.write(chunk) }
|
14
|
+
end
|
15
|
+
Resque.enqueue(FTPMVC::Async::Upload.config.job, path, id)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
def file(id)
|
22
|
+
FTPMVC::Async::Upload.storage[id]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'ftpmvc'
|
2
|
+
require 'ftpmvc/async/upload'
|
3
|
+
require 'ftpmvc/test_helpers'
|
4
|
+
require 'resque_spec'
|
5
|
+
|
6
|
+
describe 'Async Upload' do
|
7
|
+
include FTPMVC::TestHelpers
|
8
|
+
before do
|
9
|
+
ResqueSpec.reset!
|
10
|
+
end
|
11
|
+
let(:etc_dir_class) do
|
12
|
+
Class.new(FTPMVC::Directory) do
|
13
|
+
attr_reader :received
|
14
|
+
def put(path, input)
|
15
|
+
@received = [path, input.read_all]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
let(:etc_dir) { etc_dir_class.new(name: 'etc') }
|
20
|
+
let(:app) do
|
21
|
+
dir = etc_dir
|
22
|
+
FTPMVC::Application.new do
|
23
|
+
filter :async_upload
|
24
|
+
|
25
|
+
filesystem do
|
26
|
+
directory dir
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
before do
|
31
|
+
application = app
|
32
|
+
FTPMVC::Async::Upload.configure do
|
33
|
+
config.application = application
|
34
|
+
end
|
35
|
+
end
|
36
|
+
it 'delegates the put command to the job' do
|
37
|
+
with_resque do
|
38
|
+
with_application(app) do |ftp|
|
39
|
+
ftp.login
|
40
|
+
put(ftp, '/etc/hosts', '127.0.0.1 localhost')
|
41
|
+
expect(etc_dir.received).to eq ['hosts', "127.0.0.1 localhost\n"]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
context 'when job is custom' do
|
46
|
+
let(:my_job_class) do
|
47
|
+
Class.new do
|
48
|
+
extend FTPMVC::Async::Upload::Job
|
49
|
+
|
50
|
+
@queue = :ftpmvc
|
51
|
+
|
52
|
+
def self.perform(path, id)
|
53
|
+
@result = input(id).read_all
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.result
|
57
|
+
@result
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
before do
|
62
|
+
stub_const 'MyJob', my_job_class
|
63
|
+
FTPMVC::Async::Upload.configure do
|
64
|
+
config.job = MyJob
|
65
|
+
end
|
66
|
+
end
|
67
|
+
it 'uses that job' do
|
68
|
+
with_resque do
|
69
|
+
with_application(app) do |ftp|
|
70
|
+
ftp.login
|
71
|
+
put(ftp, '/etc/hosts', '127.0.0.1 localhost')
|
72
|
+
expect(MyJob.result).to eq "127.0.0.1 localhost\n"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'ftpmvc/async/upload/default_job'
|
2
|
+
require 'ftpmvc/async/upload/config'
|
3
|
+
require 'ftpmvc/application'
|
4
|
+
require 'tmpdir'
|
5
|
+
|
6
|
+
describe FTPMVC::Async::Upload::DefaultJob do
|
7
|
+
let(:etc_dir_class) do
|
8
|
+
Class.new(FTPMVC::Directory) do
|
9
|
+
attr_reader :received
|
10
|
+
def put(path, input)
|
11
|
+
@received = [path, input.read_all]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
let(:etc_dir) { etc_dir_class.new(name: 'etc') }
|
16
|
+
let(:application) do
|
17
|
+
dir = etc_dir
|
18
|
+
FTPMVC::Application.new do
|
19
|
+
filesystem do
|
20
|
+
directory dir
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
around do |example|
|
25
|
+
Dir.mktmpdir do |dir|
|
26
|
+
app = application
|
27
|
+
FTPMVC::Async::Upload.configure do
|
28
|
+
config.application = app
|
29
|
+
config.dir = dir
|
30
|
+
end
|
31
|
+
File.open(File.join(dir, '123456'), 'w') { |f| f.write '127.0.0.1 localhost' }
|
32
|
+
example.run
|
33
|
+
end
|
34
|
+
end
|
35
|
+
describe '.perform' do
|
36
|
+
it 'calls Application#put' do
|
37
|
+
|
38
|
+
FTPMVC::Async::Upload::DefaultJob.perform('/etc/hosts', '123456')
|
39
|
+
expect(etc_dir.received).to eq ['hosts', '127.0.0.1 localhost']
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'ftpmvc/async/upload/input'
|
2
|
+
require 'ftpmvc/async/upload/config'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
describe '#input' do
|
6
|
+
around do |example|
|
7
|
+
Dir.mktmpdir do |dir|
|
8
|
+
File.open(File.join(dir, 'my-file'), 'w') { |f| f.write('content') }
|
9
|
+
FTPMVC::Async::Upload.configure do
|
10
|
+
config.dir = dir
|
11
|
+
end
|
12
|
+
example.run
|
13
|
+
end
|
14
|
+
end
|
15
|
+
let(:input) { FTPMVC::Async::Upload::Input.new('my-file') }
|
16
|
+
describe '#read' do
|
17
|
+
it 'reads the file content chunk-by-chunk' do
|
18
|
+
expect { |b| input.read(&b) }.to yield_with_args 'content'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
describe '#read_all' do
|
22
|
+
it 'reads all the file content' do
|
23
|
+
expect(input.read_all).to eq 'content'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'ftpmvc/async/upload'
|
2
|
+
|
3
|
+
describe FTPMVC::Async::Upload::Job do
|
4
|
+
let(:file) { File.join(FTPMVC::Async::Upload.config.dir, 'my-file') }
|
5
|
+
before do
|
6
|
+
end
|
7
|
+
around do |example|
|
8
|
+
Dir.mktmpdir do |dir|
|
9
|
+
FTPMVC::Async::Upload.configure do
|
10
|
+
config.dir = dir
|
11
|
+
end
|
12
|
+
File.open(file, 'w') { |f| f.write('file content') }
|
13
|
+
example.run
|
14
|
+
end
|
15
|
+
end
|
16
|
+
let(:job) do
|
17
|
+
Class.new do
|
18
|
+
extend FTPMVC::Async::Upload::Job
|
19
|
+
|
20
|
+
def self.perform(path, id)
|
21
|
+
input(id).read_all
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
describe '#after_perform_delete_uploaded_file' do
|
26
|
+
it 'deletes the uploaded file' do
|
27
|
+
job.after_perform_delete_uploaded_file('/Documents/file.txt', 'my-file')
|
28
|
+
expect(File).not_to exist(file)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
describe '#input' do
|
32
|
+
it 'is the file input' do
|
33
|
+
expect(job.perform('/Documents/file.txt', 'my-file')).to eq 'file content'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'resque_spec'
|
3
|
+
require 'ftpmvc/filter/async_upload'
|
4
|
+
require 'ftpmvc/async/upload/job'
|
5
|
+
require 'ftpmvc/async/upload/config'
|
6
|
+
require 'ftpmvc/string_input'
|
7
|
+
|
8
|
+
describe FTPMVC::Filter::AsyncUpload do
|
9
|
+
let(:storage) { Dir.mktmpdir }
|
10
|
+
let(:filter) { FTPMVC::Filter::AsyncUpload.new(nil, nil) }
|
11
|
+
let(:job_class) { Class.new { @queue = :ftpmvc } }
|
12
|
+
before do
|
13
|
+
ResqueSpec.reset!
|
14
|
+
end
|
15
|
+
around do |example|
|
16
|
+
job = job_class
|
17
|
+
Dir.mktmpdir do |dir|
|
18
|
+
FTPMVC::Async::Upload.configure do
|
19
|
+
config.dir = dir
|
20
|
+
config.job = job
|
21
|
+
end
|
22
|
+
example.run
|
23
|
+
end
|
24
|
+
end
|
25
|
+
describe '#put' do
|
26
|
+
it 'writes content to storage' do
|
27
|
+
id = filter.put('/Documents/password.txt', FTPMVC::StringInput.new('mypassword'))
|
28
|
+
expect(File.read(File.join(FTPMVC::Async::Upload::Config.dir, id))).to eq 'mypassword'
|
29
|
+
end
|
30
|
+
it 'enqueues the job' do
|
31
|
+
id = filter.put('/Documents/password.txt', FTPMVC::StringInput.new('mypassword'))
|
32
|
+
expect(job_class).to have_queued('/Documents/password.txt', id).in(:ftpmvc)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ftpmvc-async-upload
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- André Aizim Kelmanson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: vfs
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: resque_spec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: ftpmvc
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.9.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.9.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: resque
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: app
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: FTPMVC asynchronous upload using resque
|
126
|
+
email:
|
127
|
+
- akelmanson@gmail.com
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- .gitignore
|
133
|
+
- .rspec
|
134
|
+
- Gemfile
|
135
|
+
- Guardfile
|
136
|
+
- LICENSE.txt
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- ftpmvc-async-upload.gemspec
|
140
|
+
- lib/ftpmvc/async/upload.rb
|
141
|
+
- lib/ftpmvc/async/upload/config.rb
|
142
|
+
- lib/ftpmvc/async/upload/default_job.rb
|
143
|
+
- lib/ftpmvc/async/upload/input.rb
|
144
|
+
- lib/ftpmvc/async/upload/job.rb
|
145
|
+
- lib/ftpmvc/async/upload/version.rb
|
146
|
+
- lib/ftpmvc/filter/async_upload.rb
|
147
|
+
- spec/integration/async_upload_spec.rb
|
148
|
+
- spec/lib/ftpmvc/async/upload/default_job_spec.rb
|
149
|
+
- spec/lib/ftpmvc/async/upload/input_spec.rb
|
150
|
+
- spec/lib/ftpmvc/async/upload/job_spec.rb
|
151
|
+
- spec/lib/ftpmvc/filter/async_upload_spec.rb
|
152
|
+
homepage: ''
|
153
|
+
licenses:
|
154
|
+
- MIT
|
155
|
+
metadata: {}
|
156
|
+
post_install_message:
|
157
|
+
rdoc_options: []
|
158
|
+
require_paths:
|
159
|
+
- lib
|
160
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
161
|
+
requirements:
|
162
|
+
- - '>='
|
163
|
+
- !ruby/object:Gem::Version
|
164
|
+
version: '0'
|
165
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
+
requirements:
|
167
|
+
- - '>='
|
168
|
+
- !ruby/object:Gem::Version
|
169
|
+
version: '0'
|
170
|
+
requirements: []
|
171
|
+
rubyforge_project:
|
172
|
+
rubygems_version: 2.2.2
|
173
|
+
signing_key:
|
174
|
+
specification_version: 4
|
175
|
+
summary: FTPMVC asynchronous upload using resque
|
176
|
+
test_files:
|
177
|
+
- spec/integration/async_upload_spec.rb
|
178
|
+
- spec/lib/ftpmvc/async/upload/default_job_spec.rb
|
179
|
+
- spec/lib/ftpmvc/async/upload/input_spec.rb
|
180
|
+
- spec/lib/ftpmvc/async/upload/job_spec.rb
|
181
|
+
- spec/lib/ftpmvc/filter/async_upload_spec.rb
|