phat_pgsearch 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -10,7 +10,7 @@ add to Gemfile
10
10
  == Configuration
11
11
 
12
12
  PhatPgsearch.setup do |config|
13
- # defaut catalog
13
+ # default catalog
14
14
  # config.catalog = :english
15
15
  end
16
16
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/lib/phat_pgsearch.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'active_support/all'
2
2
  require 'active_record'
3
3
  require 'active_record/connection_adapters/postgresql_adapter'
4
+
4
5
  module PhatPgsearch
5
6
  autoload :IndexDefinition, 'phat_pgsearch/index_definition'
6
7
  autoload :IndexBuilder, 'phat_pgsearch/index_builder'
@@ -18,6 +19,7 @@ module PhatPgsearch
18
19
  end
19
20
 
20
21
  def init
22
+ require 'phat_pgsearch/railties'
21
23
  ::ActiveRecord::ConnectionAdapters::TableDefinition.send(:include, PostgreSQL::TableDefinition)
22
24
  ::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.send(:include, PostgreSQL::SchemaStatements)
23
25
  ::ActiveRecord::ConnectionAdapters::PostgreSQLColumn.send(:include, PostgreSQL::PostgreSQLColumn)
@@ -49,6 +49,8 @@ module PhatPgsearch
49
49
 
50
50
  def pgsearch_query(*args)
51
51
  options = args.extract_options!
52
+ plain = options.delete(:plain)
53
+ plain = true if plain.nil?
52
54
  raise ArgumentError, "invalid field given" if args.first.nil? or not (args.first.is_a? String or args.first.is_a? Symbol)
53
55
  raise ArgumentError, "invalid query given" if args.second.nil? or not (args.second.is_a? String)
54
56
 
@@ -60,7 +62,6 @@ module PhatPgsearch
60
62
  begin
61
63
  table_class = field.first.classify.constantize
62
64
  rescue
63
- p field.first.classify
64
65
  raise ArgumentError, "unknown table in field given"
65
66
  end
66
67
  end
@@ -76,14 +77,19 @@ module PhatPgsearch
76
77
  catalog = options[:catalog] || definition.catalog
77
78
  end
78
79
 
79
- "plainto_tsquery(#{self.sanitize(catalog)}, #{self.sanitize(args.second)})"
80
+ "#{plain ? 'plain' : ''}to_tsquery(#{self.sanitize(catalog)}, #{self.sanitize(args.second)})"
81
+ end
82
+
83
+ # rebuild complete index for model
84
+ def rebuild_pgindex!
85
+ self.all.each { |model| model.rebuild_pgindex! }
80
86
  end
81
87
 
82
88
  end
83
89
 
84
90
  module InstanceMethods #:nodoc:
85
91
 
86
-
92
+ # rebuild pgindex für object without update timestamps
87
93
  def rebuild_pgindex!
88
94
  last_state = self.class.record_timestamps
89
95
  self.class.record_timestamps = false
@@ -102,4 +108,4 @@ module PhatPgsearch
102
108
 
103
109
  end
104
110
  end
105
- end
111
+ end
@@ -0,0 +1,13 @@
1
+ module PhatPgsearch
2
+ # namespace our plugin and inherit from Rails::Railtie
3
+ # to get our plugin into the initialization process
4
+ class Railtie < Rails::Railtie
5
+
6
+ # configure our plugin on boot. other extension points such
7
+ # as configuration, rake tasks, etc, are also available
8
+ initializer "phat_pgsearch.initialize" do |app|
9
+
10
+
11
+ end
12
+ end
13
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{phat_pgsearch}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Marco Scholl"]
12
- s.date = %q{2011-02-22}
12
+ s.date = %q{2011-06-21}
13
13
  s.description = %q{a plugin for tssearch support from postgresql}
14
14
  s.email = %q{develop@marco-scholl.de}
15
15
  s.extra_rdoc_files = [
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  "lib/phat_pgsearch/index_builder.rb",
31
31
  "lib/phat_pgsearch/index_definition.rb",
32
32
  "lib/phat_pgsearch/postgresql.rb",
33
+ "lib/phat_pgsearch/railties.rb",
33
34
  "phat_pgsearch.gemspec",
34
35
  "spec/active_record_spec.rb",
35
36
  "spec/phat_pgsearch_spec.rb",
@@ -39,7 +40,7 @@ Gem::Specification.new do |s|
39
40
  s.homepage = %q{http://github.com/phatworx/phat_pgsearch}
40
41
  s.licenses = ["MIT"]
41
42
  s.require_paths = ["lib"]
42
- s.rubygems_version = %q{1.5.0}
43
+ s.rubygems_version = %q{1.6.2}
43
44
  s.summary = %q{a postgresql based search plugin}
44
45
  s.test_files = [
45
46
  "spec/active_record_spec.rb",
metadata CHANGED
@@ -1,105 +1,102 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: phat_pgsearch
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.5
4
5
  prerelease:
5
- version: 0.1.4
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Marco Scholl
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-02-22 00:00:00 +01:00
12
+ date: 2011-06-21 00:00:00.000000000 +02:00
14
13
  default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: rails
18
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &17705040 !ruby/object:Gem::Requirement
19
18
  none: false
20
- requirements:
19
+ requirements:
21
20
  - - ~>
22
- - !ruby/object:Gem::Version
21
+ - !ruby/object:Gem::Version
23
22
  version: 3.0.0
24
23
  type: :runtime
25
24
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
25
+ version_requirements: *17705040
26
+ - !ruby/object:Gem::Dependency
28
27
  name: autotest
29
- requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirement: &17704380 !ruby/object:Gem::Requirement
30
29
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
35
34
  type: :development
36
35
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
36
+ version_requirements: *17704380
37
+ - !ruby/object:Gem::Dependency
39
38
  name: bundler
40
- requirement: &id003 !ruby/object:Gem::Requirement
39
+ requirement: &17703740 !ruby/object:Gem::Requirement
41
40
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "0"
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
46
45
  type: :development
47
46
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
47
+ version_requirements: *17703740
48
+ - !ruby/object:Gem::Dependency
50
49
  name: jeweler
51
- requirement: &id004 !ruby/object:Gem::Requirement
50
+ requirement: &17703080 !ruby/object:Gem::Requirement
52
51
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
57
56
  type: :development
58
57
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
58
+ version_requirements: *17703080
59
+ - !ruby/object:Gem::Dependency
61
60
  name: rspec
62
- requirement: &id005 !ruby/object:Gem::Requirement
61
+ requirement: &17702480 !ruby/object:Gem::Requirement
63
62
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: "0"
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
68
67
  type: :development
69
68
  prerelease: false
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
69
+ version_requirements: *17702480
70
+ - !ruby/object:Gem::Dependency
72
71
  name: yard
73
- requirement: &id006 !ruby/object:Gem::Requirement
72
+ requirement: &17701840 !ruby/object:Gem::Requirement
74
73
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
79
78
  type: :development
80
79
  prerelease: false
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
80
+ version_requirements: *17701840
81
+ - !ruby/object:Gem::Dependency
83
82
  name: pg
84
- requirement: &id007 !ruby/object:Gem::Requirement
83
+ requirement: &17700900 !ruby/object:Gem::Requirement
85
84
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
90
89
  type: :development
91
90
  prerelease: false
92
- version_requirements: *id007
91
+ version_requirements: *17700900
93
92
  description: a plugin for tssearch support from postgresql
94
93
  email: develop@marco-scholl.de
95
94
  executables: []
96
-
97
95
  extensions: []
98
-
99
- extra_rdoc_files:
96
+ extra_rdoc_files:
100
97
  - LICENSE.txt
101
98
  - README.rdoc
102
- files:
99
+ files:
103
100
  - .document
104
101
  - .rspec
105
102
  - Gemfile
@@ -113,6 +110,7 @@ files:
113
110
  - lib/phat_pgsearch/index_builder.rb
114
111
  - lib/phat_pgsearch/index_definition.rb
115
112
  - lib/phat_pgsearch/postgresql.rb
113
+ - lib/phat_pgsearch/railties.rb
116
114
  - phat_pgsearch.gemspec
117
115
  - spec/active_record_spec.rb
118
116
  - spec/phat_pgsearch_spec.rb
@@ -120,36 +118,34 @@ files:
120
118
  - spec/support/active_record.rb
121
119
  has_rdoc: true
122
120
  homepage: http://github.com/phatworx/phat_pgsearch
123
- licenses:
121
+ licenses:
124
122
  - MIT
125
123
  post_install_message:
126
124
  rdoc_options: []
127
-
128
- require_paths:
125
+ require_paths:
129
126
  - lib
130
- required_ruby_version: !ruby/object:Gem::Requirement
127
+ required_ruby_version: !ruby/object:Gem::Requirement
131
128
  none: false
132
- requirements:
133
- - - ">="
134
- - !ruby/object:Gem::Version
135
- hash: -884935242917167268
136
- segments:
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ segments:
137
134
  - 0
138
- version: "0"
139
- required_rubygems_version: !ruby/object:Gem::Requirement
135
+ hash: 30789052815081912
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
137
  none: false
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: "0"
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
145
142
  requirements: []
146
-
147
143
  rubyforge_project:
148
- rubygems_version: 1.5.0
144
+ rubygems_version: 1.6.2
149
145
  signing_key:
150
146
  specification_version: 3
151
147
  summary: a postgresql based search plugin
152
- test_files:
148
+ test_files:
153
149
  - spec/active_record_spec.rb
154
150
  - spec/phat_pgsearch_spec.rb
155
151
  - spec/spec_helper.rb