<commit_before>module Yoolk
  module Liquid
    module ProductCatalog
      class ProductDrop < BaseDrop
        attributes  :id, :name, :price, :sale_price, :quantity, :price_with_currency,
                    :description, :delivery, :features, :brand, :to_param, :hide_price,
                    :hide_price?, :sku, :storefront, :published, :tracked_inventory,
                    :storefront_order, :selling_price, :in_stock?,
                    :out_of_stock?, :unlimited?,
                    :created_at, :updated_at

        has_many    :product_categories,  with: 'Yoolk::Liquid::ProductCatalog::CategoryDrop'
        has_many    :photos,              with: 'Yoolk::Liquid::AttachmentDrop'

        ## Delegates
        delegate    :add_to_cart?, :available_for_sale?, :unavailable_for_sale?, 
                    :show_price?, :visible_price?, 
                    to: :object

        def url
          product_url(self)
        end

        def cover_photo
          photos[0]
        end

        def data_json
          {
            product: {
              id: id,
              name: name,
              price: selling_price,
              url: url,
              image_url: cover_photo.url(:small)
            }
          }.to_json
        end
      end
    end
  end
end
<commit_msg>fix data_json to escape single quote<commit_after>module Yoolk
  module Liquid
    module ProductCatalog
      class ProductDrop < BaseDrop
        attributes  :id, :name, :price, :sale_price, :quantity, :price_with_currency,
                    :description, :delivery, :features, :brand, :to_param, :hide_price,
                    :hide_price?, :sku, :storefront, :published, :tracked_inventory,
                    :storefront_order, :selling_price, :in_stock?,
                    :out_of_stock?, :unlimited?,
                    :created_at, :updated_at

        has_many    :product_categories,  with: 'Yoolk::Liquid::ProductCatalog::CategoryDrop'
        has_many    :photos,              with: 'Yoolk::Liquid::AttachmentDrop'

        ## Delegates
        delegate    :add_to_cart?, :available_for_sale?, :unavailable_for_sale?, 
                    :show_price?, :visible_price?, 
                    to: :object

        def url
          product_url(self)
        end

        def cover_photo
          photos[0]
        end

        def data_json
          {
            product: {
              id: id,
              name: name.gsub(/'/, "&#39;"),
              price: selling_price,
              url: url,
              image_url: cover_photo.url(:small)
            }
          }.to_json
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09290030211480363, 'fraction_numerical': 0.0015105740181268882, 'mean_word_length': 1.6124260355029585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '3014691', 'n_tokens_mistral': 783, 'n_tokens_neox': 743, 'n_words': 162}