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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0eeef0e576fcbb817bc834920213d877082c62843f67ce5d506d4543faa818d0
4
- data.tar.gz: 9c693fee6737870d4dddc4bfaf1623f00bf49dc69040974920f9772411224084
3
+ metadata.gz: c9e3211e8bbf5de4d55271d89815de2fb413b8a9702e7ff280771ef2e4dfe944
4
+ data.tar.gz: f643f81049c0b4accef26b1ba8fd7c26af8030c8315e5656f6039946e52c240b
5
5
  SHA512:
6
- metadata.gz: 2d70e2977920dab169fbda44dccaa94e9434250438deced9c6c77564292cf7005c1e3fe6302724f7007c603e301c20711ca054e514915ca0e99e44df00f9cfce
7
- data.tar.gz: e70e7bc7cc925360bf476bb24dc56feedd28ced08c348e5a0f123f185df33a5d50ef668f84a167418f2c3276676ac26de16f7dbe92edcfef9209eeefae28f194
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.1.2)
5
- paperclip (~> 6.1)
6
- rails (~> 5.2)
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.0)
12
- actionpack (= 5.2.0)
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.0)
16
- actionpack (= 5.2.0)
17
- actionview (= 5.2.0)
18
- activejob (= 5.2.0)
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.0)
22
- actionview (= 5.2.0)
23
- activesupport (= 5.2.0)
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.0)
29
- activesupport (= 5.2.0)
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.0)
35
- activesupport (= 5.2.0)
34
+ activejob (5.2.1)
35
+ activesupport (= 5.2.1)
36
36
  globalid (>= 0.3.6)
37
- activemodel (5.2.0)
38
- activesupport (= 5.2.0)
39
- activerecord (5.2.0)
40
- activemodel (= 5.2.0)
41
- activesupport (= 5.2.0)
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.0)
44
- actionpack (= 5.2.0)
45
- activerecord (= 5.2.0)
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.0)
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.1)
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.0)
98
- actioncable (= 5.2.0)
99
- actionmailer (= 5.2.0)
100
- actionpack (= 5.2.0)
101
- actionview (= 5.2.0)
102
- activejob (= 5.2.0)
103
- activemodel (= 5.2.0)
104
- activerecord (= 5.2.0)
105
- activestorage (= 5.2.0)
106
- activesupport (= 5.2.0)
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.0)
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.0)
116
- actionpack (= 5.2.0)
117
- activesupport (= 5.2.0)
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.18.1, < 2.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.9.0)
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
@@ -7,6 +7,7 @@ require 'rails'
7
7
 
8
8
  require 'active_job'
9
9
 
10
+ require 'paperweight/configuration'
10
11
  require 'paperweight/download'
11
12
  require 'paperweight/hook'
12
13
  require 'paperweight/post_process_job'
@@ -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
@@ -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 > MAX_SIZE
65
- raise Error, "file is too big (max is #{MAX_SIZE})"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paperweight
4
- VERSION = '0.1.2'
4
+ VERSION = '0.2.0'
5
5
  end
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', '~> 6.1'
25
- spec.add_dependency 'rails', '~> 5.2'
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.1.2
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-07-28 00:00:00.000000000 Z
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: '6.1'
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: '6.1'
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.2'
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.2'
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