pg_fuzzy_string_matcher 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -2
- data/lib/generators/pg_fuzzy_string_matcher_install/USAGE +3 -0
- data/lib/generators/pg_fuzzy_string_matcher_install/pg_fuzzy_string_matcher_install_generator.rb +18 -0
- data/lib/generators/{pg_fuzzy_string_matcher → pg_fuzzy_string_matcher_install}/templates/migration.rb +0 -0
- data/lib/pg_fuzzy_string_matcher/{finder.rb → named_scope.rb} +2 -2
- data/lib/pg_fuzzy_string_matcher.rb +2 -3
- metadata +7 -6
- data/lib/generators/pg_fuzzy_string_matcher/pg_fuzzy_string_matcher_generator.rb +0 -26
data/README.rdoc
CHANGED
@@ -12,9 +12,12 @@ Then use the bundler to install It:
|
|
12
12
|
|
13
13
|
$ bundle install
|
14
14
|
|
15
|
-
|
15
|
+
Add the next line into your file config/initializers/my_gems.rb:
|
16
|
+
require 'pg_fuzzy_string_matcher'
|
16
17
|
|
17
|
-
|
18
|
+
Then execute the rails migration generator:
|
19
|
+
|
20
|
+
$ ./script/rails generate pg_fuzzy_string_matcher_install
|
18
21
|
|
19
22
|
And finally run the rails migrations to add the functions for PostgreSQL:
|
20
23
|
|
data/lib/generators/pg_fuzzy_string_matcher_install/pg_fuzzy_string_matcher_install_generator.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/generators/migration'
|
2
|
+
class PgFuzzyStringMatcherInstallGenerator < Rails::Generators::Base
|
3
|
+
include Rails::Generators::Migration
|
4
|
+
|
5
|
+
desc "Generates a migration file to add Fuzzy String Matching functions to your PostgreSQL database."
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
@_source_root = File.expand_path('../templates', __FILE__)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.next_migration_number(path)
|
12
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
13
|
+
end
|
14
|
+
|
15
|
+
def copy_migration_template
|
16
|
+
migration_template "migration.rb", "db/migrate/add_pg_fuzzy_string_matcher"
|
17
|
+
end
|
18
|
+
end
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module PgFuzzyStringMatcher
|
2
|
-
module
|
2
|
+
module NamedScope
|
3
3
|
def self.included(base)
|
4
4
|
base.extend ClassMethods
|
5
5
|
end
|
@@ -43,7 +43,7 @@ module PgFuzzyStringMatcher
|
|
43
43
|
scope method_name.to_sym, lambda {|string| where(sql, :q => string) }
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
# TODO: The following PostgreSQL functions are not implemented: dmetaphone_alt, dmetaphone, text_soundex, metaphone and levenshtein.
|
48
48
|
end
|
49
49
|
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module PgFuzzyStringMatcher
|
2
|
-
|
3
2
|
def enable_activerecord
|
4
3
|
return if ActiveRecord::Base.respond_to? :scope_by_soundex_matcher and ActiveRecord::Base.respond_to? :scope_by_difference_matcher
|
5
|
-
require 'pg_fuzzy_string_matcher/
|
6
|
-
ActiveRecord::Base.send :include, PgFuzzyStringMatcher::
|
4
|
+
require 'pg_fuzzy_string_matcher/named_scope'
|
5
|
+
::ActiveRecord::Base.send :include, PgFuzzyStringMatcher::NamedScope
|
7
6
|
end
|
8
7
|
end
|
9
8
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Alejandro Juarez
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-06-01 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -30,10 +30,11 @@ extra_rdoc_files:
|
|
30
30
|
files:
|
31
31
|
- LICENSE
|
32
32
|
- init.rb
|
33
|
-
- lib/generators/
|
34
|
-
- lib/generators/
|
33
|
+
- lib/generators/pg_fuzzy_string_matcher_install/USAGE
|
34
|
+
- lib/generators/pg_fuzzy_string_matcher_install/pg_fuzzy_string_matcher_install_generator.rb
|
35
|
+
- lib/generators/pg_fuzzy_string_matcher_install/templates/migration.rb
|
35
36
|
- lib/pg_fuzzy_string_matcher.rb
|
36
|
-
- lib/pg_fuzzy_string_matcher/
|
37
|
+
- lib/pg_fuzzy_string_matcher/named_scope.rb
|
37
38
|
- README.rdoc
|
38
39
|
has_rdoc: true
|
39
40
|
homepage: http://github.com/alecz/pg_fuzzy_string_matcher
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rails/generators/migration'
|
2
|
-
|
3
|
-
class PgFuzzyStringMatcherGenerator < Rails::Generators::NamedBase
|
4
|
-
include Rails::Generators::Migration
|
5
|
-
|
6
|
-
desc "Generates a migration file to add Fuzzy String Matching functions to your PostgreSQL database."
|
7
|
-
|
8
|
-
def self.source_root
|
9
|
-
@_pg_fuzzy_string_matcher_source_root ||= File.expand_path("../templates", __FILE__)
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.orm_has_migration?
|
13
|
-
Rails::Generators.options[:rails][:orm] == :active_record
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.next_migration_number(path)
|
17
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
18
|
-
end
|
19
|
-
|
20
|
-
class_option :migration, :type => :boolean, :default => orm_has_migration?
|
21
|
-
|
22
|
-
def copy_migration_template
|
23
|
-
return unless options.migration?
|
24
|
-
migration_template "migration.rb", "db/migrate/add_pg_fuzzy_string_matcher"
|
25
|
-
end
|
26
|
-
end
|