<commit_before>require 'httparty'
require 'multi_json'
require 'logger'
require 'elastic_searchable/active_record_extensions'

module ElasticSearchable
  include HTTParty
  format :json
  base_uri 'localhost:9200'

  class ElasticError < StandardError; end
  class << self
    attr_accessor :logger, :index_name, :index_settings, :offline

    # execute a block of work without reindexing objects
    def offline(&block)
      @offline = true
      yield
    ensure
      @offline = false
    end
    def offline?
      !!@offline
    end
    # encapsulate encoding hash into json string
    # support Yajl encoder if installed
    def encode_json(options = {})
      MultiJson.encode options
    end<commit_msg>As per my suggestion in #16 — prefer `ENV['ELASTICSEARCH_URL']` as the default when it is present.<commit_after>require 'httparty'
require 'multi_json'
require 'logger'
require 'elastic_searchable/active_record_extensions'

module ElasticSearchable
  include HTTParty
  format :json
  base_uri ENV['ELASTICSEARCH_URL'] || 'localhost:9200'

  class ElasticError < StandardError; end
  class << self
    attr_accessor :logger, :index_name, :index_settings, :offline

    # execute a block of work without reindexing objects
    def offline(&block)
      @offline = true
      yield
    ensure
      @offline = false
    end
    def offline?
      !!@offline
    end
    # encapsulate encoding hash into json string
    # support Yajl encoder if installed
    def encode_json(options = {})
      MultiJson.encode options
    end
{'fraction_non_alphanumeric': 0.07091737150292778, 'fraction_numerical': 0.006506180871828237, 'mean_word_length': 3.5102639296187683, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4088780', 'n_tokens_mistral': 467, 'n_tokens_neox': 449, 'n_words': 143}