paperweight 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +42 -42
- data/README.md +14 -0
- data/lib/paperweight.rb +1 -0
- data/lib/paperweight/configuration.rb +23 -0
- data/lib/paperweight/download.rb +4 -4
- data/lib/paperweight/version.rb +1 -1
- data/paperweight.gemspec +2 -2
- metadata +12 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9e3211e8bbf5de4d55271d89815de2fb413b8a9702e7ff280771ef2e4dfe944
|
4
|
+
data.tar.gz: f643f81049c0b4accef26b1ba8fd7c26af8030c8315e5656f6039946e52c240b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4099be28ad137adc0307b4e507e25a20d0edfd83c86d13fb2d2b62d50882e0c390e797bc50fa878a9803cc7117c3f4614d01a2d4807d36bdd4a2c848839682c
|
7
|
+
data.tar.gz: ca6ed11cd8f2bd2ad78baec34a7a4aca11d7797dde33dac29dbfb11b88e3b713ed48b715d1579c712fed713e895ec885d6974a9d68cd5314550a538ec5356afa
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.2.0] - 2018-08-15
|
10
|
+
### Added
|
11
|
+
- The ability to configure the `max_size` value (the maximum download size) using the `Paperweight.configure` method.
|
12
|
+
|
13
|
+
[Unreleased]: https://github.com/CultureHQ/client/compare/v0.2.0...HEAD
|
14
|
+
[v0.2.0]: https://github.com/CultureHQ/client/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 (0.
|
5
|
-
paperclip (
|
6
|
-
rails (
|
4
|
+
paperweight (0.2.0)
|
5
|
+
paperclip (>= 5)
|
6
|
+
rails (>= 5)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (5.2.
|
12
|
-
actionpack (= 5.2.
|
11
|
+
actioncable (5.2.1)
|
12
|
+
actionpack (= 5.2.1)
|
13
13
|
nio4r (~> 2.0)
|
14
14
|
websocket-driver (>= 0.6.1)
|
15
|
-
actionmailer (5.2.
|
16
|
-
actionpack (= 5.2.
|
17
|
-
actionview (= 5.2.
|
18
|
-
activejob (= 5.2.
|
15
|
+
actionmailer (5.2.1)
|
16
|
+
actionpack (= 5.2.1)
|
17
|
+
actionview (= 5.2.1)
|
18
|
+
activejob (= 5.2.1)
|
19
19
|
mail (~> 2.5, >= 2.5.4)
|
20
20
|
rails-dom-testing (~> 2.0)
|
21
|
-
actionpack (5.2.
|
22
|
-
actionview (= 5.2.
|
23
|
-
activesupport (= 5.2.
|
21
|
+
actionpack (5.2.1)
|
22
|
+
actionview (= 5.2.1)
|
23
|
+
activesupport (= 5.2.1)
|
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.
|
29
|
-
activesupport (= 5.2.
|
28
|
+
actionview (5.2.1)
|
29
|
+
activesupport (= 5.2.1)
|
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.
|
35
|
-
activesupport (= 5.2.
|
34
|
+
activejob (5.2.1)
|
35
|
+
activesupport (= 5.2.1)
|
36
36
|
globalid (>= 0.3.6)
|
37
|
-
activemodel (5.2.
|
38
|
-
activesupport (= 5.2.
|
39
|
-
activerecord (5.2.
|
40
|
-
activemodel (= 5.2.
|
41
|
-
activesupport (= 5.2.
|
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)
|
42
42
|
arel (>= 9.0)
|
43
|
-
activestorage (5.2.
|
44
|
-
actionpack (= 5.2.
|
45
|
-
activerecord (= 5.2.
|
43
|
+
activestorage (5.2.1)
|
44
|
+
actionpack (= 5.2.1)
|
45
|
+
activerecord (= 5.2.1)
|
46
46
|
marcel (~> 0.3.1)
|
47
|
-
activesupport (5.2.
|
47
|
+
activesupport (5.2.1)
|
48
48
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
49
49
|
i18n (>= 0.7, < 2)
|
50
50
|
minitest (~> 5.1)
|
@@ -59,7 +59,7 @@ GEM
|
|
59
59
|
erubi (1.7.1)
|
60
60
|
globalid (0.4.1)
|
61
61
|
activesupport (>= 4.2.0)
|
62
|
-
i18n (1.0
|
62
|
+
i18n (1.1.0)
|
63
63
|
concurrent-ruby (~> 1.0)
|
64
64
|
jaro_winkler (1.5.1)
|
65
65
|
json (2.1.0)
|
@@ -94,30 +94,30 @@ GEM
|
|
94
94
|
rack (2.0.5)
|
95
95
|
rack-test (1.1.0)
|
96
96
|
rack (>= 1.0, < 3)
|
97
|
-
rails (5.2.
|
98
|
-
actioncable (= 5.2.
|
99
|
-
actionmailer (= 5.2.
|
100
|
-
actionpack (= 5.2.
|
101
|
-
actionview (= 5.2.
|
102
|
-
activejob (= 5.2.
|
103
|
-
activemodel (= 5.2.
|
104
|
-
activerecord (= 5.2.
|
105
|
-
activestorage (= 5.2.
|
106
|
-
activesupport (= 5.2.
|
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)
|
107
107
|
bundler (>= 1.3.0)
|
108
|
-
railties (= 5.2.
|
108
|
+
railties (= 5.2.1)
|
109
109
|
sprockets-rails (>= 2.0.0)
|
110
110
|
rails-dom-testing (2.0.3)
|
111
111
|
activesupport (>= 4.2.0)
|
112
112
|
nokogiri (>= 1.6)
|
113
113
|
rails-html-sanitizer (1.0.4)
|
114
114
|
loofah (~> 2.2, >= 2.2.2)
|
115
|
-
railties (5.2.
|
116
|
-
actionpack (= 5.2.
|
117
|
-
activesupport (= 5.2.
|
115
|
+
railties (5.2.1)
|
116
|
+
actionpack (= 5.2.1)
|
117
|
+
activesupport (= 5.2.1)
|
118
118
|
method_source
|
119
119
|
rake (>= 0.8.7)
|
120
|
-
thor (>= 0.
|
120
|
+
thor (>= 0.19.0, < 2.0)
|
121
121
|
rainbow (3.0.0)
|
122
122
|
rake (12.3.1)
|
123
123
|
rubocop (0.58.2)
|
@@ -128,7 +128,7 @@ GEM
|
|
128
128
|
rainbow (>= 2.2.2, < 4.0)
|
129
129
|
ruby-progressbar (~> 1.7)
|
130
130
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
131
|
-
ruby-progressbar (1.
|
131
|
+
ruby-progressbar (1.10.0)
|
132
132
|
simplecov (0.16.1)
|
133
133
|
docile (~> 1.1)
|
134
134
|
json (>= 1.8, < 3)
|
data/README.md
CHANGED
@@ -57,6 +57,20 @@ end
|
|
57
57
|
|
58
58
|
From now on, updating this attribute will queue a job in the background to update the image later.
|
59
59
|
|
60
|
+
### Configuration
|
61
|
+
|
62
|
+
You can provide additional configuration options through the `Paperweight.configure` method, as in:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
Paperweight.configure do |config|
|
66
|
+
config.max_size = 20 * 1024 * 1024
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
The current configuration options include:
|
71
|
+
|
72
|
+
* `max_size` - defaults to 10 MB
|
73
|
+
|
60
74
|
## Development
|
61
75
|
|
62
76
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/paperweight.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Handles `Paperclip` attachments on the backend in a delayed process.
|
4
|
+
module Paperweight
|
5
|
+
# Allows configuring certain attributes about how to process attachments.
|
6
|
+
class Configuration
|
7
|
+
attr_accessor :max_size
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@max_size = 10 * 1024 * 1024
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class << self
|
15
|
+
def config
|
16
|
+
@config ||= Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure
|
20
|
+
yield config
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/paperweight/download.rb
CHANGED
@@ -13,8 +13,6 @@ module Paperweight
|
|
13
13
|
Error # our errors
|
14
14
|
].freeze
|
15
15
|
|
16
|
-
MAX_SIZE = 10 * 1024 * 1024
|
17
|
-
|
18
16
|
def download(url)
|
19
17
|
# Finally we download the file. Here we mustn't use simple #open that
|
20
18
|
# open-uri overrides, because this is vulnerable to shell execution
|
@@ -52,6 +50,8 @@ module Paperweight
|
|
52
50
|
end
|
53
51
|
|
54
52
|
def open_options
|
53
|
+
max_size = Paperweight.config.max_size
|
54
|
+
|
55
55
|
{}.tap do |options|
|
56
56
|
# It was shown that in a random sample approximately 20% of websites
|
57
57
|
# will simply refuse a request which doesn't have a valid User-Agent.
|
@@ -61,8 +61,8 @@ module Paperweight
|
|
61
61
|
# will call this block as soon as it gets the "Content-Length" header,
|
62
62
|
# which means that we can bail out before we download the file.
|
63
63
|
options[:content_length_proc] = lambda { |size|
|
64
|
-
if size && size >
|
65
|
-
raise Error, "file is too big (max is #{
|
64
|
+
if size && size > max_size
|
65
|
+
raise Error, "file is too big (max is #{max_size})"
|
66
66
|
end
|
67
67
|
}
|
68
68
|
end
|
data/lib/paperweight/version.rb
CHANGED
data/paperweight.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_dependency 'paperclip', '
|
25
|
-
spec.add_dependency 'rails', '
|
24
|
+
spec.add_dependency 'paperclip', '>= 5'
|
25
|
+
spec.add_dependency 'rails', '>= 5'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
28
28
|
spec.add_development_dependency 'minitest', '~> 5.11'
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperweight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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-
|
11
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paperclip
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '5
|
33
|
+
version: '5'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '5
|
40
|
+
version: '5'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- ".gitignore"
|
133
133
|
- ".rubocop.yml"
|
134
134
|
- ".travis.yml"
|
135
|
+
- CHANGELOG.md
|
135
136
|
- Gemfile
|
136
137
|
- Gemfile.lock
|
137
138
|
- LICENSE
|
@@ -140,6 +141,7 @@ files:
|
|
140
141
|
- bin/console
|
141
142
|
- bin/setup
|
142
143
|
- lib/paperweight.rb
|
144
|
+
- lib/paperweight/configuration.rb
|
143
145
|
- lib/paperweight/download.rb
|
144
146
|
- lib/paperweight/hook.rb
|
145
147
|
- lib/paperweight/post_process_job.rb
|