cortex-plugins-core 0.4.4 → 0.4.5

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: 471ebeda661e5ea49520bf6127a7f5008b6140d8
4
- data.tar.gz: d0e101ae32fa0dc869f7d8dc1500e29cdc51fc75
3
+ metadata.gz: 9ad03faa329368738afd7686e52d7e6f372d8b79
4
+ data.tar.gz: ab0a2bd0e9d66d960fb8523f5112af6743b07b3d
5
5
  SHA512:
6
- metadata.gz: 6d65a8bd96d723dd1e279a5c92c5086a4a3d89605038e36a90cdf9375674117c3e919c8d9f8f6f5b651ae3115dfc4cf68c2105b2418d76d6c7799ec1ac474b46
7
- data.tar.gz: adcafce4dfc7f78226cf388ccddc330b10a00942dda193faac12e7d849c93e8a5e9350ba33a2054bcb27086ab028b5ed401bc5aee33b004a8c7b36395dfb8513
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
- Paperclip::HasAttachedFile.define_on(self.class, :asset, metadata)
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 url
119
- @existing_data.empty? ? asset.url : @existing_data[:asset][:url]
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
@@ -1,7 +1,7 @@
1
1
  module Cortex
2
2
  module Plugins
3
3
  module Core
4
- VERSION = '0.4.4'
4
+ VERSION = '0.4.5'
5
5
  end
6
6
  end
7
7
  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
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-25 00:00:00.000000000 Z
11
+ date: 2016-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails