carrierwave_direct 1.0.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b64419d902b8c1afba920fafe9a7029dd4c3d94a
4
- data.tar.gz: 5dfbb28ea14db2c7ae9bd665192c009534cbef90
3
+ metadata.gz: 2e621e1fb10f3bba48a832af319f33b716bd776f
4
+ data.tar.gz: 23229444c9b6dd113103e936540595ce02043a85
5
5
  SHA512:
6
- metadata.gz: c8f39ac6ced22656b3a96821356d92333f9ca141f215bb66125b3d2a8fa282718341adb133b0baa33308f9268cf1ef2014e59e3e21bb1f7949a389f170b4c1be
7
- data.tar.gz: b2e2fe378dfed399fc011fb4ebcb8a94d5d4ffe4cb4c982ed71b918aa53fa7767a1b1c6d226e6fda5ad2169af24af2a43c83b80b300650367ad49aa0e6faa9d6
6
+ metadata.gz: d3aba2a7b886f6d49d29dc76be5a0de541809dc3056da4c56bf7c93cf35b5437f3b231cbed14b45773f024fcfbddcd08c27e771369a238ba442da780177db5c3
7
+ data.tar.gz: 50b38cd5b7fe29eb7c0037390e712f3618ec68eb8e28d491bd2b0b9097c45b581698ff6e9573507cefa1aa58431a2900f92adf593ded249c87cd972b2936e6d7
data/.travis.yml CHANGED
@@ -1,12 +1,14 @@
1
1
  rvm:
2
- - 2.3.0
3
- - 2.4.0
4
- - 2.5.0
2
+ - 2.3
3
+ - 2.4
4
+ - 2.5
5
+
5
6
  script: 'bundle exec rspec spec'
6
7
  gemfile:
7
8
  - Gemfile
8
9
  - gemfiles/4.2.gemfile
9
10
  - gemfiles/5.1.gemfile
11
+
10
12
  # Move to containerized travis, see http://docs.travis-ci.com/user/migrating-from-legacy
11
13
  sudo: false
12
14
  cache: bundler
data/Changelog.md CHANGED
@@ -1,8 +1,27 @@
1
+ ### 2.0.0
2
+
3
+ Features:
4
+ * [BREAKING CHANGE] Add support for Carrierwave 1.x. Drops support for Carrierwave < 1.0 (Kevin Reintjes @kreintjes).
5
+
6
+ Misc:
7
+ * Dropped support for ruby 2.0 and 2.1, they have [reached their end of life](https://www.ruby-lang.org/en/news/2017/04/01/support-of-ruby-2-1-has-ended/)
8
+ * Update Ruby and Rails versions for Travis so builds succeed once again (Kevin Reintjes @kreintjes)
9
+
10
+ ### 1.1.0
11
+
12
+ Deprecations:
13
+ * Calling `direct_for_url` with `:with_path` is deprecated, please use `url` instead.
14
+
1
15
  ### 1.0.0
2
16
 
3
17
  Features:
4
18
  * Upgraded signing algorithm to use [AWS V4 POST authentication](http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-authentication-HTTPPOST.html). This is a breaking change if you are constructing your own upload forms or submitting your own POST requests. See the Sinatra section of the README for a summary of the new fields required in your V4 POST request. (Fran Worley @fran-worley)
5
19
 
20
+ ### 0.0.17
21
+
22
+ Misc:
23
+ * Pin carrierwave to 0.11
24
+
6
25
  ### 0.0.16
7
26
 
8
27
  Bug Fixes:
data/README.md CHANGED
@@ -280,7 +280,7 @@ If your upload was successful then you will be redirected to the `success_action
280
280
 
281
281
  The `key` is the most important piece of information as we can use it for validating the file extension, downloading the file from S3, processing it and re-uploading it.
282
282
 
283
- If you're using ActiveRecord, CarrierWaveDirect will by default validate the file extension based off your `extension_white_list` in your uploader. See the [CarrierWave readme](https://github.com/jnicklas/carrierwave) for more info. You can then use the helper `filename_valid?` to check if the filename is valid. e.g.
283
+ If you're using ActiveRecord, CarrierWaveDirect will by default validate the file extension based off your `extension_whitelist` in your uploader. See the [CarrierWave readme](https://github.com/jnicklas/carrierwave) for more info. You can then use the helper `filename_valid?` to check if the filename is valid. e.g.
284
284
 
285
285
  ```ruby
286
286
  class UsersController < ApplicationController
@@ -326,7 +326,7 @@ Now that the basic building blocks are in place you can process and save your av
326
326
  class User < ActiveRecord::Base
327
327
  def save_and_process_avatar(options = {})
328
328
  if options[:now]
329
- self.remote_avatar_url = avatar.direct_fog_url(:with_path => true)
329
+ self.remote_avatar_url = avatar.url
330
330
  save
331
331
  else
332
332
  Resque.enqueue(AvatarProcessor, attributes)
@@ -399,13 +399,13 @@ Validates that the filename in the database is unique. Turned *on* by default
399
399
  validates :avatar, :filename_format => true
400
400
  ```
401
401
 
402
- Validates that the uploaded filename is valid. As well as validating the extension against the `extension_white_list` it also validates that the `upload_dir` is correct. Turned *on* by default
402
+ Validates that the uploaded filename is valid. As well as validating the extension against the `extension_whitelist` it also validates that the `upload_dir` is correct. Turned *on* by default
403
403
 
404
404
  ```ruby
405
405
  validates :avatar, :remote_net_url_format => true
406
406
  ```
407
407
 
408
- Validates that the remote net url is valid. As well as validating the extension against the `extension_white_list` it also validates that url is valid and has only the schemes specified in the `url_scheme_whitelist`. Turned *on* by default
408
+ Validates that the remote net url is valid. As well as validating the extension against the `extension_whitelist` it also validates that url is valid and has only the schemes specified in the `url_scheme_whitelist`. Turned *on* by default
409
409
 
410
410
  ## Configuration
411
411
 
@@ -521,7 +521,7 @@ Factory.define :user |f|
521
521
  end
522
522
  ```
523
523
 
524
- This will return a valid key based off your `upload_dir` and your `extension_white_list`
524
+ This will return a valid key based off your `upload_dir` and your `extension_whitelist`
525
525
 
526
526
  ### Faking a background download
527
527
 
@@ -534,7 +534,7 @@ upload_path = find_upload_path
534
534
  redirect_key = sample_key(:base => find_key, :filename => File.basename(upload_path))
535
535
 
536
536
  uploader.key = redirect_key
537
- download_url = uploader.direct_fog_url(:with_path => true)
537
+ download_url = uploader.url
538
538
 
539
539
  # Register the download url and return the uploaded file in the body
540
540
  FakeWeb.register_uri(:get, download_url, :body => File.open(upload_path))
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.rubyforge_project = "carrierwave_direct"
16
16
 
17
- s.add_dependency "carrierwave", "~>0.11"
17
+ s.add_dependency "carrierwave", '>= 1.0.0'
18
18
  s.add_dependency "fog-aws"
19
19
 
20
20
  s.add_development_dependency "rspec"
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency "rails", ">= 3.2.12"
23
23
  s.add_development_dependency "sqlite3"
24
24
  s.add_development_dependency "capybara"
25
+ s.add_development_dependency "byebug"
25
26
 
26
27
  s.files = `git ls-files`.split("\n")
27
28
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
data/gemfiles/4.2.gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "carrierwave", "~>0.11"
3
+ gem "carrierwave"
4
4
  gem "fog-aws"
5
5
 
6
6
  group :test do
data/gemfiles/5.1.gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- gem "carrierwave", "~>0.11"
3
+ gem "carrierwave"
4
4
  gem "fog-aws"
5
5
 
6
6
  group :test do
@@ -18,7 +18,7 @@ module CarrierWaveDirect
18
18
  options = args.extract_options!
19
19
 
20
20
  html_options = {
21
- :multipart => true
21
+ :multipart => true
22
22
  }.update(options[:html] || {})
23
23
 
24
24
  form_for(
@@ -18,7 +18,7 @@ module CarrierWaveDirect
18
18
  options[:filename] = filename_parts.join(".")
19
19
  end
20
20
  options[:filename] ||= "filename"
21
- valid_extension = uploader.extension_white_list.first if uploader.extension_white_list
21
+ valid_extension = uploader.extension_whitelist.first if uploader.extension_whitelist
22
22
  options[:extension] = options[:extension] ? options[:extension].gsub(".", "") : (valid_extension || "extension")
23
23
  key = options[:base].split("/")
24
24
  key.pop
@@ -109,7 +109,7 @@ module CarrierWaveDirect
109
109
  end
110
110
 
111
111
  def extension_regexp
112
- allowed_file_types = extension_white_list
112
+ allowed_file_types = extension_whitelist
113
113
  extension_regexp = allowed_file_types.present? && allowed_file_types.any? ? "(#{allowed_file_types.join("|")})" : "\\w+"
114
114
  end
115
115
 
@@ -4,6 +4,7 @@ module CarrierWaveDirect
4
4
 
5
5
  def direct_fog_url(options = {})
6
6
  if options[:with_path]
7
+ warn "calling `#direct_for_url` with :with_path is deprecated, please use `#url` instead."
7
8
  url
8
9
  else
9
10
  CarrierWave::Storage::Fog::File.new(self, CarrierWave::Storage::Fog.new(self), nil).public_url
@@ -23,7 +23,7 @@ module CarrierWaveDirect
23
23
  class FilenameFormatValidator < ::ActiveModel::EachValidator
24
24
  def validate_each(record, attribute, value)
25
25
  if record.send("has_#{attribute}_upload?") && record.send("#{attribute}_key") !~ record.send(attribute).key_regexp
26
- extensions = record.send(attribute).extension_white_list
26
+ extensions = record.send(attribute).extension_whitelist
27
27
  message = I18n.t("errors.messages.carrierwave_direct_filename_invalid")
28
28
 
29
29
  if extensions.present?
@@ -43,7 +43,7 @@ module CarrierWaveDirect
43
43
  url_scheme_white_list = uploader.url_scheme_white_list
44
44
 
45
45
  if (remote_net_url !~ URI.regexp(url_scheme_white_list) || remote_net_url !~ /#{uploader.extension_regexp}\z/)
46
- extensions = uploader.extension_white_list
46
+ extensions = uploader.extension_whitelist
47
47
 
48
48
  message = I18n.t("errors.messages.carrierwave_direct_filename_invalid")
49
49
 
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module CarrierwaveDirect
4
- VERSION = "1.0.0"
4
+ VERSION = "2.0.0"
5
5
  end
6
6
 
@@ -104,8 +104,8 @@ describe CarrierWaveDirect::ActiveRecord do
104
104
  messages = I18n.t("errors.messages.carrierwave_direct_filename_invalid")
105
105
 
106
106
  if i18n_options
107
- if i18n_options[:extension_white_list]
108
- extensions = i18n_options[:extension_white_list].to_sentence
107
+ if i18n_options[:extension_whitelist]
108
+ extensions = i18n_options[:extension_whitelist].to_sentence
109
109
  messages += I18n.t("errors.messages.carrierwave_direct_allowed_extensions", :extensions => extensions)
110
110
  end
111
111
 
@@ -244,7 +244,7 @@ describe CarrierWaveDirect::ActiveRecord do
244
244
 
245
245
  context "where the uploader has an extension white list" do
246
246
  before do
247
- subject.video.stub(:extension_white_list).and_return(%w{avi mp4})
247
+ subject.video.stub(:extension_whitelist).and_return(%w{avi mp4})
248
248
  end
249
249
 
250
250
  context "and the uploaded file's extension is included in the list" do
@@ -302,7 +302,7 @@ describe CarrierWaveDirect::ActiveRecord do
302
302
  context "on create" do
303
303
  context "where the uploader has an extension white list" do
304
304
  before do
305
- subject.video.stub(:extension_white_list).and_return(%w{avi mp4})
305
+ subject.video.stub(:extension_whitelist).and_return(%w{avi mp4})
306
306
  end
307
307
 
308
308
  context "and the url's extension is included in the list" do
@@ -325,7 +325,7 @@ describe CarrierWaveDirect::ActiveRecord do
325
325
  end
326
326
 
327
327
  it_should_behave_like "a remote net url i18n error message" do
328
- let(:i18n_options) { {:extension_white_list => %w{avi mp4} } }
328
+ let(:i18n_options) { {:extension_whitelist => %w{avi mp4} } }
329
329
  end
330
330
 
331
331
  it "should include the white listed extensions in the error message" do
data/spec/spec_helper.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'carrierwave_direct'
4
4
  require 'json'
5
5
  require 'timecop'
6
+ require 'byebug'
6
7
 
7
8
  require File.dirname(__FILE__) << '/support/view_helpers' # Catch dependency order
8
9
 
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  CarrierWave.configure do |config|
4
+ config.fog_provider = 'fog/aws'
4
5
  config.fog_credentials = {
5
6
  :provider => 'AWS',
6
7
  :aws_access_key_id => 'AWS_ACCESS_KEY_ID',
@@ -19,7 +19,7 @@ describe CarrierWaveDirect::Test::Helpers do
19
19
 
20
20
  context "['exe', 'bmp']" do
21
21
  before do
22
- allow(direct_uploader).to receive(:extension_white_list).and_return(%w{exe bmp})
22
+ allow(direct_uploader).to receive(:extension_whitelist).and_return(%w{exe bmp})
23
23
  end
24
24
 
25
25
  it "should return '*/guid/filename.exe'" do
@@ -29,7 +29,7 @@ describe CarrierWaveDirect::Test::Helpers do
29
29
 
30
30
  context "[]" do
31
31
  before do
32
- allow(direct_uploader).to receive(:extension_white_list).and_return([])
32
+ allow(direct_uploader).to receive(:extension_whitelist).and_return([])
33
33
  end
34
34
 
35
35
  it_should_behave_like "returning the default extension"
@@ -37,7 +37,7 @@ describe CarrierWaveDirect::Test::Helpers do
37
37
 
38
38
  context "nil" do
39
39
  before do
40
- allow(direct_uploader).to receive(:extension_white_list).and_return(nil)
40
+ allow(direct_uploader).to receive(:extension_whitelist).and_return(nil)
41
41
  end
42
42
 
43
43
  it_should_behave_like "returning the default extension"
@@ -138,26 +138,26 @@ describe CarrierWaveDirect::Uploader do
138
138
  expect(subject.extension_regexp).to be_a(String)
139
139
  end
140
140
 
141
- context "where #extension_white_list returns nil" do
141
+ context "where #extension_whitelist returns nil" do
142
142
  before do
143
- allow(subject).to receive(:extension_white_list).and_return(nil)
143
+ allow(subject).to receive(:extension_whitelist).and_return(nil)
144
144
  end
145
145
 
146
146
  it_should_behave_like "a globally allowed file extension"
147
147
  end
148
148
 
149
- context "where #extension_white_list returns []" do
149
+ context "where #extension_whitelist returns []" do
150
150
  before do
151
- allow(subject).to receive(:extension_white_list).and_return([])
151
+ allow(subject).to receive(:extension_whitelist).and_return([])
152
152
  end
153
153
 
154
154
  it_should_behave_like "a globally allowed file extension"
155
155
  end
156
156
 
157
- context "where #extension_white_list returns ['exe', 'bmp']" do
157
+ context "where #extension_whitelist returns ['exe', 'bmp']" do
158
158
 
159
159
  before do
160
- allow(subject).to receive(:extension_white_list).and_return(%w{exe bmp})
160
+ allow(subject).to receive(:extension_whitelist).and_return(%w{exe bmp})
161
161
  end
162
162
 
163
163
  it "should return '(exe|bmp)'" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave_direct
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Wilkie
@@ -14,16 +14,16 @@ dependencies:
14
14
  name: carrierwave
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0.11'
19
+ version: 1.0.0
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: '0.11'
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: fog-aws
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: byebug
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: Process your uploads in the background by uploading directly to S3
112
126
  email:
113
127
  - dwilkie@gmail.com