<commit_before>require "sandstorm/version"

module Sandstorm

  ATTRIBUTE_TYPES  = {:string              => [String],
                      :integer             => [Integer],
                      :float               => [Float],
                      :id                  => [String],
                      :timestamp           => [Integer, Time, DateTime],
                      :boolean             => [TrueClass, FalseClass]
                     }

  COLLECTION_TYPES = {:list                => [Enumerable],
                      :set                 => [Set],
                      :hash                => [Hash],
                     }

  ALL_TYPES = ATTRIBUTE_TYPES.merge(COLLECTION_TYPES)

  class << self
    attr_accessor :redis
  end

  def self.valid_type?(type)
    ALL_TYPES.keys.include?(type)
  end

end
<commit_msg>redis connections stored thread & fiber-local<commit_after>require "sandstorm/version"

module Sandstorm

  ATTRIBUTE_TYPES  = {:string     => [String],
                      :integer    => [Integer],
                      :float      => [Float],
                      :id         => [String],
                      :timestamp  => [Integer, Time, DateTime],
                      :boolean    => [TrueClass, FalseClass],
                     }

  COLLECTION_TYPES = {:list       => [Enumerable],
                      :set        => [Set],
                      :hash       => [Hash],
                     }

  ALL_TYPES = ATTRIBUTE_TYPES.merge(COLLECTION_TYPES)

  class << self
    def valid_type?(type)
      ALL_TYPES.keys.include?(type)
    end

    # Thread and fiber-local
    def redis
      Thread.current[:sandstorm_redis]
    end

    def redis=(connection)
      Thread.current[:sandstorm_redis] = connection
    end
  end

end

{'fraction_non_alphanumeric': 0.10327313769751693, 'fraction_numerical': 0.0, 'mean_word_length': 1.235813366960908, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3168870', 'n_tokens_mistral': 497, 'n_tokens_neox': 470, 'n_words': 92}