acts_as_ferret 0.4.8.rails3 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- data/acts_as_ferret.gemspec +1 -2
- data/config/ferret_server.yml +2 -2
- data/lib/act_methods.rb +1 -1
- data/lib/acts_as_ferret.rb +6 -6
- data/lib/ferret_server.rb +9 -9
- data/lib/server_manager.rb +5 -5
- data/lib/unix_daemon.rb +1 -1
- metadata +2 -3
data/acts_as_ferret.gemspec
CHANGED
data/config/ferret_server.yml
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
# host: where to reach the DRb server (used by application processes to contact the server)
|
3
3
|
# port: which port the server should listen on
|
4
4
|
# socket: where the DRb server should create the socket (absolute path), this setting overrides host:port configuration
|
5
|
-
# pid_file: location of the server's pid file (relative to
|
6
|
-
# log_file: log file (default:
|
5
|
+
# pid_file: location of the server's pid file (relative to RAILS_ROOT)
|
6
|
+
# log_file: log file (default: RAILS_ROOT/log/ferret_server.log
|
7
7
|
# log_level: log level for the server's logger
|
8
8
|
production:
|
9
9
|
host: localhost
|
data/lib/act_methods.rb
CHANGED
@@ -26,7 +26,7 @@ module ActsAsFerret #:nodoc:
|
|
26
26
|
# to determine if it should be indexed or not.
|
27
27
|
#
|
28
28
|
# index_dir:: declares the directory where to put the index for this class.
|
29
|
-
# The default is
|
29
|
+
# The default is RAILS_ROOT/index/RAILS_ENV/CLASSNAME.
|
30
30
|
# The index directory will be created if it doesn't exist.
|
31
31
|
#
|
32
32
|
# reindex_batch_size:: reindexing is done in batches of this size, default is 1000
|
data/lib/acts_as_ferret.rb
CHANGED
@@ -82,7 +82,7 @@ require 'rdig_adapter'
|
|
82
82
|
# whatever reason.
|
83
83
|
#
|
84
84
|
# remote:: Set this to false to force acts_as_ferret into local (non-DRb) mode even if
|
85
|
-
# config/ferret_server.yml contains a section for the current
|
85
|
+
# config/ferret_server.yml contains a section for the current RAILS_ENV
|
86
86
|
# Usually you won't need to touch this option - just configure DRb for
|
87
87
|
# production mode in ferret_server.yml.
|
88
88
|
#
|
@@ -107,7 +107,7 @@ module ActsAsFerret
|
|
107
107
|
@@index_using_classes = {}
|
108
108
|
def self.index_using_classes; @@index_using_classes end
|
109
109
|
|
110
|
-
@@logger = Logger.new "#{
|
110
|
+
@@logger = Logger.new "#{RAILS_ROOT}/log/acts_as_ferret.log"
|
111
111
|
@@logger.level = ActiveRecord::Base.logger.level rescue Logger::DEBUG
|
112
112
|
mattr_accessor :logger
|
113
113
|
|
@@ -255,7 +255,7 @@ module ActsAsFerret
|
|
255
255
|
|
256
256
|
def self.load_config
|
257
257
|
# using require_dependency to make the reloading in dev mode work.
|
258
|
-
require_dependency "#{
|
258
|
+
require_dependency "#{RAILS_ROOT}/config/aaf.rb"
|
259
259
|
ActsAsFerret::logger.info "loaded configuration file aaf.rb"
|
260
260
|
rescue LoadError
|
261
261
|
ensure
|
@@ -518,10 +518,10 @@ module ActsAsFerret
|
|
518
518
|
|
519
519
|
|
520
520
|
# make sure the default index base dir exists. by default, all indexes are created
|
521
|
-
# under
|
521
|
+
# under RAILS_ROOT/index/RAILS_ENV
|
522
522
|
def self.init_index_basedir
|
523
|
-
index_base = "#{
|
524
|
-
@@index_dir = "#{index_base}/#{
|
523
|
+
index_base = "#{RAILS_ROOT}/index"
|
524
|
+
@@index_dir = "#{index_base}/#{RAILS_ENV}"
|
525
525
|
end
|
526
526
|
|
527
527
|
mattr_accessor :index_dir
|
data/lib/ferret_server.rb
CHANGED
@@ -14,9 +14,9 @@ module ActsAsFerret
|
|
14
14
|
DEFAULTS = {
|
15
15
|
'host' => 'localhost',
|
16
16
|
'port' => '9009',
|
17
|
-
'cf' => "#{
|
18
|
-
'pid_file' => "#{
|
19
|
-
'log_file' => "#{
|
17
|
+
'cf' => "#{RAILS_ROOT}/config/ferret_server.yml",
|
18
|
+
'pid_file' => "#{RAILS_ROOT}/log/ferret_server.pid",
|
19
|
+
'log_file' => "#{RAILS_ROOT}/log/ferret_server.log",
|
20
20
|
'log_level' => 'debug',
|
21
21
|
'socket' => nil,
|
22
22
|
'script' => nil
|
@@ -27,8 +27,8 @@ module ActsAsFerret
|
|
27
27
|
def initialize (file=DEFAULTS['cf'])
|
28
28
|
@everything = YAML.load(ERB.new(IO.read(file)).result)
|
29
29
|
raise "malformed ferret server config" unless @everything.is_a?(Hash)
|
30
|
-
@config = DEFAULTS.merge(@everything[
|
31
|
-
if @everything[
|
30
|
+
@config = DEFAULTS.merge(@everything[RAILS_ENV] || {})
|
31
|
+
if @everything[RAILS_ENV]
|
32
32
|
@config['uri'] = socket.nil? ? "druby://#{host}:#{port}" : "drbunix:#{socket}"
|
33
33
|
end
|
34
34
|
end
|
@@ -46,7 +46,7 @@ module ActsAsFerret
|
|
46
46
|
# search requests from models declared to 'acts_as_ferret :remote => true'
|
47
47
|
#
|
48
48
|
# Usage:
|
49
|
-
# - modify
|
49
|
+
# - modify RAILS_ROOT/config/ferret_server.yml to suit your needs.
|
50
50
|
# - environments for which no section in the config file exists will use
|
51
51
|
# the index locally (good for unit tests/development mode)
|
52
52
|
# - run script/ferret_server to start the server:
|
@@ -73,7 +73,7 @@ module ActsAsFerret
|
|
73
73
|
ActiveRecord::Base.logger = @logger = Logger.new(@cfg.log_file)
|
74
74
|
ActiveRecord::Base.logger.level = Logger.const_get(@cfg.log_level.upcase) rescue Logger::DEBUG
|
75
75
|
if @cfg.script
|
76
|
-
path = File.join(
|
76
|
+
path = File.join(RAILS_ROOT, @cfg.script)
|
77
77
|
load path
|
78
78
|
@logger.info "loaded custom startup script from #{path}"
|
79
79
|
end
|
@@ -82,14 +82,14 @@ module ActsAsFerret
|
|
82
82
|
################################################################################
|
83
83
|
# start the server as a daemon process
|
84
84
|
def start
|
85
|
-
raise "ferret_server not configured for #{
|
85
|
+
raise "ferret_server not configured for #{RAILS_ENV}" unless (@cfg.uri rescue nil)
|
86
86
|
platform_daemon { run_drb_service }
|
87
87
|
end
|
88
88
|
|
89
89
|
################################################################################
|
90
90
|
# run the server and block until it exits
|
91
91
|
def run
|
92
|
-
raise "ferret_server not configured for #{
|
92
|
+
raise "ferret_server not configured for #{RAILS_ENV}" unless (@cfg.uri rescue nil)
|
93
93
|
run_drb_service
|
94
94
|
end
|
95
95
|
|
data/lib/server_manager.rb
CHANGED
@@ -17,11 +17,11 @@ OptionParser.new do |optparser|
|
|
17
17
|
exit
|
18
18
|
end
|
19
19
|
|
20
|
-
optparser.on('-R', '--root=PATH', 'Set
|
20
|
+
optparser.on('-R', '--root=PATH', 'Set RAILS_ROOT to the given string') do |r|
|
21
21
|
$ferret_server_options['root'] = r
|
22
22
|
end
|
23
23
|
|
24
|
-
optparser.on('-e', '--environment=NAME', 'Set
|
24
|
+
optparser.on('-e', '--environment=NAME', 'Set RAILS_ENV to the given string') do |e|
|
25
25
|
$ferret_server_options['environment'] = e
|
26
26
|
end
|
27
27
|
|
@@ -53,12 +53,12 @@ begin
|
|
53
53
|
ENV['FERRET_USE_LOCAL_INDEX'] = 'true'
|
54
54
|
ENV['RAILS_ENV'] = $ferret_server_options['environment']
|
55
55
|
# determine RAILS_ROOT unless already set
|
56
|
-
|
56
|
+
RAILS_ROOT = determine_rails_root unless defined?(RAILS_ROOT)
|
57
57
|
|
58
58
|
begin
|
59
|
-
require File.join(
|
59
|
+
require File.join(RAILS_ROOT, 'config', 'environment')
|
60
60
|
rescue LoadError
|
61
|
-
puts "Unable to find Rails environment.rb in any of these locations:\n#{possible_rails_roots.join("\n")}\nPlease use the --root option of ferret_server to point it to your
|
61
|
+
puts "Unable to find Rails environment.rb in any of these locations:\n#{possible_rails_roots.join("\n")}\nPlease use the --root option of ferret_server to point it to your RAILS_ROOT."
|
62
62
|
raise $!
|
63
63
|
end
|
64
64
|
|
data/lib/unix_daemon.rb
CHANGED
@@ -13,7 +13,7 @@ module ActsAsFerret
|
|
13
13
|
trap("TERM") { exit(0) }
|
14
14
|
sess_id = Process.setsid
|
15
15
|
STDIN.reopen("/dev/null")
|
16
|
-
STDOUT.reopen("#{
|
16
|
+
STDOUT.reopen("#{RAILS_ROOT}/log/ferret_server.out", "a")
|
17
17
|
STDERR.reopen(STDOUT)
|
18
18
|
block.call
|
19
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_ferret
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
9
|
- 8
|
10
|
-
|
11
|
-
version: 0.4.8.rails3
|
10
|
+
version: 0.4.8
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- Jens Kraemer
|