Sha256: a1086bf137298a32848aa69d4de45a68e29b7f9c7e40d6378f0152ec54426c78

Contents?: true

Size: 1.53 KB

Versions: 10

Compression:

Stored size: 1.53 KB

Contents

class UpdateConfiguration < ActiveRecord::Migration[5.1]
  def self.up
    if TrustyCms.config.table_exists?

      puts "Importing paperclip configuration"
      %w{url path skip_filetype_validation storage}.select{|k| !!TrustyCms.config["assets.#{k}"] }.each do |k|
        begin
          TrustyCms.config["paperclip.#{k}"] = TrustyCms.config["assets.#{k}"]
        rescue ActiveRecord::RecordInvalid => e
          print "Oops! There was trouble setting #{k} to '#{TrustyCms.config["assets.#{k}"]}'"
          print "\nSetting it to 'fog'. Please see the clipped extension README for more details."
          TrustyCms.config["paperclip.#{k}"] = 'fog'
        end
      end

      puts "Importing s3 storage configuration"
      %w{bucket key secret host_alias}.select{|k| !!TrustyCms.config["assets.s3.#{k}"] }.each do |k|
        TrustyCms.config["paperclip.s3.#{k}"] = TrustyCms.config["assets.s3.#{k}"]
      end

      puts "Importing thumbnail configuration"
      if thumbnails = TrustyCms.config["assets.additional_thumbnails"]
        old_styles = thumbnails.to_s.gsub(' ','').split(',').collect{|s| s.split('=')}.inject({}) {|ha, (k, v)| ha[k.to_sym] = v; ha}
        new_styles = old_styles.map {|k,v| "#{k}:size=#{v}"}
        TrustyCms.config["assets.thumbnails.image"] = new_styles.join("|")
        TrustyCms.config["assets.thumbnails.video"] = new_styles.map{|s| "#{s},format=jpg"}.join("|")
        TrustyCms.config["assets.thumbnails.pdf"] = new_styles.map{|s| "#{s},format=jpg"}.join("|")
      end
    end
  end

  def self.down
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
trusty-cms-3.3.2 db/migrate/20110606111250_update_configuration.rb
trusty-cms-3.3.1 db/migrate/20110606111250_update_configuration.rb
trusty-cms-3.2.1 db/migrate/20110606111250_update_configuration.rb
trusty-cms-3.3.0 db/migrate/20110606111250_update_configuration.rb
trusty-cms-3.2.0 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-3.1.4 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-3.1.3 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-3.1.2 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-3.1.1 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-3.1.0 db/migrate/20110606111250_update_configuration.rb