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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4d16aa83af67ced9c2daa7bda886b630efbac50
4
- data.tar.gz: 3efce25971a17375b3d230d0f01314bace8f1d40
3
+ metadata.gz: 9106d3c91ed9719f32498c1608df42581ee3513c
4
+ data.tar.gz: b34134c7bfde63fb148a2277fea2b820199745e9
5
5
  SHA512:
6
- metadata.gz: 8b1bec6195e0840e8a4a8b9dec11d542ac8f029c43571fb7019d82ce4bd3b91b0f2273c89dfdc99b5926fcb58836faf571c75c78a865ca4f71d1b3713dac90e3
7
- data.tar.gz: b212de7f85445b9df146ab92de16cfeb41b1c2d414f9691242b2083b4828e1e4fb6d68c14a279814a70e5cbbb20e46ee7c0143d0a21d77df3495fa3a50e192b3
6
+ metadata.gz: eccd2395fd64cbb404b84650cb8372505fd96d96906b3ef95a0b7f6ae9ecc832f7a3d210ea79113a2a9bf08618d5a837c582456c613401d2748cd5c4855fcaf2
7
+ data.tar.gz: 42154c130421af151240b0525f793141f3baffc300dc5ff426e2073636039b990b440fa14d8f8a627d002c61946538383ddf750296c5b333cfb7fd3217e1d8c5
data/.rubocop.yml ADDED
@@ -0,0 +1,2 @@
1
+ Documentation:
2
+ Enabled: false
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Paperclip::Tus
1
+ # paperclip-tus
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/paperclip/tus`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Build Status](https://travis-ci.org/deees/paperclip-tus.svg?branch=master)](https://travis-ci.org/deees/paperclip-tus)
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
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. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "paperclip/tus"
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 "irb"
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
- unless tus_storage.class == ::Tus::Storage::Filesystem
42
- raise "Paperclip Tus Adapter does not support #{tus_storage.class.name}!" \
43
- "Please set Tus::Server.opts[:storage] to Tus::Storage::Filesystem.new(cache_directory)"
44
- end
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 === target && target =~ Paperclip::Tus::Adapter::REGEXP
57
+ target.is_a?(String) && target =~ Paperclip::Tus::Adapter::REGEXP
57
58
  end
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module Tus
3
- VERSION = "0.1.0"
3
+ VERSION = '0.1.1'.freeze
4
4
  end
5
5
  end
data/lib/paperclip/tus.rb CHANGED
@@ -1,2 +1,2 @@
1
- require "paperclip/tus/version"
2
- require "paperclip/tus/adapter"
1
+ require 'paperclip/tus/version'
2
+ require 'paperclip/tus/adapter'
@@ -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 = "paperclip-tus"
8
+ spec.name = 'paperclip-tus'
8
9
  spec.version = Paperclip::Tus::VERSION
9
- spec.authors = ["Tomas Brazys"]
10
- spec.email = ["tomas.brazys@gmail.com"]
10
+ spec.authors = ['Tomas Brazys']
11
+ spec.email = ['tomas.brazys@gmail.com']
11
12
 
12
- spec.summary = "TUS server adapter for Paperclip"
13
- spec.homepage = "https://github.com/deees/paperclip-tus"
14
- spec.license = "MIT"
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 = "exe"
20
+ spec.bindir = 'exe'
20
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
- spec.require_paths = ["lib"]
22
+ spec.require_paths = ['lib']
22
23
 
23
- spec.add_development_dependency "bundler", "~> 1.14"
24
- spec.add_development_dependency "rake", "~> 10.0"
25
- spec.add_development_dependency "rspec", "~> 3.0"
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 "paperclip", '~> 4.3'
28
- spec.add_runtime_dependency "tus-server", '~> 0.10'
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.0
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-06 00:00:00.000000000 Z
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: TUS server adapter for Paperclip
141
+ summary: tus server adapter for Paperclip
128
142
  test_files: []
data/TODO.txt DELETED
@@ -1,2 +0,0 @@
1
- * README (explain how to use with tus-js-client)
2
- * rubocop