<commit_before># Ruth Gemfile what
module Ruth
  # Gemfile generator
  class Gemfile
    # Hash parser
    class Hash
      attr_accessor :file, :gem, :gemfile
      attr_writer :data

      def initialize
        @gem = []
      end

      # Public - Generate Gemfile contents
      #
      # Returns Array
      def output
        parse_gemfile_item
        @gem.join("\n")
      end

      private

      # Private  - Go trough provided keys and generate output
      #
      # Returns nil
      def parse_gemfile_item
        @data.keys.map do |key|
          case key
          when :source then sources
          when :general then general_list
          when :group then group_list
          end
        end
      end

      # Private - Fill in source list
      #
      # Returns nil
      def sources
        case @data[:source]
        when String then gem << "source '#{@data[:source]}"
        when Array then @data[:source].each { |h| @gem << "source '#{h}'" }
        end
      end

      # Private - Generate gem list depending on type
      #
      # Returns nil
      def general_list
        @data[:general].each { |g| gem_list(g) }
      end

      # Private - Generate gem group
      #
      # Returns nil
      def group_list
        @data[:group].each do |group|
          @gem << gem_group(group[:group_name])
          group[:gems].each { |item| gem_list(item, true) }
          @gem << 'end'
        end
      end

      # Private - Create gem listing from a provided Array or Hash
      #
      # item - Array or Hash gem list
      # tab - nil/true add tab indentation
      #
      # Returns nil
      def gem_list(item, tab = nil)
        item.key?(:name)
      rescue NoMethodError
        @gem << format_gem_item(item, tab)
      else
        @gem << detailed_gem_list(item, tab)
      end<commit_msg>More fixorz<commit_after># Ruth Gemfile what
module Ruth
  # Gemfile generator
  class Gemfile
    # Hash parser
    class Hash
      attr_accessor :file, :gem, :gemfile
      attr_writer :data

      def initialize
        @gem = []
      end

      # Public - Generate Gemfile contents
      #
      # Returns Array
      def output
        parse_gemfile_item
        @gem.join("\n")
      end

      private

      # Private  - Go trough provided keys and generate output
      #
      # Returns nil
      def parse_gemfile_item
        @data.keys.map do |key|
          case key
          when :source then sources
          when :general then general_list
          when :group then group_list
          end
        end
      end

      # Private - Fill in source list
      #
      # Returns nil
      def sources
        case @data[:source]
        when String then gem << "source '#{@data[:source]}"
        when Array then @data[:source].each { |h| @gem << "source '#{h}'" }
        end
        @gem << ''
      end

      # Private - Generate gem list depending on type
      #
      # Returns nil
      def general_list
        @data[:general].each { |g| gem_list(g) }
      end

      # Private - Generate gem group
      #
      # Returns nil
      def group_list
        @data[:group].each do |group|
          @gem << gem_group(group[:group_name])
          group[:gems].each { |item| gem_list(item, true) }
          @gem << "end\n"
        end
      end

      # Private - Create gem listing from a provided Array or Hash
      #
      # item - Array or Hash gem list
      # tab - nil/true add tab indentation
      #
      # Returns nil
      def gem_list(item, tab = nil)
        item.key?(:name)
      rescue NoMethodError
        @gem << format_gem_item(item, tab)
      else
        @gem << detailed_gem_list(item, tab)
      end
{'fraction_non_alphanumeric': 0.08792401628222524, 'fraction_numerical': 0.0, 'mean_word_length': 1.6328571428571428, 'pattern_counts': {'":': 0, '<': 29, '<?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': '4285781', 'n_tokens_mistral': 1060, 'n_tokens_neox': 1041, 'n_words': 339}