texticle 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,13 @@
1
1
  === 1.0.0 / 2009-04-14
2
2
 
3
+ * 1 minor enhancement
4
+
5
+ * Textical adds a rake task to generate FTS index migrations. Just run:
6
+
7
+ rake textical:migration
8
+
9
+ === 1.0.0 / 2009-04-14
10
+
3
11
  * 1 major enhancement
4
12
 
5
13
  * Birthday!
@@ -14,13 +14,11 @@ named_scope methods making searching easy and fun!
14
14
 
15
15
  == SYNOPSIS:
16
16
 
17
- ###
18
- # In environment.rb
17
+ In environment.rb:
19
18
 
20
19
  config.gem 'texticle'
21
20
 
22
- ###
23
- # Declare your index in your model
21
+ Declare your index in your model:
24
22
 
25
23
  class Product < ActiveRecord::Base
26
24
  index do
@@ -29,21 +27,24 @@ named_scope methods making searching easy and fun!
29
27
  end
30
28
  end
31
29
 
32
- ###
33
- # Use the search method
30
+ Use the search method
34
31
 
35
32
  Product.search('hello world')
36
33
 
37
- ###
38
- # Full text searches can be sped up by creating indexes. To create the
39
- # indexes, add these lines to your Rakefile:
34
+ Full text searches can be sped up by creating indexes. To create the
35
+ indexes, add these lines to your Rakefile:
36
+
40
37
  require 'rubygems'
41
38
  require 'texticle/tasks'
42
39
 
43
- # Then run:
40
+ Then run:
44
41
 
45
42
  $ rake texticle:create_indexes
46
43
 
44
+ Alternatively, you can create a migration that will build your indexes:
45
+
46
+ $ rake texticle:migration
47
+
47
48
  == REQUIREMENTS:
48
49
 
49
50
  * Texticle may be used outside rails, but works best with rails.
data/Rakefile CHANGED
@@ -3,14 +3,11 @@
3
3
  require 'rubygems'
4
4
  require 'hoe'
5
5
 
6
- $: << "lib"
7
- require 'texticle'
8
-
9
- Hoe.new('texticle', Texticle::VERSION) do |p|
10
- p.developer('Aaron Patterson', 'aaronp@rubyforge.org')
11
- p.readme_file = 'README.rdoc'
12
- p.history_file = 'CHANGELOG.rdoc'
13
- p.extra_rdoc_files = FileList['*.rdoc']
6
+ Hoe.spec 'texticle' do
7
+ developer('Aaron Patterson', 'aaronp@rubyforge.org')
8
+ self.readme_file = 'README.rdoc'
9
+ self.history_file = 'CHANGELOG.rdoc'
10
+ self.extra_rdoc_files = FileList['*.rdoc']
14
11
  end
15
12
 
16
13
  # vim: syntax=Ruby
@@ -48,7 +48,7 @@ require 'texticle/full_text_index'
48
48
  # end
49
49
  module Texticle
50
50
  # The version of Texticle you are using.
51
- VERSION = '1.0.0'
51
+ VERSION = '1.0.1'
52
52
 
53
53
  # A list of full text indexes
54
54
  attr_accessor :full_text_indexes
@@ -12,17 +12,23 @@ module Texticle
12
12
  end
13
13
 
14
14
  def create
15
- @model_class.connection.execute(<<-eosql)
15
+ @model_class.connection.execute create_sql
16
+ end
17
+
18
+ def destroy
19
+ @model_class.connection.execute destroy_sql
20
+ end
21
+
22
+ def create_sql
23
+ <<-eosql
16
24
  CREATE index #{@name}
17
25
  ON #{@model_class.table_name}
18
26
  USING gin((#{to_s}))
19
27
  eosql
20
28
  end
21
29
 
22
- def destroy
23
- @model_class.connection.execute(<<-eosql)
24
- DROP index IF EXISTS #{@name}
25
- eosql
30
+ def destroy_sql
31
+ "DROP index IF EXISTS #{@name}"
26
32
  end
27
33
 
28
34
  def to_s
@@ -2,6 +2,33 @@ require 'rake'
2
2
  require 'texticle'
3
3
 
4
4
  namespace :texticle do
5
+ desc "Create full text index migration"
6
+ task :migration => :environment do
7
+ now = Time.now
8
+ filename = "#{now.strftime('%Y%m%d%H%m%S')}_full_text_search_#{now.to_i}.rb"
9
+ File.open(File.join(RAILS_ROOT, 'db', 'migrate', filename), 'wb') { |fh|
10
+ fh.puts "class FullTextSearch#{now.to_i} < ActiveRecord::Migration"
11
+ fh.puts " def self.up"
12
+ Dir[File.join(RAILS_ROOT, 'app', 'models', '*.rb')].each do |f|
13
+ klass = File.basename(f, '.rb').classify.constantize
14
+ if klass.respond_to?(:full_text_indexes)
15
+ (klass.full_text_indexes || []).each do |fti|
16
+ fh.puts <<-eostmt
17
+ ActiveRecord::Base.connection.execute(<<-'eosql')
18
+ #{fti.destroy_sql}
19
+ eosql
20
+ ActiveRecord::Base.connection.execute(<<-'eosql')
21
+ #{fti.create_sql}
22
+ eosql
23
+ eostmt
24
+ end
25
+ end
26
+ end
27
+ fh.puts " end"
28
+ fh.puts "end"
29
+ }
30
+ end
31
+
5
32
  desc "Create full text indexes"
6
33
  task :create_indexes => ['texticle:destroy_indexes'] do
7
34
  Dir[File.join(RAILS_ROOT, 'app', 'models', '*.rb')].each do |f|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: texticle
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Patterson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-15 00:00:00 -07:00
12
+ date: 2009-10-16 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.12.1
23
+ version: 2.3.3
24
24
  version:
25
25
  description: |-
26
26
  Texticle exposes full text search capabilities from PostgreSQL, and allows
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  requirements: []
75
75
 
76
76
  rubyforge_project: texticle
77
- rubygems_version: 1.3.2
77
+ rubygems_version: 1.3.5
78
78
  signing_key:
79
79
  specification_version: 3
80
80
  summary: Texticle exposes full text search capabilities from PostgreSQL, and allows you to declare full text indexes