riddle 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/riddle.rb CHANGED
@@ -2,16 +2,25 @@ require 'socket'
2
2
  require 'timeout'
3
3
 
4
4
  module Riddle #:nodoc:
5
+ @@mutex = Mutex.new
6
+ @@escape_pattern = /[\(\)\|\-!@~"&\/]/
7
+
5
8
  class ConnectionError < StandardError #:nodoc:
6
9
  #
7
10
  end
8
11
 
12
+ def self.mutex
13
+ @@mutex
14
+ end
15
+
9
16
  def self.escape_pattern
10
- Thread.current[:riddle_escape_pattern] ||= /[\(\)\|\-!@~"&\/]/
17
+ @@escape_pattern
11
18
  end
12
19
 
13
20
  def self.escape_pattern=(pattern)
14
- Thread.current[:riddle_escape_pattern] = pattern
21
+ mutex.synchronize do
22
+ @@escape_pattern = pattern
23
+ end
15
24
  end
16
25
 
17
26
  def self.escape(string)
@@ -6,13 +6,10 @@ class Riddle::AutoVersion
6
6
  case version
7
7
  when '0.9.8', '0.9.9'
8
8
  require "riddle/#{version}"
9
- when '1.10-beta', '1.10-id64-beta', '1.10-dev'
9
+ when /1.10/
10
10
  require 'riddle/1.10'
11
11
  when /2.0.1/
12
12
  require 'riddle/2.0.1'
13
- else
14
- puts "found version: #{version}"
15
- exit
16
13
  end
17
14
  end
18
15
  end
data/lib/riddle/client.rb CHANGED
@@ -123,12 +123,16 @@ module Riddle
123
123
  :connection, :key
124
124
  attr_reader :queue
125
125
 
126
+ @@connection = nil
127
+
126
128
  def self.connection=(value)
127
- Thread.current[:riddle_connection] = value
129
+ Riddle.mutex.synchronize do
130
+ @@connection = value
131
+ end
128
132
  end
129
133
 
130
134
  def self.connection
131
- Thread.current[:riddle_connection]
135
+ @@connection
132
136
  end
133
137
 
134
138
  # Can instantiate with a specific server and port - otherwise it assumes
@@ -28,6 +28,7 @@ module Riddle
28
28
 
29
29
  def start
30
30
  return if running?
31
+ check_for_configuration_file
31
32
 
32
33
  cmd = "#{searchd} --pidfile --config \"#{@path}\""
33
34
 
@@ -46,6 +47,7 @@ module Riddle
46
47
 
47
48
  def stop
48
49
  return true unless running?
50
+ check_for_configuration_file
49
51
 
50
52
  stop_flag = 'stopwait'
51
53
  stop_flag = 'stop' if Riddle.loaded_version.split('.').first == '0'
@@ -83,5 +85,10 @@ module Riddle
83
85
  def searchd
84
86
  "#{bin_path}#{searchd_binary_name}"
85
87
  end
88
+
89
+ def check_for_configuration_file
90
+ return if File.exist?(@path)
91
+ raise "Configuration file '#{@path}' does not exist"
92
+ end
86
93
  end
87
94
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: riddle
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.3.0
5
+ version: 1.3.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Pat Allan
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-07 00:00:00 +10:00
13
+ date: 2011-05-09 00:00:00 +10:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -136,7 +136,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
- hash: 2692990953322091417
139
+ hash: 4547098215792839825
140
140
  segments:
141
141
  - 0
142
142
  version: "0"