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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f08760e0f79a70c76350131c65de6fcca3ed7a3366eeb3893d1f64b817ede4ee
4
- data.tar.gz: 42df1435f059aab276345f12fac1c35fdce71b9bf237bd73163fa4ef3d87c5df
3
+ metadata.gz: 1ccf0600d57412d8ff22d523c1a5b935e2c770bc78f95de0ec310891864ac791
4
+ data.tar.gz: 061342fbdaf7d07e4623a9daa999f973395ca28f4ecc80a2aef1c262db7acd67
5
5
  SHA512:
6
- metadata.gz: 54348c7ce20c685556a8ad1aad6e8c62abee2916091f5120cdfa4c266c5a3790ecd0a0234ec3e18a7218fb2c402aaef20b0b4484d3363dbee7ae12acdf1aec76
7
- data.tar.gz: 1176e2de7cab6b5d0f8eea6e76fbfad435cc2d06fcacb633286db19c56e3937cfbf0dcdde2d19b5ab43dadbd447c461d009a3cad0e8be13796a05917d0a48692
6
+ metadata.gz: 3d471be00f0029ccfa2a7138d7ba353e56d117afc4926acae8510287793bd9335fb0d503d250cbbf89f25f59bb5fc71a90dd3c34480f0017999450cf6089d262
7
+ data.tar.gz: be97b3029bb54200f8e815645c55b71452c95137d2c47f6b9ce0dcef50e3be9ac17e6b0a0b560cbc4618451f3f8843bfa2acca990017b19ade0853020a76b47e
@@ -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.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paperweight (1.0.0)
4
+ paperweight (1.0.1)
5
5
  paperclip (>= 5)
6
6
  rails (>= 5)
7
7
 
@@ -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
- self.updated_at = Time.now if value
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
- attachment_url = public_send(name.url)
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
- instance.public_send(:"#{name}_processing") || super
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, url)
11
- tempfile = Download.new.download(url)
12
- model.update!(name => tempfile, :"#{name}_processing" => nil)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paperweight
4
- VERSION = '1.0.0'
4
+ VERSION = '1.0.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperweight
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Deisz