Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 7a9c3a98aedb1c6b868f6b8dcfc7836296cff323 0 parents
@tenderlove tenderlove authored
23 .autotest
@@ -0,0 +1,23 @@
+# -*- ruby -*-
+
+require 'autotest/restart'
+
+# Autotest.add_hook :initialize do |at|
+# at.extra_files << "../some/external/dependency.rb"
+#
+# at.libs << ":../some/external"
+#
+# at.add_exception 'vendor'
+#
+# at.add_mapping(/dependency.rb/) do |f, _|
+# at.files_matching(/test_.*rb$/)
+# end
+#
+# %w(TestA TestB).each do |klass|
+# at.extra_class_map[klass] = "test/test_misc.rb"
+# end
+# end
+
+# Autotest.add_hook :run_command do |at|
+# system "rake build"
+# end
3  .gitignore
@@ -0,0 +1,3 @@
+.*.swp
+*.tmproj
+tags
6 History.txt
@@ -0,0 +1,6 @@
+=== 1.0.0 / 2009-04-14
+
+* 1 major enhancement
+
+ * Birthday!
+
7 Manifest.txt
@@ -0,0 +1,7 @@
+History.txt
+Manifest.txt
+README.txt
+Rakefile
+bin/texticle
+lib/texticle.rb
+test/test_texticle.rb
48 README.txt
@@ -0,0 +1,48 @@
+= texticle
+
+* FIX (url)
+
+== DESCRIPTION:
+
+FIX (describe your package)
+
+== FEATURES/PROBLEMS:
+
+* FIX (list of features or problems)
+
+== SYNOPSIS:
+
+ FIX (code sample of usage)
+
+== REQUIREMENTS:
+
+* FIX (list of requirements)
+
+== INSTALL:
+
+* FIX (sudo gem install, anything else)
+
+== LICENSE:
+
+(The MIT License)
+
+Copyright (c) 2009 FIX
+
+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.
11 Rakefile
@@ -0,0 +1,11 @@
+# -*- ruby -*-
+
+require 'rubygems'
+require 'hoe'
+require './lib/texticle.rb'
+
+Hoe.new('texticle', Texticle::VERSION) do |p|
+ p.developer('Aaron Patterson', 'aaronp@rubyforge.org')
+end
+
+# vim: syntax=Ruby
3  bin/texticle
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+
+abort "you need to write me"
22 lib/texticle.rb
@@ -0,0 +1,22 @@
+require 'texticle/full_text_index'
+
+module Texticle
+ VERSION = '1.0.0'
+
+ attr_accessor :full_text_indexes
+
+ def index &block
+ class_eval(<<-eoruby)
+ named_scope :search, lambda { |term|
+ {
+ :select => "*, ts_rank_cd((\#{full_text_indexes.first.to_s}),
+ plainto_tsquery(\#{connection.quote(term)\})) as rank",
+ :conditions =>
+ ["\#{full_text_indexes.first.to_s} @@ plainto_tsquery(?)", term],
+ :order => 'rank DESC'
+ }
+ }
+ eoruby
+ (self.full_text_indexes ||= []) << FullTextIndex.new
+ end
+end
4 lib/texticle/full_text_index.rb
@@ -0,0 +1,4 @@
+module Texticle
+ class FullTextIndex
+ end
+end
21 test/test_texticle.rb
@@ -0,0 +1,21 @@
+require "test/unit"
+require "texticle"
+
+class TestTexticle < Test::Unit::TestCase
+ def test_index_method
+ x = Class.new {
+ extend Texticle
+ class << self; attr_accessor :ns; end
+
+ def self.named_scope *args
+ self.ns = [args]
+ end
+
+ index do
+ name
+ end
+ }
+ assert_equal 1, x.full_text_indexes.length
+ assert_equal 1, x.ns.length
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.