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.27 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.26 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.45 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.25 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.23 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.44 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.22 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.43 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.21 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.42 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.20 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.41 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.19 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.40 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.18 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.39 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.17 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.38 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.16 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.37 lib/workarea/configuration/dragonfly.rb