Sha256: 1e4437621f9f9f9c9a7e78c40b0d3c4220e76219ae2301dbadd4dc7cf3df93d3

Contents?: true

Size: 1.52 KB

Versions: 31

Compression:

Stored size: 1.52 KB

Contents

class UpdateConfiguration < ActiveRecord::Migration
  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

31 entries across 31 versions & 1 rubygems

Version Path
trusty-clipped-extension-3.0.0 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.15 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.14 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.13 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.12 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.11 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.10 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.9 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.8 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.7 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.6 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.5 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.4 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.3.pre.beta db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.2.pre.beta db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.1.pre.beta db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-2.0.0.pre.beta db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-1.1.1 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-1.1.0 db/migrate/20110606111250_update_configuration.rb
trusty-clipped-extension-1.0.11 db/migrate/20110606111250_update_configuration.rb