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.4.27 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.4 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.26 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.3 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.25 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.2 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.24 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.1 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.23 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.22 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.0 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.21 lib/workarea/configuration/dragonfly.rb
workarea-core-3.5.0.beta.1 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.20 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.19 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.18 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.17 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.16 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.15 lib/workarea/configuration/dragonfly.rb
workarea-core-3.4.14 lib/workarea/configuration/dragonfly.rb