<commit_before>require 'sass'
require 'sass/scss/rx'
class SassyHashException < Exception; end
class SassyHash < Hash
  VERSION = "0.0.5"
  VALID_UNIT = %r{(?<unit>#{::Sass::SCSS::RX::NMSTART}#{::Sass::SCSS::RX::NMCHAR}|%*)}
  VALID_NUMBER = %r{((?<float>^[0-9]*\.[0-9]+)|(?<int>^[0-9]+))#{VALID_UNIT}}
  def self.[](hash_values)
    super(hash_values).tap do |hash|
      hash.sassify!
    end
  end

  def initialize(*args)
    super(args).tap do |hash|
      hash.sassify!
    end
  end

  def sassify!
    keys.each do |key|
      new_key = self.class.sass_convert_value(key.to_s)
      self[new_key] = self.class.sass_convert_value(delete(key))
    end
  end


  def []=(key, value)
    key = self.class.sass_convert_value(key.to_s)
    value = self.class.sass_convert_value(value)
    super(key, value)
  end

  def self.sass_convert_value(value)
    case value
    when Integer, Fixnum<commit_msg>version bum 0.0.6<commit_after>require 'sass'
require 'sass/scss/rx'
class SassyHashException < Exception; end
class SassyHash < Hash
  VERSION = "0.0.6"
  VALID_UNIT = %r{(?<unit>#{::Sass::SCSS::RX::NMSTART}#{::Sass::SCSS::RX::NMCHAR}|%*)}
  VALID_NUMBER = %r{((?<float>^[0-9]*\.[0-9]+)|(?<int>^[0-9]+))#{VALID_UNIT}}
  def self.[](hash_values)
    super(hash_values).tap do |hash|
      hash.sassify!
    end
  end

  def initialize(*args)
    super(args).tap do |hash|
      hash.sassify!
    end
  end

  def sassify!
    keys.each do |key|
      new_key = self.class.sass_convert_value(key.to_s)
      self[new_key] = self.class.sass_convert_value(delete(key))
    end
  end


  def []=(key, value)
    key = self.class.sass_convert_value(key.to_s)
    value = self.class.sass_convert_value(value)
    super(key, value)
  end

  def self.sass_convert_value(value)
    case value
    when Integer, Fixnum
{'fraction_non_alphanumeric': 0.16887417218543047, 'fraction_numerical': 0.011589403973509934, 'mean_word_length': 3.660668380462725, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 9, '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': '4579731', 'n_tokens_mistral': 749, 'n_tokens_neox': 724, 'n_words': 123}