Sha256: df90f6c2eae70175adfd80320085df78fdb59c7df501a256e6b0f90b13f16146

Contents?: true

Size: 1.18 KB

Versions: 62

Compression:

Stored size: 1.18 KB

Contents

module Workarea
  module Configuration
    module Dragonfly
      extend self

      def load
        type, options = *Workarea.config.asset_store
        options = (options || {}).with_indifferent_access

        if type == :s3 && S3.bucket.present?
          options.reverse_merge!(s3_defaults)
        elsif %i(file file_system).include?(type)
          type = :file
          options.reverse_merge!(file_system_defaults)
        end

        ::Dragonfly.app(:workarea).configure do
          # Ensure Dragonfly always uses the CDN no matter what
          url_host Rails.application.config.action_controller.asset_host
          datastore type, options
        end
      end

      def s3_defaults
        {
          region: S3.region,
          bucket_name: S3.bucket,
          access_key_id: S3.access_key_id,
          secret_access_key: S3.secret_access_key,
          use_iam_profile: S3.access_key_id.blank?,
          storage_headers: { 'x-amz-acl' => 'private' }
        }
      end

      def file_system_defaults
        {
          root_path: Rails.root.join('public/system/workarea', Rails.env).to_s,
          server_root: Rails.root.join('public').to_s
        }
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.15 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.36 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.14 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.35 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.13 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.34 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.12 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.33 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.11 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.10 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.32 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.9 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.31 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.8 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.30 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.7 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.29 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.6 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.28 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.5 lib/workarea/configuration/dragonfly.rb