From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.90.117.16 with SMTP id p16cs279401agc; Mon, 19 Oct 2009 23:14:12 -0700 (PDT) Received: by 10.224.1.11 with SMTP id 11mr3029468qad.357.1256019251441; Mon, 19 Oct 2009 23:14:11 -0700 (PDT) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id 2si4599451qyk.9.2009.10.19.23.14.11; Mon, 19 Oct 2009 23:14:11 -0700 (PDT) Received-SPF: pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-talk-bounces@rubyforge.org Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 341BF18582F1; Tue, 20 Oct 2009 02:14:11 -0400 (EDT) Received: from magnesium.club.cc.cmu.edu (MAGNESIUM.CLUB.CC.cmu.edu [128.237.157.15]) by rubyforge.org (Postfix) with ESMTP id 9764018582D2 for ; Tue, 20 Oct 2009 02:14:08 -0400 (EDT) Received: (qmail 16237 invoked from network); 20 Oct 2009 06:14:08 -0000 Received: from pion.club.cc.cmu.edu (HELO localhost.localdomain) (128.237.157.88) by magnesium.club.cc.cmu.edu with SMTP; 20 Oct 2009 06:14:08 -0000 From: Rich Lane To: sup-talk@rubyforge.org Date: Mon, 19 Oct 2009 23:14:07 -0700 Message-Id: <1256019247-6046-1-git-send-email-rlane@club.cc.cmu.edu> X-Mailer: git-send-email 1.6.4.2 In-Reply-To: <20091012223449.GB31940@tilus.net> References: <20091012223449.GB31940@tilus.net> Subject: [sup-talk] [PATCH] xapian: replace DocumentMethods module with plain monkeypatching X-BeenThere: sup-talk@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: User & developer discussion of Sup List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-talk-bounces@rubyforge.org Errors-To: sup-talk-bounces@rubyforge.org --- lib/sup/xapian_index.rb | 47 ++++++++++++++++++++++------------------------- 1 files changed, 22 insertions(+), 25 deletions(-) diff --git a/lib/sup/xapian_index.rb b/lib/sup/xapian_index.rb index ad45b0e..34d67d5 100644 --- a/lib/sup/xapian_index.rb +++ b/lib/sup/xapian_index.rb @@ -565,35 +565,32 @@ EOS raise "Invalid term type #{type}" end end +end - module DocumentMethods - def entry - Marshal.load data - end - - def entry=(x) - self.data = Marshal.dump x - end +end - def index_text text, prefix, weight=1 - term_generator = Xapian::TermGenerator.new - term_generator.stemmer = Xapian::Stem.new(STEM_LANGUAGE) - term_generator.document = self - term_generator.index_text text, weight, prefix - end +class Xapian::Document + def entry + Marshal.load data + end - def add_term term - if term.length <= MAX_TERM_LENGTH - super term - else - warn "dropping excessively long term #{term}" - end - end + def entry=(x) + self.data = Marshal.dump x end -end -end + def index_text text, prefix, weight=1 + term_generator = Xapian::TermGenerator.new + term_generator.stemmer = Xapian::Stem.new(Redwood::XapianIndex::STEM_LANGUAGE) + term_generator.document = self + term_generator.index_text text, weight, prefix + end -class Xapian::Document - include Redwood::XapianIndex::DocumentMethods + alias old_add_term add_term + def add_term term + if term.length <= Redwood::XapianIndex::MAX_TERM_LENGTH + old_add_term term + else + warn "dropping excessively long term #{term}" + end + end end -- 1.6.4.2 _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk