Permalink
Browse files

proper hook code for loading config/aaf.rb

  • Loading branch information...
1 parent fb2d5ed commit f8f086fb25929cd7d316266ff7a0e06423ab2999 @jkraemer committed Aug 3, 2010
Showing with 25 additions and 33 deletions.
  1. +5 −9 acts_as_ferret.gemspec
  2. +0 −24 init.rb
  3. +4 −0 lib/acts_as_ferret.rb
  4. +12 −0 lib/acts_as_ferret/railtie.rb
  5. +4 −0 rails/init.rb
View
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
s.has_rdoc = true
- s.rdoc_options = ["--charset=UTF-8"]
+ s.rdoc_options << "--charset=UTF-8" << '--title' << 'ActsAsFeret - Ferret powered full text search for Rails' << '--main' << 'README'
s.extra_rdoc_files = [
@@ -42,20 +42,16 @@ Gem::Specification.new do |s|
]
s.test_files = Dir['test/**/*rb']
s.files = [
+ '*rb',
+ 'README',
+ 'LICENSE',
'bin/*',
'config/*',
'doc/**/*',
'recipes/*',
'script/*',
'tasks/*',
'lib/**/*rb'
- ].map{|p| Dir[p]}.flatten +
- [
- 'acts_as_ferret.gemspec',
- 'init.rb',
- 'install.rb',
- 'README',
- 'LICENSE',
- ]
+ ].map{|p| Dir[p]}.flatten
end
View
24 init.rb
@@ -1,24 +0,0 @@
-# Copyright (c) 2006 Kasper Weibel Nielsen-Refs, Thomas Lockney, Jens Krämer
-#
-# Permission is hereby granted, free of charge, to any person obtaining a copy
-# of this software and associated documentation files (the "Software"), to deal
-# in the Software without restriction, including without limitation the rights
-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-# copies of the Software, and to permit persons to whom the Software is
-# furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in all
-# copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-# SOFTWARE.
-
-require 'acts_as_ferret'
-
-config.after_initialize { ActsAsFerret::load_config }
-config.to_prepare { ActsAsFerret::load_config }
View
@@ -89,6 +89,8 @@
#
module ActsAsFerret
+ require 'acts_as_ferret/railtie' if defined?(Rails)
+
class ActsAsFerretError < StandardError; end
class IndexNotDefined < ActsAsFerretError; end
class IndexAlreadyDefined < ActsAsFerretError; end
@@ -589,3 +591,5 @@ def self.field_config_for(fieldname, options = {})
# include acts_as_ferret method into ActiveRecord::Base
ActiveRecord::Base.extend ActsAsFerret::ActMethods
+
+
@@ -0,0 +1,12 @@
+require 'acts_as_ferret'
+require 'rails'
+
+module ActsAsFerret
+
+ class Railtie < Rails::Railtie
+
+ config.to_prepare { ActsAsFerret::load_config }
+
+ end
+
+end
View
@@ -0,0 +1,4 @@
+require 'acts_as_ferret'
+
+# load config/aaf.rb
+config.to_prepare { ActsAsFerret::load_config }

0 comments on commit f8f086f

Please sign in to comment.