ar-tsvectors 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source 'https://rubygems.org/'
2
2
  gemspec
data/README.md CHANGED
@@ -42,7 +42,7 @@ For queries to perform well, you must add an index on the column. This is slight
42
42
 
43
43
  The `ts_vector` mixin takes the following options:
44
44
 
45
- * `:configuation` - the name of the PostgreSQL text configuration to use. Defaults to `simple`, which is appropriate for keyword-type indexing.
45
+ * `:configuration` - the name of the PostgreSQL text configuration to use. Defaults to `simple`, which is appropriate for keyword-type indexing.
46
46
  * `:format` - the format of the column, must be either `:text` (the default) or `:tsvector`.
47
47
  * `:normalize` - a proc that overrides the default normalization. It must take a single string and return a normalized copy of the string.
48
48
 
@@ -1,6 +1,8 @@
1
1
  module TsVectors
2
2
 
3
3
  class Attribute
4
+ FORMATS = [:text, :tsvector]
5
+
4
6
  def initialize(name, options = {})
5
7
  options.assert_valid_keys(:normalize, :configuration, :format)
6
8
  @name, @options = name, options
@@ -10,6 +12,7 @@ module TsVectors
10
12
  @configuration = 'simple'
11
13
  end
12
14
  if (format = @options[:format])
15
+ raise ArgumentError, "Unsupported format #{format.inspect}" unless FORMATS.include?(format)
13
16
  @format = format.to_sym
14
17
  else
15
18
  @format = :text
@@ -1,3 +1,3 @@
1
1
  module TsVectors
2
- VERSION = '0.0.2'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  class ModelUsingTsVectorFormat < ActiveRecord::Base
4
4
  self.table_name = 'models_with_tsvector_format'
5
5
  FORMAT = 'tsvector'
6
- ts_vector :tags
6
+ ts_vector :tags, :format => :tsvector
7
7
  end
8
8
 
9
9
  class ModelUsingTextFormat < ActiveRecord::Base
@@ -14,7 +14,9 @@ end
14
14
 
15
15
  class ModelWithNormalization < ActiveRecord::Base
16
16
  self.table_name = 'models_with_tsvector_format'
17
- ts_vector :tags, :normalize => lambda { |v| v.downcase.gsub(/\d/, '') }
17
+ ts_vector :tags,
18
+ :format => :tsvector,
19
+ :normalize => lambda { |v| v.downcase.gsub(/\d/, '') }
18
20
  end
19
21
 
20
22
  describe TsVectors::Model do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ar-tsvectors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-08 00:00:00.000000000 Z
12
+ date: 2013-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -115,8 +115,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  version: '0'
116
116
  requirements: []
117
117
  rubyforge_project: ar-tsvectors
118
- rubygems_version: 1.8.24
118
+ rubygems_version: 1.8.23
119
119
  signing_key:
120
120
  specification_version: 3
121
121
  summary: Support for PostgreSQL's ts_vector data type in ActiveRecord
122
122
  test_files: []
123
+ has_rdoc: