Sha256: c482b05b5a78f230077bfdacc2b3501090904ed31b25e061069e1b10b26f5e19

Contents?: true

Size: 472 Bytes

Versions: 4

Compression:

Stored size: 472 Bytes

Contents

# -*- encoding : utf-8 -*-

class JsonizeTinymce < ActiveRecord::Migration
  include Wagn::MigrationHelper
  def up
    contentedly do
      card = Card[:tiny_mce]
      cleaned_rows = card.content.strip.split( /\s*\,\s+/ ).map do |row|
        key, val = row.split /\s*\:\s*/
        val.gsub! /\"\s*\+\s*\"/, ''
        val.gsub! "'", '"'
        %("#{key}":#{val})
      end
      card.content = %({\n#{ cleaned_rows.join ",\n" }\n})
      card.save!
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wagn-1.13.0 db/migrate_cards/20130920214038_jsonize_tinymce.rb
wagn-1.13.0.pre2 db/migrate_cards/20130920214038_jsonize_tinymce.rb
wagn-1.13.0.pre1 db/migrate_cards/20130920214038_jsonize_tinymce.rb
wagn-1.13.0.pre db/migrate_cards/20130920214038_jsonize_tinymce.rb