shrine-url 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d6f4cb4622bcb4d935b7b86b9888ee7c32079053
4
+ data.tar.gz: 1b0f0d88c06a9da86dfd9031db7da73b33c65f32
5
+ SHA512:
6
+ metadata.gz: 9a3ac0a1d66ed189d42e185407e2a97971faeb5b792c91c979b2b03c99a29aaaae08f337b1e04d913a5a0ebcec36b0077afb379bb67e25fbb7d2ddf344b616d2
7
+ data.tar.gz: 0be5d02f2b146a9dbe9f26bb9aabbcc24b91136bc57e2e359e1c0b3d4be8ff1d24aeeead115321aaa2449ddb1cc281073e014d307d360041f403a028fdc9999c
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Janko Marohnić
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Shrine::Storage::Url
2
+
3
+ Provides a fake storage which allows you to create a Shrine attachment defined
4
+ only by a custom URL.
5
+
6
+ ## Installation
7
+
8
+ ```ruby
9
+ gem "shrine-url"
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ The representation of the uploaded file assumes that the ID will be a custom
15
+ URL:
16
+
17
+ ```rb
18
+ {
19
+ id: "http://example.com/image.jpg",
20
+ storage: "url",
21
+ metadata: {}
22
+ }
23
+ ```
24
+
25
+ This is used in [shrine-transloadit] for direct uploads, where a temporary URL
26
+ of the uploaded file is returned, and we want to use that URL for further
27
+ processing, eventually replacing the attachment with permanent files.
28
+
29
+ ## Contributing
30
+
31
+ ```sh
32
+ $ rake test
33
+ ```
34
+
35
+ ## License
36
+
37
+ [MIT](/LICENSE.txt)
38
+
39
+ [shrine-transloadit]: https://github.com/janko-m/shrine-transloadit
@@ -0,0 +1,40 @@
1
+ require "shrine"
2
+ require "down"
3
+ require "net/http"
4
+
5
+ class Shrine
6
+ module Storage
7
+ class Url
8
+ def upload(io, id, **)
9
+ id.replace(io.url)
10
+ end
11
+
12
+ def download(id)
13
+ Down.download(id)
14
+ end
15
+
16
+ def open(id)
17
+ Down.open(id)
18
+ end
19
+
20
+ def exists?(id)
21
+ response = nil
22
+ uri = URI(id)
23
+ Net::HTTP.start(uri.host, uri.port) { |http| response = http.head(id) }
24
+ response.code.to_i == 200
25
+ end
26
+
27
+ def url(id, **options)
28
+ id
29
+ end
30
+
31
+ def delete(id)
32
+ # noop
33
+ end
34
+
35
+ def clear!
36
+ # noop
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,21 @@
1
+ Gem::Specification.new do |gem|
2
+ gem.name = "shrine-url"
3
+ gem.version = "0.1.0"
4
+
5
+ gem.required_ruby_version = ">= 2.1"
6
+
7
+ gem.summary = "Provides a fake storage which allows you to create a Shrine attachment defined only by a custom URL."
8
+ gem.homepage = "https://github.com/janko-m/shrine-url"
9
+ gem.authors = ["Janko Marohnić"]
10
+ gem.email = ["janko.marohnic@gmail.com"]
11
+ gem.license = "MIT"
12
+
13
+ gem.files = Dir["README.md", "LICENSE.txt", "lib/**/*.rb", "*.gemspec"]
14
+ gem.require_path = "lib"
15
+
16
+ gem.add_dependency "shrine", ">= 2.0"
17
+ gem.add_dependency "down", ">= 2.3.3"
18
+
19
+ gem.add_development_dependency "rake"
20
+ gem.add_development_dependency "minitest"
21
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shrine-url
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Janko Marohnić
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: shrine
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: down
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.3.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
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: minitest
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
+ description:
70
+ email:
71
+ - janko.marohnic@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - LICENSE.txt
77
+ - README.md
78
+ - lib/shrine/storage/url.rb
79
+ - shrine-url.gemspec
80
+ homepage: https://github.com/janko-m/shrine-url
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '2.1'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 2.5.1
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Provides a fake storage which allows you to create a Shrine attachment defined
104
+ only by a custom URL.
105
+ test_files: []
106
+ has_rdoc: