From fc8947012fa5ae34d1ff181703e8e0476f7ba6d8 Mon Sep 17 00:00:00 2001 From: Yoshiyuki Hirano Date: Mon, 11 Dec 2017 00:01:16 +0900 Subject: `webpack` is assigned but never used in webpack.config.js * Removed webpack const, so it is assigned but never used in webpack.config.js. --- activestorage/webpack.config.js | 1 - 1 file changed, 1 deletion(-) (limited to 'activestorage') diff --git a/activestorage/webpack.config.js b/activestorage/webpack.config.js index 92c4530e7f..3a50eef470 100644 --- a/activestorage/webpack.config.js +++ b/activestorage/webpack.config.js @@ -1,4 +1,3 @@ -const webpack = require("webpack") const path = require("path") module.exports = { -- cgit v1.2.3 From 4c590e9d2e23d24666ed68a0cfbce3a2a2d39160 Mon Sep 17 00:00:00 2001 From: Yoshiyuki Hirano Date: Tue, 12 Dec 2017 02:51:03 +0900 Subject: Return `nil` instead of `false` if raise `Azure::Core::Http::HTTPError` * If it raise error `Azure::Core::Http::HTTPError`, return `nil` instead of `false` in `ActiveStorage::Service::AzureStorageService#delete`. * Other services behave as same as this. --- activestorage/lib/active_storage/service/azure_storage_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activestorage') diff --git a/activestorage/lib/active_storage/service/azure_storage_service.rb b/activestorage/lib/active_storage/service/azure_storage_service.rb index 19b09991b3..0a9eb7f23d 100644 --- a/activestorage/lib/active_storage/service/azure_storage_service.rb +++ b/activestorage/lib/active_storage/service/azure_storage_service.rb @@ -46,7 +46,7 @@ module ActiveStorage begin blobs.delete_blob(container, key) rescue Azure::Core::Http::HTTPError - false + # Ignore files already deleted end end end -- cgit v1.2.3 From a80f81af055f02bf4625c90470aa90441cf6fc24 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Mon, 11 Dec 2017 13:28:05 -0500 Subject: Invoke mogrify once when transforming an image Execute a single mogrify command with multiple options rather than one command per option. Permit the use of all mogrify options, not just the ones that fall through to MiniMagick::Image#method_missing. --- activestorage/app/models/active_storage/variation.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'activestorage') diff --git a/activestorage/app/models/active_storage/variation.rb b/activestorage/app/models/active_storage/variation.rb index 13bad87cac..6a8825f1a8 100644 --- a/activestorage/app/models/active_storage/variation.rb +++ b/activestorage/app/models/active_storage/variation.rb @@ -44,13 +44,15 @@ class ActiveStorage::Variation end # Accepts an open MiniMagick image instance, like what's returned by MiniMagick::Image.read(io), - # and performs the +transformations+ against it. The transformed image instance is then returned. + # and performs the +transformations+ against it. def transform(image) - transformations.each do |(method, argument)| - if eligible_argument?(argument) - image.public_send(method, argument) - else - image.public_send(method) + image.mogrify do |command| + transformations.each do |method, argument| + if eligible_argument?(argument) + command.public_send(method, argument) + else + command.public_send(method) + end end end end -- cgit v1.2.3 From 931fe37aa78b9af9f779ac750cf2fa132e049c2b Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Mon, 11 Dec 2017 18:30:21 -0500 Subject: Revert "Invoke mogrify once when transforming an image" This reverts commit a80f81af055f02bf4625c90470aa90441cf6fc24. --- activestorage/app/models/active_storage/variation.rb | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'activestorage') diff --git a/activestorage/app/models/active_storage/variation.rb b/activestorage/app/models/active_storage/variation.rb index 6a8825f1a8..13bad87cac 100644 --- a/activestorage/app/models/active_storage/variation.rb +++ b/activestorage/app/models/active_storage/variation.rb @@ -44,15 +44,13 @@ class ActiveStorage::Variation end # Accepts an open MiniMagick image instance, like what's returned by MiniMagick::Image.read(io), - # and performs the +transformations+ against it. + # and performs the +transformations+ against it. The transformed image instance is then returned. def transform(image) - image.mogrify do |command| - transformations.each do |method, argument| - if eligible_argument?(argument) - command.public_send(method, argument) - else - command.public_send(method) - end + transformations.each do |(method, argument)| + if eligible_argument?(argument) + image.public_send(method, argument) + else + image.public_send(method) end end end -- cgit v1.2.3 From 6129d1f937c64eadd6118a89fea556b201b6b4d4 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Mon, 11 Dec 2017 18:32:05 -0500 Subject: Fix optimizing GIF variants using mogrify's -layers option --- activestorage/app/models/active_storage/variation.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'activestorage') diff --git a/activestorage/app/models/active_storage/variation.rb b/activestorage/app/models/active_storage/variation.rb index 13bad87cac..fc4305dcc5 100644 --- a/activestorage/app/models/active_storage/variation.rb +++ b/activestorage/app/models/active_storage/variation.rb @@ -46,11 +46,13 @@ class ActiveStorage::Variation # Accepts an open MiniMagick image instance, like what's returned by MiniMagick::Image.read(io), # and performs the +transformations+ against it. The transformed image instance is then returned. def transform(image) - transformations.each do |(method, argument)| - if eligible_argument?(argument) - image.public_send(method, argument) - else - image.public_send(method) + transformations.each do |method, argument| + image.mogrify do |command| + if eligible_argument?(argument) + command.public_send(method, argument) + else + command.public_send(method) + end end end end -- cgit v1.2.3 From 66a22dee1cec365d459559b96a658dfc4daef0c4 Mon Sep 17 00:00:00 2001 From: Hirofumi Wakasugi Date: Mon, 11 Dec 2017 12:24:11 +0900 Subject: Invoke app-prefixed active storage task when in engine --- activestorage/lib/tasks/activestorage.rake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activestorage') diff --git a/activestorage/lib/tasks/activestorage.rake b/activestorage/lib/tasks/activestorage.rake index ef923e5926..296e91afa1 100644 --- a/activestorage/lib/tasks/activestorage.rake +++ b/activestorage/lib/tasks/activestorage.rake @@ -3,6 +3,10 @@ namespace :active_storage do desc "Copy over the migration needed to the application" task install: :environment do - Rake::Task["active_storage:install:migrations"].invoke + if Rake::Task.task_defined?("active_storage:install:migrations") + Rake::Task["active_storage:install:migrations"].invoke + else + Rake::Task["app:active_storage:install:migrations"].invoke + end end end -- cgit v1.2.3 From 74c4017daff90df6bebf260cbcec03c73aa3be10 Mon Sep 17 00:00:00 2001 From: George Claghorn Date: Wed, 13 Dec 2017 08:34:20 -0500 Subject: Exclude ActiveStorage::Filename{#parameters,::Parameters} from API docs [ci skip] --- activestorage/app/models/active_storage/filename.rb | 2 +- activestorage/app/models/active_storage/filename/parameters.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'activestorage') diff --git a/activestorage/app/models/active_storage/filename.rb b/activestorage/app/models/active_storage/filename.rb index 79d55dc889..b9413dec95 100644 --- a/activestorage/app/models/active_storage/filename.rb +++ b/activestorage/app/models/active_storage/filename.rb @@ -50,7 +50,7 @@ class ActiveStorage::Filename @filename.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "�").strip.tr("\u{202E}%$|:;/\t\r\n\\", "-") end - def parameters + def parameters #:nodoc: Parameters.new self end diff --git a/activestorage/app/models/active_storage/filename/parameters.rb b/activestorage/app/models/active_storage/filename/parameters.rb index 58ce198d38..fb9ea10e49 100644 --- a/activestorage/app/models/active_storage/filename/parameters.rb +++ b/activestorage/app/models/active_storage/filename/parameters.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -class ActiveStorage::Filename::Parameters +class ActiveStorage::Filename::Parameters #:nodoc: attr_reader :filename def initialize(filename) -- cgit v1.2.3 From ff25c25127405f49c0021714a9d938558c7822ab Mon Sep 17 00:00:00 2001 From: Mehmet Emin INAC Date: Wed, 13 Dec 2017 17:59:36 +0100 Subject: Expose Active Storage routes --- activestorage/config/routes.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'activestorage') diff --git a/activestorage/config/routes.rb b/activestorage/config/routes.rb index 1eae21445a..ad9640ce03 100644 --- a/activestorage/config/routes.rb +++ b/activestorage/config/routes.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true Rails.application.routes.draw do - get "/rails/active_storage/blobs/:signed_id/*filename" => "active_storage/blobs#show", as: :rails_service_blob, internal: true + get "/rails/active_storage/blobs/:signed_id/*filename" => "active_storage/blobs#show", as: :rails_service_blob direct :rails_blob do |blob, options| route_for(:rails_service_blob, blob.signed_id, blob.filename, options) @@ -11,7 +11,7 @@ Rails.application.routes.draw do resolve("ActiveStorage::Attachment") { |attachment, options| route_for(:rails_blob, attachment.blob, options) } - get "/rails/active_storage/variants/:signed_blob_id/:variation_key/*filename" => "active_storage/variants#show", as: :rails_blob_variation, internal: true + get "/rails/active_storage/variants/:signed_blob_id/:variation_key/*filename" => "active_storage/variants#show", as: :rails_blob_variation direct :rails_variant do |variant, options| signed_blob_id = variant.blob.signed_id @@ -24,7 +24,7 @@ Rails.application.routes.draw do resolve("ActiveStorage::Variant") { |variant, options| route_for(:rails_variant, variant, options) } - get "/rails/active_storage/previews/:signed_blob_id/:variation_key/*filename" => "active_storage/previews#show", as: :rails_blob_preview, internal: true + get "/rails/active_storage/previews/:signed_blob_id/:variation_key/*filename" => "active_storage/previews#show", as: :rails_blob_preview direct :rails_preview do |preview, options| signed_blob_id = preview.blob.signed_id @@ -37,7 +37,7 @@ Rails.application.routes.draw do resolve("ActiveStorage::Preview") { |preview, options| route_for(:rails_preview, preview, options) } - get "/rails/active_storage/disk/:encoded_key/*filename" => "active_storage/disk#show", as: :rails_disk_service, internal: true - put "/rails/active_storage/disk/:encoded_token" => "active_storage/disk#update", as: :update_rails_disk_service, internal: true - post "/rails/active_storage/direct_uploads" => "active_storage/direct_uploads#create", as: :rails_direct_uploads, internal: true + get "/rails/active_storage/disk/:encoded_key/*filename" => "active_storage/disk#show", as: :rails_disk_service + put "/rails/active_storage/disk/:encoded_token" => "active_storage/disk#update", as: :update_rails_disk_service + post "/rails/active_storage/direct_uploads" => "active_storage/direct_uploads#create", as: :rails_direct_uploads end -- cgit v1.2.3 From acc03bb695d39682c5e7e4b1338ca96ad57d8ec6 Mon Sep 17 00:00:00 2001 From: Olivier Lacan Date: Wed, 13 Dec 2017 16:17:06 -0500 Subject: Provide instant feedback when booting Rails I've noticed during pair/mob programming sessions with peers that despite the speed boosts provided by Bootsnap and Spring, there is a noticeable latency between firing a bin/rails server command and any feedback being provided to the console. Depending on the size of the application this lack of feedback can make it seem like something is wrong when Rails is simply busy initializing. This change may seem gratuitous but by just printing one line to STDOUT we're giving a clear signal to the Rails user that their command has been received and that Rails is indeed booting. It almost imperciptibly makes Rails feel more responsive. Sure the code doesn't look very fancy but there's no other appropriate place I could think of putting it than boot.rb. Compare these two GIFs of booting without and with this change: Before: ![Without Boot Feedback](https://user-images.githubusercontent.com/65950/33964140-721041fc-e025-11e7-9b25-9d839ce92977.gif) After: ![With Boot Feedback](https://user-images.githubusercontent.com/65950/33964151-79e12f86-e025-11e7-93e9-7a75c70d408f.gif) --- activestorage/test/dummy/config/boot.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activestorage') diff --git a/activestorage/test/dummy/config/boot.rb b/activestorage/test/dummy/config/boot.rb index 59459d4ae3..72516d9255 100644 --- a/activestorage/test/dummy/config/boot.rb +++ b/activestorage/test/dummy/config/boot.rb @@ -5,3 +5,7 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) $LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) + +if %w[s server c console].any? { |a| ARGV.include?(a) } + puts "=> Booting Rails" +end -- cgit v1.2.3 From 245c1dafa8bab409fbcd780a996c619240df7143 Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Thu, 14 Dec 2017 17:30:54 +0900 Subject: Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the future Follow up of #31432. --- activestorage/test/dummy/config/application.rb | 4 ---- 1 file changed, 4 deletions(-) (limited to 'activestorage') diff --git a/activestorage/test/dummy/config/application.rb b/activestorage/test/dummy/config/application.rb index 06cbc453a2..bd14ac0b1a 100644 --- a/activestorage/test/dummy/config/application.rb +++ b/activestorage/test/dummy/config/application.rb @@ -10,10 +10,6 @@ require "action_controller/railtie" require "action_view/railtie" require "sprockets/railtie" require "active_storage/engine" -#require "action_mailer/railtie" -#require "rails/test_unit/railtie" -#require "action_cable/engine" - Bundler.require(*Rails.groups) -- cgit v1.2.3