fclay 1.50.0 → 1.50.2

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: 0cd4d68a9d0de6f8479283f6dd5abb91ef0322ed
4
- data.tar.gz: b1f5fb353758cc9dd143421f670ae745492489fc
3
+ metadata.gz: 59e9bfa1ddeacd560f2cd9be91a320f39ceb6e1d
4
+ data.tar.gz: 86672e2d722d6ef0405f0446d7bfbdf67e9aa830
5
5
  SHA512:
6
- metadata.gz: 527bae9df327302246fda7d59fd1c0c1fa0b3bde9e79d752acf06b811e48f93fd37ffc32644ae13d66993478038864ac679e553306d39b06166bbc14d1e8fe7a
7
- data.tar.gz: 011fd5a2a2d059637686282f7e6d7cd2f7e800414d48d5a1a29fedded072458b0a642849bae89a0fc86144ec1eeb9d2909e2bd310a5013d3205eab2ee9616738
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(storage, uploading_object)
18
- klass = get_provider_class(storage)
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(Fclay.configuration.storage_policy, uploading_object)
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(Fclay.configuration.storage_policy, model)
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
- @name = 's3'
7
- @uploading_object = uploading_object
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
- "https://#{Fclay.configuration.remote_storages['s3'][:bucket]}.s3.amazonaws.com"
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['s3'][:bucket]
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
- @name = 'ssh'
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
- opts = Fclay.configuration.remote_storages['ssh']
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
 
@@ -1,3 +1,3 @@
1
1
  module Fclay
2
- VERSION = "1.50.0"
2
+ VERSION = "1.50.2"
3
3
  end
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.0
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-12 00:00:00.000000000 Z
11
+ date: 2019-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler