paperweight 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/paperweight/hooks.rb +17 -4
- data/lib/paperweight/post_process_job.rb +5 -3
- data/lib/paperweight/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ccf0600d57412d8ff22d523c1a5b935e2c770bc78f95de0ec310891864ac791
|
4
|
+
data.tar.gz: 061342fbdaf7d07e4623a9daa999f973395ca28f4ecc80a2aef1c262db7acd67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d471be00f0029ccfa2a7138d7ba353e56d117afc4926acae8510287793bd9335fb0d503d250cbbf89f25f59bb5fc71a90dd3c34480f0017999450cf6089d262
|
7
|
+
data.tar.gz: be97b3029bb54200f8e815645c55b71452c95137d2c47f6b9ce0dcef50e3be9ac17e6b0a0b560cbc4618451f3f8843bfa2acca990017b19ade0853020a76b47e
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [1.0.1] - 2018-08-15
|
10
|
+
### Changed
|
11
|
+
- Fixed `paperweight` to not break `paperclip` functionality when a record does not contain the `#*_processing` column.
|
12
|
+
- Simplified the post processing job to not require sending the URL manually, instead we can just use the record itself. This guaruntees that if the URL changes between the time the job is enqueued and the time the job is completed we don't end up with race conditions.
|
13
|
+
|
9
14
|
## [1.0.0] - 2018-08-15
|
10
15
|
### Changed
|
11
16
|
- Changed the expected column type of `#*_processing` from a boolean to string. This allows us to use it to store the URL from the `#*_url=` method so that it can be used in the meantime before the job finishes processing.
|
data/Gemfile.lock
CHANGED
data/lib/paperweight/hooks.rb
CHANGED
@@ -18,6 +18,10 @@ module Paperweight
|
|
18
18
|
:"#{name}_processing"
|
19
19
|
end
|
20
20
|
|
21
|
+
def updated_at
|
22
|
+
:"#{name}_updated_at"
|
23
|
+
end
|
24
|
+
|
21
25
|
def url
|
22
26
|
:"#{name}_url"
|
23
27
|
end
|
@@ -47,14 +51,16 @@ module Paperweight
|
|
47
51
|
define_method(name.url_eq) do |value|
|
48
52
|
instance_variable_set(name.url_attr, value)
|
49
53
|
self[name.processing] = value
|
50
|
-
|
54
|
+
|
55
|
+
return unless value
|
56
|
+
self[name.updated_at] = Time.now
|
57
|
+
self.updated_at = Time.now
|
51
58
|
end
|
52
59
|
end
|
53
60
|
|
54
61
|
def define_paperweight_after_commit_for(name)
|
55
62
|
after_commit if: name.url do
|
56
|
-
|
57
|
-
PostProcessJob.perform_later(self, name.name.to_s, attachment_url)
|
63
|
+
PostProcessJob.perform_later(self, name.name.to_s)
|
58
64
|
end
|
59
65
|
end
|
60
66
|
end
|
@@ -63,7 +69,14 @@ module Paperweight
|
|
63
69
|
# check the `image_processing` field and use that if it's still processing.
|
64
70
|
module AttachmentHook
|
65
71
|
def url(*)
|
66
|
-
|
72
|
+
processing_url || super
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def processing_url
|
78
|
+
attribute = :"#{name}_processing"
|
79
|
+
instance.has_attribute?(attribute) && instance.public_send(attribute)
|
67
80
|
end
|
68
81
|
end
|
69
82
|
end
|
@@ -7,9 +7,11 @@ module Paperweight
|
|
7
7
|
|
8
8
|
discard_on ActiveJob::DeserializationError
|
9
9
|
|
10
|
-
def perform(model, name
|
11
|
-
|
12
|
-
|
10
|
+
def perform(model, name)
|
11
|
+
processing = :"#{name}_processing"
|
12
|
+
|
13
|
+
tempfile = Download.new.download(model.public_send(processing))
|
14
|
+
model.update!(name => tempfile, processing => nil)
|
13
15
|
end
|
14
16
|
end
|
15
17
|
end
|
data/lib/paperweight/version.rb
CHANGED