fclay 1.50.0 → 1.50.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fclay/remote_storage/base.rb +12 -1
- data/lib/fclay/remote_storage/provider.rb +16 -8
- data/lib/fclay/remote_storage/s3.rb +7 -8
- data/lib/fclay/remote_storage/ssh.rb +5 -7
- data/lib/fclay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59e9bfa1ddeacd560f2cd9be91a320f39ceb6e1d
|
4
|
+
data.tar.gz: 86672e2d722d6ef0405f0446d7bfbdf67e9aa830
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8c344aa70a596d22639e9f3dfeec54ead29eeaa7e171ca88b6a2743747d936ee9799031c6be3e200587c6bad672da609f30333a80331a56145041a10e905153
|
7
|
+
data.tar.gz: f9e7aa36e0182185db6a613e16867d345a6ce139e1cc04d5d8e985a7468ef90705062d1d51d8f4ef6452ef27369d8bbedd2970257314ad34ecb784385812ca95
|
@@ -2,6 +2,13 @@ class Fclay::RemoteStorage::Base
|
|
2
2
|
|
3
3
|
attr_accessor :name, :uploading_object, :storage, :options
|
4
4
|
|
5
|
+
def initialize(name, uploading_object)
|
6
|
+
@name = name
|
7
|
+
@uploading_object = uploading_object
|
8
|
+
@storage = get_storage_by_name(name)
|
9
|
+
@options = @uploading_object.class.fclay_options
|
10
|
+
end
|
11
|
+
|
5
12
|
def upload(options = {})
|
6
13
|
uploading_object.update(file_status: 'idle', file_location: name)
|
7
14
|
uploading_object.try(:log, "Sucessful uploaded! file_status: 'idle', file_location: #{name}")
|
@@ -11,7 +18,11 @@ class Fclay::RemoteStorage::Base
|
|
11
18
|
def delete_files
|
12
19
|
end
|
13
20
|
|
14
|
-
def self.url
|
21
|
+
def self.url(name = nil)
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_storage_by_name(name)
|
25
|
+
Fclay.configuration.remote_storages[name]
|
15
26
|
end
|
16
27
|
|
17
28
|
end
|
@@ -4,7 +4,7 @@ require_relative './s3'
|
|
4
4
|
class Fclay::RemoteStorage::Provider
|
5
5
|
|
6
6
|
def self.get_provider_class(storage)
|
7
|
-
case storage
|
7
|
+
case storage[:kind]
|
8
8
|
when 'ssh'
|
9
9
|
Fclay::RemoteStorage::SSH
|
10
10
|
when 's3'
|
@@ -14,9 +14,9 @@ class Fclay::RemoteStorage::Provider
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.provider_for(
|
18
|
-
klass = get_provider_class(
|
19
|
-
klass.new(uploading_object)
|
17
|
+
def self.provider_for(storage_name, uploading_object)
|
18
|
+
klass = get_provider_class(storages_list[storage_name])
|
19
|
+
klass.new(storage_name, uploading_object)
|
20
20
|
end
|
21
21
|
|
22
22
|
|
@@ -32,7 +32,7 @@ class Fclay::RemoteStorage::Provider
|
|
32
32
|
storage.upload(without_update: true)
|
33
33
|
end
|
34
34
|
else
|
35
|
-
storage = provider_for(
|
35
|
+
storage = provider_for(storage_policy, uploading_object)
|
36
36
|
storage.upload
|
37
37
|
end
|
38
38
|
|
@@ -51,14 +51,22 @@ class Fclay::RemoteStorage::Provider
|
|
51
51
|
storage.delete_files
|
52
52
|
end
|
53
53
|
else
|
54
|
-
storage = provider_for(
|
54
|
+
storage = provider_for(storage_policy, model)
|
55
55
|
storage.delete_files
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.remote_file_url(obj, style = nil)
|
60
|
-
klass = get_provider_class(obj.file_location)
|
61
|
-
"#{klass.url}/#{obj.remote_file_path(style)}"
|
60
|
+
klass = get_provider_class(storages_list[obj.file_location])
|
61
|
+
"#{klass.url(obj.file_location)}/#{obj.remote_file_path(style)}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.storages_list
|
65
|
+
Fclay.configuration.remote_storages
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.storage_policy
|
69
|
+
Fclay.configuration.storage_policy
|
62
70
|
end
|
63
71
|
|
64
72
|
end
|
@@ -2,11 +2,9 @@ require_relative './base'
|
|
2
2
|
|
3
3
|
class Fclay::RemoteStorage::S3 < Fclay::RemoteStorage::Base
|
4
4
|
|
5
|
-
def initialize(uploading_object)
|
6
|
-
|
7
|
-
|
8
|
-
@storage = Fclay.configuration.remote_storages['s3']
|
9
|
-
@options = @uploading_object.class.fclay_options
|
5
|
+
def initialize(name, uploading_object)
|
6
|
+
super
|
7
|
+
|
10
8
|
@bucket = Aws::S3::Resource.new.bucket(bucket_name)
|
11
9
|
end
|
12
10
|
|
@@ -33,8 +31,9 @@ class Fclay::RemoteStorage::S3 < Fclay::RemoteStorage::Base
|
|
33
31
|
@bucket.object(uploading_object.remote_file_path(style))
|
34
32
|
end
|
35
33
|
|
36
|
-
def self.url
|
37
|
-
|
34
|
+
def self.url(name = nil)
|
35
|
+
return '' unless name
|
36
|
+
"https://#{Fclay.configuration.remote_storages[name][:bucket]}.s3.amazonaws.com"
|
38
37
|
end
|
39
38
|
|
40
39
|
def content_type
|
@@ -42,7 +41,7 @@ class Fclay::RemoteStorage::S3 < Fclay::RemoteStorage::Base
|
|
42
41
|
end
|
43
42
|
|
44
43
|
def bucket_name
|
45
|
-
Fclay.configuration.remote_storages[
|
44
|
+
Fclay.configuration.remote_storages[name][:bucket]
|
46
45
|
end
|
47
46
|
|
48
47
|
end
|
@@ -2,11 +2,8 @@ require_relative './base'
|
|
2
2
|
|
3
3
|
class Fclay::RemoteStorage::SSH < Fclay::RemoteStorage::Base
|
4
4
|
|
5
|
-
def initialize(uploading_object)
|
6
|
-
|
7
|
-
@uploading_object = uploading_object
|
8
|
-
@storage = Fclay.configuration.remote_storages['ssh']
|
9
|
-
@options = @uploading_object.class.fclay_options
|
5
|
+
def initialize(name, uploading_object)
|
6
|
+
super
|
10
7
|
end
|
11
8
|
|
12
9
|
def upload(options = {})
|
@@ -27,8 +24,9 @@ class Fclay::RemoteStorage::SSH < Fclay::RemoteStorage::Base
|
|
27
24
|
end
|
28
25
|
end
|
29
26
|
|
30
|
-
def self.url
|
31
|
-
|
27
|
+
def self.url(name = nil)
|
28
|
+
return '' unless name
|
29
|
+
opts = Fclay.configuration.remote_storages[name]
|
32
30
|
"https://#{opts[:host]}"
|
33
31
|
end
|
34
32
|
|
data/lib/fclay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fclay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.50.
|
4
|
+
version: 1.50.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Galiev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|