<commit_before>require 'dragonfly'

module Refinery
  module Videos
    module Dragonfly

      class << self
        def configure!
          ActiveRecord::Base.extend ::Dragonfly::Model
          ActiveRecord::Base.extend ::Dragonfly::Model::Validations

          app_videos = ::Dragonfly.app(:refinery_videos)
          app_videos.configure do
            # datastore ::Dragonfly::DataStorage::MongoDataStore.new(:db => MongoMapper.database)
            datastore :file, {
              :root_path => Refinery::Videos.datastore_root_path
            }
            url_format Refinery::Videos.dragonfly_url_format
            secret Refinery::Videos.dragonfly_secret
          end

          if ::Refinery::Videos.s3_backend
            app_videos.datastore = ::Dragonfly::DataStorage::S3DataStore.new
            app_videos.datastore.configure do |s3|
              s3.bucket_name = Refinery::Videos.s3_bucket_name
              s3.access_key_id = Refinery::Videos.s3_access_key_id
              s3.secret_access_key = Refinery::Videos.s3_secret_access_key
              # S3 Region otherwise defaults to 'us-east-1'
              s3.region = Refinery::Videos.s3_region if Refinery::Videos.s3_region
            end
          end
        end

        def attach!
          Rails.application.config.middleware.use ::Dragonfly::Middleware, :refinery_videos
        end
      end

    end
  end
end<commit_msg>updated dragonfly config for Amazon S3<commit_after>require 'dragonfly'

module Refinery
  module Videos
    module Dragonfly

      class << self
        def configure!
          ActiveRecord::Base.extend ::Dragonfly::Model
          ActiveRecord::Base.extend ::Dragonfly::Model::Validations

          app_videos = ::Dragonfly.app(:refinery_videos)
          app_videos.configure do
            # datastore ::Dragonfly::DataStorage::MongoDataStore.new(:db => MongoMapper.database)
            datastore :file, {
              :root_path => Refinery::Videos.datastore_root_path
            }
            url_format Refinery::Videos.dragonfly_url_format
            secret Refinery::Videos.dragonfly_secret
          end

          if ::Refinery::Videos.s3_backend
            require 'dragonfly/s3_data_store'
            options = {
              bucket_name: Refinery::Videos.s3_bucket_name,
              access_key_id: Refinery::Videos.s3_access_key_id,
              secret_access_key: Refinery::Videos.s3_secret_access_key
            }
            # S3 Region otherwise defaults to 'us-east-1'
            options.update(region: Refinery::Videos.s3_region) if Refinery::Videos.s3_region
            app_videos.use_datastore :s3, options
          end
        end

        def attach!
          Rails.application.config.middleware.use ::Dragonfly::Middleware, :refinery_videos
        end
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.08289241622574955, 'fraction_numerical': 0.008818342151675485, 'mean_word_length': 2.2635212888377447, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '906043', 'n_tokens_mistral': 879, 'n_tokens_neox': 835, 'n_words': 140}