Sha256: 814c1f45a6fd3bc7b97cc186fa2251c63b6b81c3f386b69d5ea70206bd93e1d2

Contents?: true

Size: 756 Bytes

Versions: 3

Compression:

Stored size: 756 Bytes

Contents

require 'uri'
require 'multi_json'
require 'redis'

require 'soulmate/version'
require 'soulmate/helpers'
require 'soulmate/base'
require 'soulmate/matcher'
require 'soulmate/loader'

module Soulmate

  extend self

  MIN_COMPLETE = 2
  DEFAULT_STOP_WORDS = ["vs", "at", "the"]

  def redis=(url)
    @redis = nil
    @redis_url = url
    redis
  end

  def redis
    @redis ||= (
      url = URI(@redis_url || ENV["REDIS_URL"] || "redis://127.0.0.1:6379/0")

      ::Redis.new({
        :host => url.host,
        :port => url.port,
        :db => url.path[1..-1],
        :password => url.password
      })
    )
  end

  def stop_words
    @stop_words ||= DEFAULT_STOP_WORDS
  end

  def stop_words=(arr)
    @stop_words = Array(arr).flatten
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
soulmate-1.0.0 lib/soulmate.rb
soulmate-0.1.3 lib/soulmate.rb
soulmate-0.1.2 lib/soulmate.rb