sequel-pg-trgm 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 01a2cad5f96f7d809c552a4e954a6f41846093d0
4
+ data.tar.gz: 9d415dec033c312b37f0a1c3b3d70b5504f855ed
5
+ SHA512:
6
+ metadata.gz: 4b74774c66b189c7809634e38570182bc1b50c2402796d7f4a9ed311f8fc7e17f8ee06f99c4b6c5dd612c210e52bc77aae8b9d4c8e759fde92ed3bb7c198514e
7
+ data.tar.gz: 572280ed5b31a1189c3ce26109a7bf1aef8ce2ef2bfaa6135297447f8e59d7a95d44dfd10d39fb08510272e24a52208fb73640fb3a81b201f3600bab10d2f9c8
@@ -0,0 +1,25 @@
1
+ module Sequel
2
+ module Postgres
3
+ module PgTrgm
4
+ def add_extension(name)
5
+ quoted_name = quote_identifier(name) if name
6
+ self.run "CREATE EXTENSION IF NOT EXISTS #{quoted_name};"
7
+ end
8
+
9
+ def drop_extension(name)
10
+ quoted_name = quote_identifier(name) if name
11
+ self.run "DROP EXTENSION IF EXISTS #{quoted_name};"
12
+ end
13
+
14
+ def add_pg_trgm(table, column, op={})
15
+ self.run "CREATE INDEX #{table}_#{column}_trgm_index ON #{table} USING gist (#{column} gist_trgm_ops);"
16
+ end
17
+
18
+ def drop_pg_trgm(table, column)
19
+ self.run "DROP INDEX #{table}_#{column}_trgm_index;"
20
+ end
21
+ end
22
+ end
23
+
24
+ Database.register_extension(:pg_trgm, Postgres::PgTrgm)
25
+ end
@@ -0,0 +1,11 @@
1
+ module Sequel
2
+ module Plugins
3
+ module PgTrgm
4
+ module DatasetMethods
5
+ def text_search(column, query)
6
+ where("#{column} % #{Sequel::Model.db.literal query}").order_by{ Sequel.desc(similarity(column, query)) }
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sequel-pg-trgm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mitchell Henke
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-13 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: mitchh23@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/sequel/extensions/pg_trgm.rb
20
+ - lib/sequel/plugins/pg_trgm.rb
21
+ homepage: https://github.com/mitchellhenke/sequel-pg-trgm
22
+ licenses: []
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.14
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: sequel-pg-trgm
44
+ test_files: []