fuzzily_reloaded 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
3
+ describe Fuzzily::String do
4
+ def result(string)
5
+ described_class.new(string).trigrams
6
+ end
7
+
8
+ it "splits strings into trigrams" do
9
+ expect(result("Paris")).to eq %w(**p *pa par ari ris is*)
10
+ end
11
+
12
+ it "removes accents" do
13
+ expect(result("Montélimar")).to eq %w(**m *mo mon ont nte tel eli lim ima mar ar*)
14
+ end
15
+
16
+ it "allows numbers" do
17
+ expect(result("GTA 5")).to eq %w(**g *gt gta ta* a*5 *5*)
18
+ end
19
+
20
+ it "handles multi word strings" do
21
+ expect(result("Le Mans")).to eq %w(**l *le le* e*m *ma man ans ns*)
22
+ end
23
+
24
+ it "removes symbols and duplicates" do
25
+ # The final ess, sse, se* would be dupes.
26
+ expect(result("Besse-en-Chandesse")).to eq %w(**b *be bes ess sse se* e*e *en en* n*c *ch cha han and nde des)
27
+ end
28
+ end
data/spec/meta_spec.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+ # This tests our RSpec setup works
3
+
4
+ describe "Test suite" do
5
+ it "has a working ActiveRecord connection" do
6
+ ActiveRecord::Base.connection.execute("SELECT(1)")
7
+ end
8
+ end
@@ -0,0 +1,79 @@
1
+ require "fuzzily"
2
+ require "pathname"
3
+ require "yaml"
4
+
5
+
6
+ DATABASE = Pathname.new "test.sqlite3"
7
+
8
+ # def get_adapter
9
+ # ENV.fetch("FUZZILY_ADAPTER", "sqlite3")
10
+ # end
11
+
12
+ # Database connection hashes
13
+ def get_connection_hash
14
+ case ENV.fetch("FUZZILY_ADAPTER", "sqlite3")
15
+ when "postgresql"
16
+ {
17
+ adapter: "postgresql",
18
+ database: "fuzzily_test",
19
+ host: "localhost",
20
+ min_messages: "warning",
21
+ username: ENV["FUZZILY_DB_USER"]
22
+ }
23
+ when "mysql"
24
+ {
25
+ adapter: "mysql2",
26
+ database: "fuzzily_test",
27
+ host: "localhost",
28
+ username: ENV["FUZZILY_DB_USER"]
29
+ }
30
+ when "sqlite3"
31
+ {
32
+ adapter: "sqlite3",
33
+ database: DATABASE.to_s
34
+ }
35
+ end
36
+ end
37
+
38
+ # A test model we"ll need as a source of trigrams
39
+ class Stuff < ActiveRecord::Base ; end
40
+ class StuffMigration < ActiveRecord::Migration[5.1]
41
+ def self.up
42
+ create_table :stuffs do |t|
43
+ t.string :name
44
+ t.string :data
45
+ t.timestamps
46
+ end
47
+ end
48
+
49
+ def self.down
50
+ drop_table :stuffs
51
+ end
52
+ end
53
+
54
+ RSpec.configure do |config|
55
+ config.before(:each) do
56
+ # Connect to & cleanup test database
57
+ ActiveRecord::Base.establish_connection(get_connection_hash)
58
+
59
+ %w(trigrams stuffs foobars).each do |table_name|
60
+ ActiveRecord::Base.connection.execute "DROP TABLE IF EXISTS #{table_name};"
61
+ end
62
+
63
+ def prepare_trigrams_table
64
+ ActiveRecord::Migration.suppress_messages do
65
+ Class.new(ActiveRecord::Migration[5.1]).extend(Fuzzily::Migration).up
66
+ end
67
+ end
68
+
69
+ def prepare_owners_table
70
+ ActiveRecord::Migration.suppress_messages do
71
+ StuffMigration.up
72
+ end
73
+ end
74
+ end
75
+
76
+ config.after(:each) do
77
+ DATABASE.delete if DATABASE.exist?
78
+ end
79
+ end
metadata ADDED
@@ -0,0 +1,174 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fuzzily_reloaded
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Julien Letessier
8
+ - Sven Pachnit
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2020-04-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activerecord
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '5.1'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '5.1'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: sqlite3
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: pg
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: mysql2
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ description: Fast fuzzy string matching for rails
113
+ email:
114
+ - julien.letessier@gmail.com
115
+ - sven@bmonkeys.net
116
+ executables: []
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - ".travis.yml"
123
+ - Gemfile
124
+ - Gemfile.lock
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - fuzzily.gemspec
129
+ - gemfiles/rails51.gemfile
130
+ - gemfiles/rails60.gemfile
131
+ - lib/fuzzily.rb
132
+ - lib/fuzzily/migration.rb
133
+ - lib/fuzzily/model.rb
134
+ - lib/fuzzily/searchable.rb
135
+ - lib/fuzzily/trigram.rb
136
+ - lib/fuzzily/version.rb
137
+ - lib/fuzzily_reloaded.rb
138
+ - spec/fuzzily/migration_spec.rb
139
+ - spec/fuzzily/model_spec.rb
140
+ - spec/fuzzily/searchable_spec.rb
141
+ - spec/fuzzily/trigram_spec.rb
142
+ - spec/meta_spec.rb
143
+ - spec/spec_helper.rb
144
+ homepage: http://github.com/2called-chaos/fuzzily
145
+ licenses:
146
+ - MIT
147
+ metadata: {}
148
+ post_install_message:
149
+ rdoc_options: []
150
+ require_paths:
151
+ - lib
152
+ required_ruby_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ requirements: []
163
+ rubygems_version: 3.1.2
164
+ signing_key:
165
+ specification_version: 4
166
+ summary: A fast, trigram-based, database-backed fuzzy string search/match engine for
167
+ Rails.
168
+ test_files:
169
+ - spec/fuzzily/migration_spec.rb
170
+ - spec/fuzzily/model_spec.rb
171
+ - spec/fuzzily/searchable_spec.rb
172
+ - spec/fuzzily/trigram_spec.rb
173
+ - spec/meta_spec.rb
174
+ - spec/spec_helper.rb