diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/active_file/purge_job.rb | 7 | ||||
-rw-r--r-- | lib/active_vault.rb (renamed from lib/active_file.rb) | 4 | ||||
-rw-r--r-- | lib/active_vault/blob.rb (renamed from lib/active_file/blob.rb) | 10 | ||||
-rw-r--r-- | lib/active_vault/config/sites.yml (renamed from lib/active_file/config/sites.yml) | 6 | ||||
-rw-r--r-- | lib/active_vault/disk_controller.rb (renamed from lib/active_file/disk_controller.rb) | 10 | ||||
-rw-r--r-- | lib/active_vault/download.rb (renamed from lib/active_file/download.rb) | 2 | ||||
-rw-r--r-- | lib/active_vault/filename.rb (renamed from lib/active_file/filename.rb) | 2 | ||||
-rw-r--r-- | lib/active_vault/migration.rb (renamed from lib/active_file/migration.rb) | 2 | ||||
-rw-r--r-- | lib/active_vault/purge_job.rb | 7 | ||||
-rw-r--r-- | lib/active_vault/railtie.rb (renamed from lib/active_file/railtie.rb) | 8 | ||||
-rw-r--r-- | lib/active_vault/site.rb (renamed from lib/active_file/site.rb) | 6 | ||||
-rw-r--r-- | lib/active_vault/site/disk_site.rb (renamed from lib/active_file/site/disk_site.rb) | 4 | ||||
-rw-r--r-- | lib/active_vault/site/gcs_site.rb (renamed from lib/active_file/site/gcs_site.rb) | 2 | ||||
-rw-r--r-- | lib/active_vault/site/mirror_site.rb (renamed from lib/active_file/site/mirror_site.rb) | 2 | ||||
-rw-r--r-- | lib/active_vault/site/s3_site.rb (renamed from lib/active_file/site/s3_site.rb) | 2 | ||||
-rw-r--r-- | lib/active_vault/verified_key_with_expiration.rb (renamed from lib/active_file/verified_key_with_expiration.rb) | 4 |
16 files changed, 39 insertions, 39 deletions
diff --git a/lib/active_file/purge_job.rb b/lib/active_file/purge_job.rb deleted file mode 100644 index 1a967db2f0..0000000000 --- a/lib/active_file/purge_job.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ActiveFile::PurgeJob < ActiveJob::Base - retry_on ActiveFile::StorageException - - def perform(blob) - blob.purge - end -end diff --git a/lib/active_file.rb b/lib/active_vault.rb index b4b319fc8e..f47b09b4cd 100644 --- a/lib/active_file.rb +++ b/lib/active_vault.rb @@ -1,7 +1,7 @@ require "active_record" -require "active_file/railtie" if defined?(Rails) +require "active_vault/railtie" if defined?(Rails) -module ActiveFile +module ActiveVault extend ActiveSupport::Autoload autoload :Blob diff --git a/lib/active_file/blob.rb b/lib/active_vault/blob.rb index d8b9cd07d2..4948d43ec7 100644 --- a/lib/active_file/blob.rb +++ b/lib/active_vault/blob.rb @@ -1,8 +1,8 @@ -require "active_file/site" -require "active_file/filename" +require "active_vault/site" +require "active_vault/filename" # Schema: id, key, filename, content_type, metadata, byte_size, checksum, created_at -class ActiveFile::Blob < ActiveRecord::Base +class ActiveVault::Blob < ActiveRecord::Base self.table_name = "rails_blobs" has_secure_token :key @@ -31,7 +31,7 @@ class ActiveFile::Blob < ActiveRecord::Base end def filename - ActiveFile::Filename.new(self[:filename]) + ActiveVault::Filename.new(self[:filename]) end def url(expires_in: 5.minutes, disposition: :inline) @@ -61,6 +61,6 @@ class ActiveFile::Blob < ActiveRecord::Base end def purge_later - ActiveFile::PurgeJob.perform_later(self) + ActiveVault::PurgeJob.perform_later(self) end end diff --git a/lib/active_file/config/sites.yml b/lib/active_vault/config/sites.yml index bb550aed7a..334e779b28 100644 --- a/lib/active_file/config/sites.yml +++ b/lib/active_vault/config/sites.yml @@ -1,13 +1,13 @@ # Configuration should be something like this: # # config/environments/development.rb -# config.active_file.site = :local +# config.active_vault.site = :local # # config/environments/production.rb -# config.active_file.site = :amazon +# config.active_vault.site = :amazon local: site: Disk - root: <%%= File.join(Dir.tmpdir, "active_file") %> + root: <%%= File.join(Dir.tmpdir, "active_vault") %> amazon: site: S3 diff --git a/lib/active_file/disk_controller.rb b/lib/active_vault/disk_controller.rb index d778cf066f..623569f0f6 100644 --- a/lib/active_file/disk_controller.rb +++ b/lib/active_vault/disk_controller.rb @@ -1,13 +1,13 @@ require "action_controller" -require "active_file/blob" -require "active_file/verified_key_with_expiration" +require "active_vault/blob" +require "active_vault/verified_key_with_expiration" require "active_support/core_ext/object/inclusion" -class ActiveFile::DiskController < ActionController::Base +class ActiveVault::DiskController < ActionController::Base def show if key = decode_verified_key - blob = ActiveFile::Blob.find_by!(key: key) + blob = ActiveVault::Blob.find_by!(key: key) if stale?(etag: blob.checksum) send_data blob.download, filename: blob.filename, type: blob.content_type, disposition: disposition_param @@ -19,7 +19,7 @@ class ActiveFile::DiskController < ActionController::Base private def decode_verified_key - ActiveFile::VerifiedKeyWithExpiration.decode(params[:encoded_key]) + ActiveVault::VerifiedKeyWithExpiration.decode(params[:encoded_key]) end def disposition_param diff --git a/lib/active_file/download.rb b/lib/active_vault/download.rb index 74f69a9dfc..6e74056062 100644 --- a/lib/active_file/download.rb +++ b/lib/active_vault/download.rb @@ -1,4 +1,4 @@ -class ActiveFile::Download +class ActiveVault::Download # Sending .ai files as application/postscript to Safari opens them in a blank, grey screen. # Downloading .ai as application/postscript files in Safari appends .ps to the extension. # Sending HTML, SVG, XML and SWF files as binary closes XSS vulnerabilities. diff --git a/lib/active_file/filename.rb b/lib/active_vault/filename.rb index b3c184e26c..647d037b1f 100644 --- a/lib/active_file/filename.rb +++ b/lib/active_vault/filename.rb @@ -1,4 +1,4 @@ -class ActiveFile::Filename +class ActiveVault::Filename include Comparable def initialize(filename) diff --git a/lib/active_file/migration.rb b/lib/active_vault/migration.rb index 1c87444dd4..cc7a535f39 100644 --- a/lib/active_file/migration.rb +++ b/lib/active_vault/migration.rb @@ -1,4 +1,4 @@ -class ActiveFile::CreateBlobs < ActiveRecord::Migration[5.1] +class ActiveVault::CreateBlobs < ActiveRecord::Migration[5.1] def change create_table :rails_blobs do |t| t.string :key diff --git a/lib/active_vault/purge_job.rb b/lib/active_vault/purge_job.rb new file mode 100644 index 0000000000..d7634af2bb --- /dev/null +++ b/lib/active_vault/purge_job.rb @@ -0,0 +1,7 @@ +class ActiveVault::PurgeJob < ActiveJob::Base + retry_on ActiveVault::StorageException + + def perform(blob) + blob.purge + end +end diff --git a/lib/active_file/railtie.rb b/lib/active_vault/railtie.rb index 18e4779229..c254f4c77c 100644 --- a/lib/active_file/railtie.rb +++ b/lib/active_vault/railtie.rb @@ -1,17 +1,17 @@ require "rails/railtie" -module ActiveFile +module ActiveVault class Railtie < Rails::Railtie # :nodoc: config.action_file = ActiveSupport::OrderedOptions.new - config.eager_load_namespaces << ActiveFile + config.eager_load_namespaces << ActiveVault initializer "action_file.routes" do - require "active_file/disk_controller" + require "active_vault/disk_controller" config.after_initialize do |app| app.routes.prepend do - get "/rails/blobs/:encoded_key" => "active_file/disk#show", as: :rails_disk_blob + get "/rails/blobs/:encoded_key" => "active_vault/disk#show", as: :rails_disk_blob end end end diff --git a/lib/active_file/site.rb b/lib/active_vault/site.rb index 19cbbc754e..29eddf1566 100644 --- a/lib/active_file/site.rb +++ b/lib/active_vault/site.rb @@ -1,9 +1,9 @@ # Abstract class serving as an interface for concrete sites. -class ActiveFile::Site +class ActiveVault::Site def self.configure(site, **options) begin - require "active_file/site/#{site.to_s.downcase}_site" - ActiveFile::Site.const_get(:"#{site}Site").new(**options) + require "active_vault/site/#{site.to_s.downcase}_site" + ActiveVault::Site.const_get(:"#{site}Site").new(**options) rescue LoadError => e puts "Couldn't configure site: #{site} (#{e.message})" end diff --git a/lib/active_file/site/disk_site.rb b/lib/active_vault/site/disk_site.rb index 7916a642c0..73f86bac6a 100644 --- a/lib/active_file/site/disk_site.rb +++ b/lib/active_vault/site/disk_site.rb @@ -1,7 +1,7 @@ require "fileutils" require "pathname" -class ActiveFile::Site::DiskSite < ActiveFile::Site +class ActiveVault::Site::DiskSite < ActiveVault::Site attr_reader :root def initialize(root:) @@ -38,7 +38,7 @@ class ActiveFile::Site::DiskSite < ActiveFile::Site def url(key, expires_in:, disposition:, filename:) - verified_key_with_expiration = ActiveFile::VerifiedKeyWithExpiration.encode(key, expires_in: expires_in) + verified_key_with_expiration = ActiveVault::VerifiedKeyWithExpiration.encode(key, expires_in: expires_in) if defined?(Rails) && defined?(Rails.application) Rails.application.routes.url_helpers.rails_disk_blob_path(verified_key_with_expiration, disposition: disposition) diff --git a/lib/active_file/site/gcs_site.rb b/lib/active_vault/site/gcs_site.rb index c5f3d634cf..e509ebbbd2 100644 --- a/lib/active_file/site/gcs_site.rb +++ b/lib/active_vault/site/gcs_site.rb @@ -1,6 +1,6 @@ require "google/cloud/storage" -class ActiveFile::Site::GCSSite < ActiveFile::Site +class ActiveVault::Site::GCSSite < ActiveVault::Site attr_reader :client, :bucket def initialize(project:, keyfile:, bucket:) diff --git a/lib/active_file/site/mirror_site.rb b/lib/active_vault/site/mirror_site.rb index 65f28cd437..67d79a2607 100644 --- a/lib/active_file/site/mirror_site.rb +++ b/lib/active_vault/site/mirror_site.rb @@ -1,4 +1,4 @@ -class ActiveFile::Site::MirrorSite < ActiveFile::Site +class ActiveVault::Site::MirrorSite < ActiveVault::Site attr_reader :sites def initialize(sites:) diff --git a/lib/active_file/site/s3_site.rb b/lib/active_vault/site/s3_site.rb index 25a876c697..49a7522170 100644 --- a/lib/active_file/site/s3_site.rb +++ b/lib/active_vault/site/s3_site.rb @@ -1,6 +1,6 @@ require "aws-sdk" -class ActiveFile::Site::S3Site < ActiveFile::Site +class ActiveVault::Site::S3Site < ActiveVault::Site attr_reader :client, :bucket def initialize(access_key_id:, secret_access_key:, region:, bucket:) diff --git a/lib/active_file/verified_key_with_expiration.rb b/lib/active_vault/verified_key_with_expiration.rb index e9e811d364..95d4993ff0 100644 --- a/lib/active_file/verified_key_with_expiration.rb +++ b/lib/active_vault/verified_key_with_expiration.rb @@ -1,5 +1,5 @@ -class ActiveFile::VerifiedKeyWithExpiration - class_attribute :verifier, default: defined?(Rails) ? Rails.application.message_verifier('ActiveFile') : nil +class ActiveVault::VerifiedKeyWithExpiration + class_attribute :verifier, default: defined?(Rails) ? Rails.application.message_verifier('ActiveVault') : nil class << self def encode(key, expires_in: nil) |