<commit_before>require 'digest'

module TheCommunityFarm
  class OrganicBoxes
    class Box
      def initialize(noko:)
        @noko = noko
      end

      def id
        Digest::MD5.new.tap do |id|
          id.update(title)
          id.update(items.join("\n"))
        end.hexdigest
      end

      def title
        @title ||= noko.at_css('.lead').text.strip
      end

      def box_size
        @box_size ||= noko.at_css('option[selected]')&.text&.strip
      end

      def items
        @items ||= item_doc.css('li').map { |li| li.text.strip }
      end

      def to_s
        "#{title} #{box_size}".strip
      end

      private

      attr_reader :noko

      def item_doc
        @item_doc ||= Nokogiri::HTML(noko.at_css(item_selector)['data-content'])
      end
<commit_msg>Make code compatible with Ruby 2.1<commit_after>require 'digest'

module TheCommunityFarm
  class OrganicBoxes
    class Box
      def initialize(noko:)
        @noko = noko
      end

      def id
        Digest::MD5.new.tap do |id|
          id.update(title)
          id.update(items.join("\n"))
        end.hexdigest
      end

      def title
        @title ||= noko.at_css('.lead').text.strip
      end

      def box_size
        @box_size ||= begin
          size = noko.at_css('option[selected]')
          size && size.text && size.text.strip
        end
      end

      def items
        @items ||= item_doc.css('li').map { |li| li.text.strip }
      end

      def to_s
        "#{title} #{box_size}".strip
      end

      private

      attr_reader :noko

      def item_doc
        @item_doc ||= Nokogiri::HTML(noko.at_css(item_selector)['data-content'])
      end

{'fraction_non_alphanumeric': 0.12021531100478469, 'fraction_numerical': 0.0023923444976076554, 'mean_word_length': 1.811764705882353, 'pattern_counts': {'":': 0, '<': 3, '<?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': '2879213', 'n_tokens_mistral': 578, 'n_tokens_neox': 548, 'n_words': 115}