paperclip-tus 0.1.0 → 0.1.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 +4 -4
- data/.rubocop.yml +2 -0
- data/README.md +31 -7
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/lib/paperclip/tus/adapter.rb +6 -5
- data/lib/paperclip/tus/version.rb +1 -1
- data/lib/paperclip/tus.rb +2 -2
- data/paperclip-tus.gemspec +15 -13
- metadata +18 -4
- data/TODO.txt +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9106d3c91ed9719f32498c1608df42581ee3513c
|
4
|
+
data.tar.gz: b34134c7bfde63fb148a2277fea2b820199745e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eccd2395fd64cbb404b84650cb8372505fd96d96906b3ef95a0b7f6ae9ecc832f7a3d210ea79113a2a9bf08618d5a837c582456c613401d2748cd5c4855fcaf2
|
7
|
+
data.tar.gz: 42154c130421af151240b0525f793141f3baffc300dc5ff426e2073636039b990b440fa14d8f8a627d002c61946538383ddf750296c5b333cfb7fd3217e1d8c5
|
data/.rubocop.yml
ADDED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# paperclip-tus
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/deees/paperclip-tus)
|
4
4
|
|
5
|
-
|
5
|
+
paperclip-tus is paperclip io adapter for [tus-ruby-server](https://github.com/janko-m/tus-ruby-server).
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,19 +22,43 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
First, make sure you [configure tus ruby server](https://github.com/janko-m/tus-ruby-server/blob/master/README.md#usage) correctly.
|
26
|
+
Only `Tus::Storage::Filesystem` storage is supported at the moment.
|
27
|
+
|
28
|
+
Then, you need [tus-js-client](https://github.com/tus/tus-js-client). Set it up similar to [this example](https://github.com/tus/tus-js-client/blob/master/README.md#example).
|
29
|
+
It's recommended to add `metadata` to `tus.Upload` `options` (to make sure names of uploaded files can be retrieved by the adapter):
|
30
|
+
```
|
31
|
+
var upload = new tus.Upload(file, {
|
32
|
+
endpoint: ...,
|
33
|
+
metadata: { filename: file.name },
|
34
|
+
...
|
35
|
+
```
|
36
|
+
|
37
|
+
Next, in `onSuccess` callback, you should extract file uid and submit it as `has_attached_file` attribute.
|
38
|
+
Uid can be extracted from url:
|
39
|
+
```
|
40
|
+
var upload = new tus.Upload(file, {
|
41
|
+
...
|
42
|
+
onSuccess: function() {
|
43
|
+
var url_parts = upload.url.split('/')
|
44
|
+
# get last part of url
|
45
|
+
var uid = url_parts[url_parts.length - 1]
|
46
|
+
... [assign uid to attachment attribute]..
|
47
|
+
}
|
48
|
+
...
|
49
|
+
```
|
26
50
|
|
27
51
|
## Development
|
28
52
|
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
53
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
|
54
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
55
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
56
|
+
To install this gem onto your local machine, run `bundle exec rake install:local`.
|
32
57
|
|
33
58
|
## Contributing
|
34
59
|
|
35
60
|
Bug reports and pull requests are welcome on GitHub at https://github.com/deees/paperclip-tus.
|
36
61
|
|
37
|
-
|
38
62
|
## License
|
39
63
|
|
40
64
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'paperclip/tus'
|
5
5
|
|
6
6
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +10,5 @@ require "paperclip/tus"
|
|
10
10
|
# require "pry"
|
11
11
|
# Pry.start
|
12
12
|
|
13
|
-
require
|
13
|
+
require 'irb'
|
14
14
|
IRB.start(__FILE__)
|
@@ -38,10 +38,11 @@ module Paperclip
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def ensure_tus_filesystem_storage!
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
return if tus_storage.class == ::Tus::Storage::Filesystem
|
42
|
+
|
43
|
+
raise 'Paperclip tus adapter does not support ' \
|
44
|
+
"#{tus_storage.class.name}! Please set Tus::Server.opts[:storage] " \
|
45
|
+
'to Tus::Storage::Filesystem.new(cache_directory)'
|
45
46
|
end
|
46
47
|
|
47
48
|
def copy_to_tempfile(src_path)
|
@@ -53,5 +54,5 @@ module Paperclip
|
|
53
54
|
end
|
54
55
|
|
55
56
|
Paperclip.io_adapters.register Paperclip::Tus::Adapter do |target|
|
56
|
-
String
|
57
|
+
target.is_a?(String) && target =~ Paperclip::Tus::Adapter::REGEXP
|
57
58
|
end
|
data/lib/paperclip/tus.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'paperclip/tus/version'
|
2
|
+
require 'paperclip/tus/adapter'
|
data/paperclip-tus.gemspec
CHANGED
@@ -1,29 +1,31 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'paperclip/tus/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'paperclip-tus'
|
8
9
|
spec.version = Paperclip::Tus::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
10
|
+
spec.authors = ['Tomas Brazys']
|
11
|
+
spec.email = ['tomas.brazys@gmail.com']
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.summary = 'tus server adapter for Paperclip'
|
14
|
+
spec.homepage = 'https://github.com/deees/paperclip-tus'
|
15
|
+
spec.license = 'MIT'
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
18
|
f.match(%r{^(test|spec|features)/})
|
18
19
|
end
|
19
|
-
spec.bindir =
|
20
|
+
spec.bindir = 'exe'
|
20
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
-
spec.require_paths = [
|
22
|
+
spec.require_paths = ['lib']
|
22
23
|
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'rubocop'
|
26
28
|
|
27
|
-
spec.add_runtime_dependency
|
28
|
-
spec.add_runtime_dependency
|
29
|
+
spec.add_runtime_dependency 'paperclip', '~> 4.3'
|
30
|
+
spec.add_runtime_dependency 'tus-server', '~> 0.10'
|
29
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-tus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Brazys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
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'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: paperclip
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,12 +103,12 @@ extra_rdoc_files: []
|
|
89
103
|
files:
|
90
104
|
- ".gitignore"
|
91
105
|
- ".rspec"
|
106
|
+
- ".rubocop.yml"
|
92
107
|
- ".travis.yml"
|
93
108
|
- Gemfile
|
94
109
|
- LICENSE.txt
|
95
110
|
- README.md
|
96
111
|
- Rakefile
|
97
|
-
- TODO.txt
|
98
112
|
- bin/console
|
99
113
|
- bin/setup
|
100
114
|
- lib/paperclip/tus.rb
|
@@ -124,5 +138,5 @@ rubyforge_project:
|
|
124
138
|
rubygems_version: 2.6.10
|
125
139
|
signing_key:
|
126
140
|
specification_version: 4
|
127
|
-
summary:
|
141
|
+
summary: tus server adapter for Paperclip
|
128
142
|
test_files: []
|
data/TODO.txt
DELETED