paperweight 1.0.2 → 1.1.0

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: bf350a78eb45871318695fd3a2f6d2d3c4126f7dd3b28140e1012d8141f3479b
4
- data.tar.gz: 0f94872951f119858b46f4e7f5c545dbe1d73fe3b4c31b29e5870529455e28ec
3
+ metadata.gz: 1c3a418afa5d783b26a30c395d25027a6520661087e828d13ae522a57c72d84a
4
+ data.tar.gz: b137292e157766a5ac5bb6c5dd583a05d98cc44ec8f9a40039f65ede48f70d48
5
5
  SHA512:
6
- metadata.gz: 17bebeb321a9ff3fb55233b04a6ac79c1d2931778a616c8080c57ff0a52534604159725f32c248b34d0ee5f223d4ad58c11530a2f40c19798e4042983e2104d8
7
- data.tar.gz: 1c7cab05077be909ed669a7a08b23da19cd40cbc9458cfa27523e90689defae0e798b506baf19c9f84ecd1a9d7e9c53556a10e54c48cdb7b0fac60b404e6a600
6
+ metadata.gz: 334f233a0b66cd999ed338c09c9a77dd28b2866677c9a1935d7e6c33a8a63f9a28daf1d093698a4ee321707d3ac337dafb76cbadb5774d4658d64a71cabfe080
7
+ data.tar.gz: bf8736c8fdcf75f40c8bc52187f5b9c5fd18de0f283acae419ceb3c5bc77eea037f6810c1a78d069216aeb853c7f8b5278a4a7f36683a7529df132ded2da7461
@@ -0,0 +1,40 @@
1
+ workflow "Main" {
2
+ on = "push"
3
+ resolves = "Publish"
4
+ }
5
+
6
+ action "Install" {
7
+ uses = "docker://culturehq/actions-bundler:latest"
8
+ args = "install"
9
+ }
10
+
11
+ action "Audit" {
12
+ needs = "Install"
13
+ uses = "docker://culturehq/actions-bundler:latest"
14
+ args = "exec bundle audit"
15
+ }
16
+
17
+ action "Lint" {
18
+ needs = "Install"
19
+ uses = "docker://culturehq/actions-bundler:latest"
20
+ args = "exec rubocop --parallel"
21
+ }
22
+
23
+ action "Test" {
24
+ needs = "Install"
25
+ uses = "docker://culturehq/actions-bundler:latest"
26
+ args = "exec rake test"
27
+ }
28
+
29
+ action "Tag" {
30
+ needs = ["Audit", "Lint", "Test"]
31
+ uses = "actions/bin/filter@master"
32
+ args = "tag"
33
+ }
34
+
35
+ action "Publish" {
36
+ needs = "Tag"
37
+ uses = "docker://culturehq/actions-bundler:latest"
38
+ args = "build release:rubygem_push"
39
+ secrets = ["BUNDLE_GEM__PUSH_KEY"]
40
+ }
data/.rubocop.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  AllCops:
2
2
  DisplayCopNames: true
3
3
  DisplayStyleGuide: true
4
- TargetRubyVersion: 2.5
4
+ TargetRubyVersion: 2.6
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ 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.1.0] - 2019-01-08
10
+ ### Added
11
+ - Support the `after_download` option on `paperweight`-enabled attachments that takes a callable and calls it when the post process job has completed.
12
+
9
13
  ## [1.0.2] - 2018-09-04
10
14
  ### Changed
11
15
  - Handle the case where an image has been removed or cleared before the post process job executes. In this case the job should bail out before attempting to download the file.
@@ -23,6 +27,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
23
27
  ### Added
24
28
  - The ability to configure the `max_size` value (the maximum download size) using the `Paperweight.configure` method.
25
29
 
26
- [Unreleased]: https://github.com/CultureHQ/client/compare/v0.2.0...HEAD
27
- [v1.0.0]: https://github.com/CultureHQ/client/compare/v0.2.0...v1.0.0
28
- [v0.2.0]: https://github.com/CultureHQ/client/compare/v0.1.2...v0.2.0
30
+ [Unreleased]: https://github.com/CultureHQ/paperweight/compare/v1.1.0...HEAD
31
+ [1.1.0]: https://github.com/CultureHQ/paperweight/compare/v1.0.2...v1.1.0
32
+ [1.0.2]: https://github.com/CultureHQ/paperweight/compare/v1.0.1...v1.0.2
33
+ [1.0.1]: https://github.com/CultureHQ/paperweight/compare/v1.0.0...v1.0.1
34
+ [1.0.0]: https://github.com/CultureHQ/paperweight/compare/v0.2.0...v1.0.0
35
+ [0.2.0]: https://github.com/CultureHQ/paperweight/compare/v0.1.2...v0.2.0
data/Gemfile.lock CHANGED
@@ -1,50 +1,50 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- paperweight (1.0.2)
4
+ paperweight (1.1.0)
5
5
  paperclip (>= 5)
6
6
  rails (>= 5)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (5.2.1)
12
- actionpack (= 5.2.1)
11
+ actioncable (5.2.2)
12
+ actionpack (= 5.2.2)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
- actionmailer (5.2.1)
16
- actionpack (= 5.2.1)
17
- actionview (= 5.2.1)
18
- activejob (= 5.2.1)
15
+ actionmailer (5.2.2)
16
+ actionpack (= 5.2.2)
17
+ actionview (= 5.2.2)
18
+ activejob (= 5.2.2)
19
19
  mail (~> 2.5, >= 2.5.4)
20
20
  rails-dom-testing (~> 2.0)
21
- actionpack (5.2.1)
22
- actionview (= 5.2.1)
23
- activesupport (= 5.2.1)
21
+ actionpack (5.2.2)
22
+ actionview (= 5.2.2)
23
+ activesupport (= 5.2.2)
24
24
  rack (~> 2.0)
25
25
  rack-test (>= 0.6.3)
26
26
  rails-dom-testing (~> 2.0)
27
27
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
- actionview (5.2.1)
29
- activesupport (= 5.2.1)
28
+ actionview (5.2.2)
29
+ activesupport (= 5.2.2)
30
30
  builder (~> 3.1)
31
31
  erubi (~> 1.4)
32
32
  rails-dom-testing (~> 2.0)
33
33
  rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
- activejob (5.2.1)
35
- activesupport (= 5.2.1)
34
+ activejob (5.2.2)
35
+ activesupport (= 5.2.2)
36
36
  globalid (>= 0.3.6)
37
- activemodel (5.2.1)
38
- activesupport (= 5.2.1)
39
- activerecord (5.2.1)
40
- activemodel (= 5.2.1)
41
- activesupport (= 5.2.1)
37
+ activemodel (5.2.2)
38
+ activesupport (= 5.2.2)
39
+ activerecord (5.2.2)
40
+ activemodel (= 5.2.2)
41
+ activesupport (= 5.2.2)
42
42
  arel (>= 9.0)
43
- activestorage (5.2.1)
44
- actionpack (= 5.2.1)
45
- activerecord (= 5.2.1)
43
+ activestorage (5.2.2)
44
+ actionpack (= 5.2.2)
45
+ activerecord (= 5.2.2)
46
46
  marcel (~> 0.3.1)
47
- activesupport (5.2.1)
47
+ activesupport (5.2.2)
48
48
  concurrent-ruby (~> 1.0, >= 1.0.2)
49
49
  i18n (>= 0.7, < 2)
50
50
  minitest (~> 5.1)
@@ -52,35 +52,38 @@ GEM
52
52
  arel (9.0.0)
53
53
  ast (2.4.0)
54
54
  builder (3.2.3)
55
+ bundler-audit (0.6.0)
56
+ bundler (~> 1.2)
57
+ thor (~> 0.18)
55
58
  climate_control (0.2.0)
56
- concurrent-ruby (1.0.5)
59
+ concurrent-ruby (1.1.4)
57
60
  crass (1.0.4)
58
61
  docile (1.3.1)
59
- erubi (1.7.1)
62
+ erubi (1.8.0)
60
63
  globalid (0.4.1)
61
64
  activesupport (>= 4.2.0)
62
- i18n (1.1.0)
65
+ i18n (1.5.1)
63
66
  concurrent-ruby (~> 1.0)
64
- jaro_winkler (1.5.1)
67
+ jaro_winkler (1.5.2)
65
68
  json (2.1.0)
66
- loofah (2.2.2)
69
+ loofah (2.2.3)
67
70
  crass (~> 1.0.2)
68
71
  nokogiri (>= 1.5.9)
69
- mail (2.7.0)
72
+ mail (2.7.1)
70
73
  mini_mime (>= 0.1.1)
71
- marcel (0.3.2)
74
+ marcel (0.3.3)
72
75
  mimemagic (~> 0.3.2)
73
- method_source (0.9.0)
76
+ method_source (0.9.2)
74
77
  mime-types (3.2.2)
75
78
  mime-types-data (~> 3.2015)
76
79
  mime-types-data (3.2018.0812)
77
- mimemagic (0.3.2)
80
+ mimemagic (0.3.3)
78
81
  mini_mime (1.0.1)
79
- mini_portile2 (2.3.0)
82
+ mini_portile2 (2.4.0)
80
83
  minitest (5.11.3)
81
84
  nio4r (2.3.1)
82
- nokogiri (1.8.4)
83
- mini_portile2 (~> 2.3.0)
85
+ nokogiri (1.10.0)
86
+ mini_portile2 (~> 2.4.0)
84
87
  paperclip (6.1.0)
85
88
  activemodel (>= 4.2.0)
86
89
  activesupport (>= 4.2.0)
@@ -88,46 +91,46 @@ GEM
88
91
  mimemagic (~> 0.3.0)
89
92
  terrapin (~> 0.6.0)
90
93
  parallel (1.12.1)
91
- parser (2.5.1.2)
94
+ parser (2.5.3.0)
92
95
  ast (~> 2.4.0)
93
96
  powerpack (0.1.2)
94
- rack (2.0.5)
97
+ rack (2.0.6)
95
98
  rack-test (1.1.0)
96
99
  rack (>= 1.0, < 3)
97
- rails (5.2.1)
98
- actioncable (= 5.2.1)
99
- actionmailer (= 5.2.1)
100
- actionpack (= 5.2.1)
101
- actionview (= 5.2.1)
102
- activejob (= 5.2.1)
103
- activemodel (= 5.2.1)
104
- activerecord (= 5.2.1)
105
- activestorage (= 5.2.1)
106
- activesupport (= 5.2.1)
100
+ rails (5.2.2)
101
+ actioncable (= 5.2.2)
102
+ actionmailer (= 5.2.2)
103
+ actionpack (= 5.2.2)
104
+ actionview (= 5.2.2)
105
+ activejob (= 5.2.2)
106
+ activemodel (= 5.2.2)
107
+ activerecord (= 5.2.2)
108
+ activestorage (= 5.2.2)
109
+ activesupport (= 5.2.2)
107
110
  bundler (>= 1.3.0)
108
- railties (= 5.2.1)
111
+ railties (= 5.2.2)
109
112
  sprockets-rails (>= 2.0.0)
110
113
  rails-dom-testing (2.0.3)
111
114
  activesupport (>= 4.2.0)
112
115
  nokogiri (>= 1.6)
113
116
  rails-html-sanitizer (1.0.4)
114
117
  loofah (~> 2.2, >= 2.2.2)
115
- railties (5.2.1)
116
- actionpack (= 5.2.1)
117
- activesupport (= 5.2.1)
118
+ railties (5.2.2)
119
+ actionpack (= 5.2.2)
120
+ activesupport (= 5.2.2)
118
121
  method_source
119
122
  rake (>= 0.8.7)
120
123
  thor (>= 0.19.0, < 2.0)
121
124
  rainbow (3.0.0)
122
- rake (12.3.1)
123
- rubocop (0.58.2)
125
+ rake (12.3.2)
126
+ rubocop (0.62.0)
124
127
  jaro_winkler (~> 1.5.1)
125
128
  parallel (~> 1.10)
126
129
  parser (>= 2.5, != 2.5.1.1)
127
130
  powerpack (~> 0.1)
128
131
  rainbow (>= 2.2.2, < 4.0)
129
132
  ruby-progressbar (~> 1.7)
130
- unicode-display_width (~> 1.0, >= 1.0.1)
133
+ unicode-display_width (~> 1.4.0)
131
134
  ruby-progressbar (1.10.0)
132
135
  simplecov (0.16.1)
133
136
  docile (~> 1.1)
@@ -144,11 +147,11 @@ GEM
144
147
  sqlite3 (1.3.13)
145
148
  terrapin (0.6.0)
146
149
  climate_control (>= 0.0.3, < 1.0)
147
- thor (0.20.0)
150
+ thor (0.20.3)
148
151
  thread_safe (0.3.6)
149
152
  tzinfo (1.2.5)
150
153
  thread_safe (~> 0.1)
151
- unicode-display_width (1.4.0)
154
+ unicode-display_width (1.4.1)
152
155
  websocket-driver (0.7.0)
153
156
  websocket-extensions (>= 0.1.0)
154
157
  websocket-extensions (0.1.3)
@@ -158,12 +161,13 @@ PLATFORMS
158
161
 
159
162
  DEPENDENCIES
160
163
  bundler (~> 1.16)
164
+ bundler-audit (~> 0.6)
161
165
  minitest (~> 5.11)
162
166
  paperweight!
163
- rake (~> 12.0)
164
- rubocop (~> 0.58)
167
+ rake (~> 12.3)
168
+ rubocop (~> 0.62)
165
169
  simplecov (~> 0.16)
166
170
  sqlite3 (~> 1.3)
167
171
 
168
172
  BUNDLED WITH
169
- 1.16.1
173
+ 1.17.2
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 CultureHQ
3
+ Copyright (c) 2019 CultureHQ
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Paperweight
2
2
 
3
- [![Build Status](https://travis-ci.com/CultureHQ/paperweight.svg?branch=master)](https://travis-ci.com/CultureHQ/paperweight)
3
+ [![Gem Version](https://img.shields.io/gem/v/paperweight.svg)](https://github.com/CultureHQ/paperweight)
4
4
 
5
5
  Handles `Paperclip` attachments on the backend in a delayed process.
6
6
 
data/lib/paperweight.rb CHANGED
@@ -7,6 +7,7 @@ require 'rails'
7
7
 
8
8
  require 'active_job'
9
9
 
10
+ require 'paperweight/attachment_name'
10
11
  require 'paperweight/configuration'
11
12
  require 'paperweight/download'
12
13
  require 'paperweight/hooks'
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Paperweight
4
+ # Converts a parent name to its respective component child names.
5
+ class AttachmentName
6
+ attr_reader :name
7
+
8
+ def initialize(name)
9
+ @name = name
10
+ end
11
+
12
+ def after_download
13
+ :"#{name}_after_download"
14
+ end
15
+
16
+ def processing
17
+ :"#{name}_processing"
18
+ end
19
+
20
+ def updated_at
21
+ :"#{name}_updated_at"
22
+ end
23
+
24
+ def url
25
+ :"#{name}_url"
26
+ end
27
+
28
+ def url_eq
29
+ :"#{name}_url="
30
+ end
31
+
32
+ def url_attr
33
+ :"@#{name}_url"
34
+ end
35
+ end
36
+ end
@@ -6,36 +6,9 @@ module Paperweight
6
6
  # Overrides the `has_attached_file` method from `paperclip` so that
7
7
  # `paperweight` can add extras when the macro is called.
8
8
  module RecordHook
9
- # Converts a parent name to its respective component child names.
10
- class AttachmentName
11
- attr_reader :name
12
-
13
- def initialize(name)
14
- @name = name
15
- end
16
-
17
- def processing
18
- :"#{name}_processing"
19
- end
20
-
21
- def updated_at
22
- :"#{name}_updated_at"
23
- end
24
-
25
- def url
26
- :"#{name}_url"
27
- end
28
-
29
- def url_eq
30
- :"#{name}_url="
31
- end
32
-
33
- def url_attr
34
- :"@#{name}_url"
35
- end
36
- end
37
-
38
- def has_attached_file(name, *) # rubocop:disable Naming/PredicateName
9
+ # rubocop:disable Naming/PredicateName
10
+ def has_attached_file(name, options = {})
11
+ after_download = options.delete(:after_download)
39
12
  super
40
13
 
41
14
  name = AttachmentName.new(name)
@@ -43,7 +16,9 @@ module Paperweight
43
16
 
44
17
  define_paperweight_setter_for(name)
45
18
  define_paperweight_after_commit_for(name)
19
+ define_method(name.after_download, &after_download) if after_download
46
20
  end
21
+ # rubocop:enable Naming/PredicateName
47
22
 
48
23
  private
49
24
 
@@ -53,6 +28,7 @@ module Paperweight
53
28
  self[name.processing] = value
54
29
 
55
30
  return unless value
31
+
56
32
  self[name.updated_at] = Time.now
57
33
  self.updated_at = Time.now
58
34
  end
@@ -8,11 +8,19 @@ module Paperweight
8
8
  discard_on ActiveJob::DeserializationError
9
9
 
10
10
  def perform(model, name)
11
- processing = :"#{name}_processing"
12
- image_url = model.public_send(processing)
11
+ name = AttachmentName.new(name)
12
+ image_url = model.public_send(name.processing)
13
13
 
14
14
  return unless image_url
15
- model.update!(name => Download.download(image_url), processing => nil)
15
+
16
+ model.update!(
17
+ name.name => Download.download(image_url),
18
+ name.processing => nil
19
+ )
20
+
21
+ return unless model.respond_to?(name.after_download)
22
+
23
+ model.public_send(name.after_download)
16
24
  end
17
25
  end
18
26
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paperweight
4
- VERSION = '1.0.2'
4
+ VERSION = '1.1.0'
5
5
  end
data/paperweight.gemspec CHANGED
@@ -25,9 +25,10 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency 'rails', '>= 5'
26
26
 
27
27
  spec.add_development_dependency 'bundler', '~> 1.16'
28
+ spec.add_development_dependency 'bundler-audit', '~> 0.6'
28
29
  spec.add_development_dependency 'minitest', '~> 5.11'
29
- spec.add_development_dependency 'rake', '~> 12.0'
30
- spec.add_development_dependency 'rubocop', '~> 0.58'
30
+ spec.add_development_dependency 'rake', '~> 12.3'
31
+ spec.add_development_dependency 'rubocop', '~> 0.62'
31
32
  spec.add_development_dependency 'simplecov', '~> 0.16'
32
33
  spec.add_development_dependency 'sqlite3', '~> 1.3'
33
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperweight
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Deisz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-04 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paperclip
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler-audit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.6'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: minitest
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +86,28 @@ dependencies:
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '12.0'
89
+ version: '12.3'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '12.0'
96
+ version: '12.3'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: rubocop
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - "~>"
88
102
  - !ruby/object:Gem::Version
89
- version: '0.58'
103
+ version: '0.62'
90
104
  type: :development
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '0.58'
110
+ version: '0.62'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: simplecov
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -129,9 +143,9 @@ executables: []
129
143
  extensions: []
130
144
  extra_rdoc_files: []
131
145
  files:
146
+ - ".github/main.workflow"
132
147
  - ".gitignore"
133
148
  - ".rubocop.yml"
134
- - ".travis.yml"
135
149
  - CHANGELOG.md
136
150
  - Gemfile
137
151
  - Gemfile.lock
@@ -141,6 +155,7 @@ files:
141
155
  - bin/console
142
156
  - bin/setup
143
157
  - lib/paperweight.rb
158
+ - lib/paperweight/attachment_name.rb
144
159
  - lib/paperweight/configuration.rb
145
160
  - lib/paperweight/download.rb
146
161
  - lib/paperweight/hooks.rb
@@ -166,8 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
181
  - !ruby/object:Gem::Version
167
182
  version: '0'
168
183
  requirements: []
169
- rubyforge_project:
170
- rubygems_version: 2.7.6
184
+ rubygems_version: 3.0.1
171
185
  signing_key:
172
186
  specification_version: 4
173
187
  summary: An opinionated Paperclip.
data/.travis.yml DELETED
@@ -1,11 +0,0 @@
1
- language: ruby
2
- rvm: 2.5.1
3
- branches:
4
- only: master
5
- before_install:
6
- - gem update --system
7
- - gem install bundler
8
- cache: bundler
9
- script:
10
- - bundle exec rake
11
- - bundle exec rubocop --parallel