<commit_before>#
# Doing
#
#     require 'icss/brevity'
#
# makes the #inspect method on Icss::Type's be nice and readable, not GIGANTE
# PIQUANTE OY CABRON
#
#
module Icss
  Type.class_eval do
    def inspect_with_brevity
      ["#<#{self.class.name}",
        inspect_hsh.map{|k,v| "#{k}=#{v}" },
        ">",
      ].join(" ")
    end

  private
    def inspect_hsh
      {
        :name        => name,
        :type        => type,
        :doc         => "'#{(doc||"")[0..30].gsub(/[\n\t\r]+/,' ')}...'",
    }
    end
  end

  RecordType.class_eval do
    private
    # stuff a compact cartoon of the fields in there
    def inspect_hsh
      super.merge(
        :fields => (fields||[]).inject({}){|h,f| h[f.name] = f.type ; h }.inspect
        )
    end
  end

  Protocol.class_eval do
    def inspect
      ["#<#{self.class.name}",
        inspect_hsh.map{|k,v| "#{k}=#{v}" },
        ">"
      ].join(" ")
    end

    def inspect_hsh
      {
        :name        => name,
        :namespace   => namespace,
        :types       => (types||[]).map(&:name).inspect,
        :messages    => (messages||{}).values.map(&:name).inspect,
        :data_assets => (data_assets||[]).map(&:name).inspect,
        :doc         => "'#{(doc||"")[0..30].gsub(/[\n\t\r]+/,' ')}...'",
      }
    end
  end

end
<commit_msg>added fields for complex types<commit_after>#
# Doing
#
#     require 'icss/brevity'
#
# makes the #inspect method on Icss::Type's be nice and readable, not GIGANTE
# PIQUANTE OY CABRON
#
#
module Icss

  Protocol.class_eval do
    def inspect
      ["#<#{self.class.name}",
        inspect_hsh.map{|k,v| "#{k}=#{v}" },
        ">"
      ].join(" ")
    end

    def inspect_hsh
      {
        :name        => name,
        :namespace   => @namespace,
        :types       => (types||[]).map(&:name).inspect,
        :messages    => (messages||{}).values.map(&:name).inspect,
        :data_assets => (data_assets||[]).map(&:name).inspect,
        :doc         => "'#{(doc||"")[0..30].gsub(/[\n\t\r]+/,' ')}...'",
      }
    end
  end

  Message.class_eval do
    def inspect
      ["#<#{self.class.name}",
        inspect_hsh.map{|k,v| "#{k}=#{v}" },
        ">"
      ].join(" ")
    end

    private
    # stuff a compact cartoon of the fields in there
    def inspect_hsh
      {
        :name        => name,
        :types       => (types||[]).map(&:name).inspect,
        :messages    => (messages||{}).values.map(&:name).inspect,
        :data_assets => (data_assets||[]).map(&:name).inspect,
        :doc         => "'#{(doc||"")[0..30].gsub(/[\n\t\r]+/,' ')}...'",
      }
    end
  end

  Type.class_eval do
    def inspect
      ["#<#{self.class.name}",
        inspect_hsh.map{|k,v| "#{k}=#{v}" },
        (respond_to?(:type) ? type : nil),
        ">",
      ].compact.join(" ")
    end
  private
    def inspect_hsh
      { :name        => name,
        :doc         => "'#{(doc||"")[0..30].gsub(/[\n\t\r]+/,' ')}...'", }
    end
  end

  NamedType.class_eval do
    private
    def inspect_hsh
      super.merge( :namespace => @namespace )
    end
  end

  RecordType.class_eval do
    private
    def inspect_hsh
      super.merge( :fields  => (fields||[]).inject({}){|h,f| h[f.name] = f.type ; h }.inspect )
    end
  end

  EnumType.class_eval do
    private
    def inspect_hsh
      super.merge( :symbols => symbols.inspect )
    end
  end

  FixedType.class_eval do
    private
    def inspect_hsh
      super.merge( :size    => size.inspect )
    end
  end

  ArrayType.class_eval do
    private
    def inspect_hsh
      super.merge( :items   => items.inspect )
    end
  end

  MapType.class_eval do
    private
    def inspect_hsh
      super.merge( :values  => values.inspect )
    end
  end

end

{'fraction_non_alphanumeric': 0.1920405982905983, 'fraction_numerical': 0.004006410256410256, 'mean_word_length': 1.9280688037529319, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 37, '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': '2314674', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1351, 'n_words': 259}