cortex-plugins-core 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/asset_field_type.rb +19 -5
- data/lib/cortex/plugins/core/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: 9ad03faa329368738afd7686e52d7e6f372d8b79
|
4
|
+
data.tar.gz: ab0a2bd0e9d66d960fb8523f5112af6743b07b3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28a8bef94abea9e65bd54ea129ca375b2d976ad6221d46325df071cbafe66b5b91a77cfb74c06bc4da16e32f4f3acb52c9eeccb325984655fec90c18f0cf1891
|
7
|
+
data.tar.gz: 9ab399e6f59acf27a72db85da70c6263ed649495e4a665a1188b32e0de1391879ad00bcc0c543fd192d155656ad855153554eb0884ab8988270608ec5df28ea3
|
@@ -16,11 +16,11 @@ class AssetFieldType < FieldType
|
|
16
16
|
|
17
17
|
def metadata=(metadata_hash)
|
18
18
|
@metadata = metadata_hash.deep_symbolize_keys
|
19
|
-
|
19
|
+
@existing_data = metadata_hash[:existing_data]
|
20
|
+
Paperclip::HasAttachedFile.define_on(self.class, :asset, existing_metadata)
|
20
21
|
end
|
21
22
|
|
22
23
|
def data=(data_hash)
|
23
|
-
@existing_data = data_hash.deep_symbolize_keys[:existing_data]
|
24
24
|
self.asset = data_hash.deep_symbolize_keys[:asset]
|
25
25
|
end
|
26
26
|
|
@@ -28,7 +28,7 @@ class AssetFieldType < FieldType
|
|
28
28
|
{
|
29
29
|
'asset': {
|
30
30
|
'file_name': asset_file_name,
|
31
|
-
'url': url,
|
31
|
+
'url': asset.url,
|
32
32
|
'dimensions': dimensions,
|
33
33
|
'content_type': asset_content_type,
|
34
34
|
'file_size': asset_file_size,
|
@@ -115,7 +115,21 @@ class AssetFieldType < FieldType
|
|
115
115
|
attachment_content_type_validator.validate_each(self, :asset, asset)
|
116
116
|
end
|
117
117
|
|
118
|
-
def
|
119
|
-
|
118
|
+
def existing_metadata
|
119
|
+
metadata.except!(:existing_data)
|
120
|
+
|
121
|
+
unless @existing_data.empty?
|
122
|
+
metadata[:path] = updated_url(@existing_data['asset']['url'])
|
123
|
+
end
|
124
|
+
|
125
|
+
metadata
|
126
|
+
end
|
127
|
+
|
128
|
+
def updated_url(path)
|
129
|
+
# Take the parse path of the existing URL and drop the first '/',
|
130
|
+
# that will be added later and we don't want to duplicate it
|
131
|
+
# Then remove the old file extension and replace it with the paperclipp'd new one
|
132
|
+
new_path = URI.parse(path).path.slice(1..-1)
|
133
|
+
new_path.gsub(File.extname(path), ".:extension")
|
120
134
|
end
|
121
135
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cortex-plugins-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CareerBuilder Employer Site & Content Products
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|