fonetica 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  pkg/*
2
2
  *.gem
3
3
  .bundle
4
+ .rvmrc
@@ -1,52 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fonetica (0.1.1)
5
- activerecord (>= 3.0.0)
4
+ fonetica (0.3.0)
6
5
  activesupport (>= 3.0.0)
6
+ i18n (>= 0.4.1)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
- abstract (1.0.0)
12
- actionpack (3.0.1)
13
- activemodel (= 3.0.1)
14
- activesupport (= 3.0.1)
15
- builder (~> 2.1.2)
16
- erubis (~> 2.6.6)
17
- i18n (~> 0.4.1)
18
- rack (~> 1.2.1)
19
- rack-mount (~> 0.6.12)
20
- rack-test (~> 0.5.4)
21
- tzinfo (~> 0.3.23)
22
- activemodel (3.0.1)
23
- activesupport (= 3.0.1)
24
- builder (~> 2.1.2)
25
- i18n (~> 0.4.1)
26
- activerecord (3.0.1)
27
- activemodel (= 3.0.1)
28
- activesupport (= 3.0.1)
29
- arel (~> 1.0.0)
30
- tzinfo (~> 0.3.23)
31
11
  activesupport (3.0.1)
32
- arel (1.0.1)
33
- activesupport (~> 3.0.0)
34
- builder (2.1.2)
35
12
  diff-lcs (1.1.2)
36
- erubis (2.6.6)
37
- abstract (>= 1.0.0)
38
- i18n (0.4.1)
39
- rack (1.2.1)
40
- rack-mount (0.6.13)
41
- rack (>= 1.0.0)
42
- rack-test (0.5.6)
43
- rack (>= 1.0)
44
- railties (3.0.1)
45
- actionpack (= 3.0.1)
46
- activesupport (= 3.0.1)
47
- rake (>= 0.8.4)
48
- thor (~> 0.14.0)
49
- rake (0.8.7)
13
+ i18n (0.4.2)
50
14
  rspec (2.0.0)
51
15
  rspec-core (= 2.0.0)
52
16
  rspec-expectations (= 2.0.0)
@@ -57,17 +21,12 @@ GEM
57
21
  rspec-mocks (2.0.0)
58
22
  rspec-core (= 2.0.0)
59
23
  rspec-expectations (= 2.0.0)
60
- sqlite3-ruby (1.3.1)
61
- thor (0.14.3)
62
- tzinfo (0.3.23)
63
24
 
64
25
  PLATFORMS
65
26
  ruby
66
27
 
67
28
  DEPENDENCIES
68
- activerecord (>= 3.0.0)
69
29
  activesupport (>= 3.0.0)
70
30
  fonetica!
71
- railties (>= 3.0.0)
31
+ i18n (>= 0.4.1)
72
32
  rspec (>= 2.0.0)
73
- sqlite3-ruby (>= 1.3.1)
@@ -15,8 +15,6 @@ Gem::Specification.new do |s|
15
15
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
16
  s.require_paths = ["lib"]
17
17
  s.add_dependency(%q<activesupport>, [">= 3.0.0"])
18
- s.add_dependency(%q<activerecord>, [">= 3.0.0"])
19
- s.add_development_dependency(%q<railties>, [">= 3.0.0"])
18
+ s.add_dependency(%q<i18n>, [">= 0.4.1"])
20
19
  s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
21
- s.add_development_dependency(%q<sqlite3-ruby>, [">= 1.3.1"])
22
20
  end
@@ -1,6 +1,47 @@
1
+ require 'i18n'
2
+ require 'active_support/core_ext/module/attribute_accessors'
3
+ require 'active_support/inflector/transliterate'
1
4
  require 'fonetica/core_ext/string'
2
- require 'fonetica/railtie' if defined?(Rails)
3
5
 
4
6
  module Fonetica
5
- autoload :ActiveRecord, 'fonetica/active_record'
7
+ extend self
8
+
9
+ mattr_accessor :replacements, :instance_writer => false
10
+
11
+ self.replacements = [
12
+ ['Y', 'I'],
13
+ [/BR|BL/, 'B'],
14
+ ['PH', 'F'],
15
+ [/MG|NG|RG/, 'G'],
16
+ [/GE|GI|RJ|MJ|NJ/, 'J'],
17
+ [/GR|GL/, 'G'],
18
+ [/CE|CI|CH/, 'S'],
19
+ [/PT|CT/, 'T'],
20
+ ['CS', 'S'],
21
+ [/Q|C|CA|CO|CU|CK/, 'K'],
22
+ ['LH', 'L'],
23
+ ['RM', 'SM'],
24
+ ['N', 'M'],
25
+ [/MD|GM|AO\b/, 'M'],
26
+ ['NH', 'N'],
27
+ ['PR', 'P'],
28
+ [/X|TS|C|Z|RS/, 'S'],
29
+ [/TR|TL/, 'T'],
30
+ [/LT|RT|ST/, 'T'],
31
+ ['W', 'V'],
32
+ [/[SZRMNL]\b/, ''],
33
+ ['L', 'R'],
34
+ [/[AEIOUH]/, '']
35
+ ]
36
+
37
+ def foneticalize(word)
38
+ result = word.to_s.gsub(/ç/i, 's')
39
+ result = I18n.transliterate(result).upcase
40
+
41
+ replacements.each do |search, replace|
42
+ result.gsub!(search, replace)
43
+ end
44
+
45
+ result.squeeze
46
+ end
6
47
  end
@@ -1,40 +1,5 @@
1
- require 'active_support'
2
-
3
1
  class String
4
- FONETICA = [
5
- [/Y/, 'I'],
6
- [/B[RL]/, 'B'],
7
- [/PH/, 'F'],
8
- [/[MNR]G/, 'G'],
9
- [/G[EI]|[RMN]J/, 'J'],
10
- [/G[RL]/, 'G'],
11
- [/C[EIH]/, 'S'],
12
- [/[PC]T/, 'T'],
13
- [/CS/, 'S'],
14
- [/Q|C[AOUK]?/, 'K'],
15
- [/LH/, 'L'],
16
- [/RM/, 'SM'],
17
- [/N/, 'M'],
18
- [/MD|GM|AO\b/, 'M'],
19
- [/NH/, 'N'],
20
- [/PR/, 'P'],
21
- [/X|TS|C|Z|RS/, 'S'],
22
- [/T[RL]/, 'T'],
23
- [/[LRS]T/, 'T'],
24
- [/W/, 'V'],
25
- [/[SZRMNL]\b/, ''],
26
- [/L/, 'R'],
27
- [/[AEIOUH]/, '']
28
- ]
29
-
30
- def fonetica
31
- word = self.gsub(/ç/i, 's') # special case
32
- word = I18n.transliterate(word).upcase
33
-
34
- FONETICA.each do |search, replace|
35
- word.gsub!(search, replace)
36
- end
37
-
38
- word.squeeze
2
+ def foneticalize
3
+ Fonetica.foneticalize(self)
39
4
  end
40
5
  end
@@ -1,7 +1,7 @@
1
1
  module Fonetica
2
2
  module Version #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 2
4
+ MINOR = 3
5
5
  TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
@@ -3,242 +3,242 @@ require 'spec_helper'
3
3
  describe 'Fonetica' do
4
4
  context 'BR = BL = B' do
5
5
  it '"broco" and "bloco" should fonetica to "BK"' do
6
- 'broco'.fonetica.should == 'BK'
7
- 'bloco'.fonetica.should == 'BK'
6
+ 'broco'.foneticalize.should == 'BK'
7
+ 'bloco'.foneticalize.should == 'BK'
8
8
  end
9
9
  end
10
10
 
11
11
  context 'CA = CO = CU = CK = K' do
12
12
  it '"casa" and "kasa" should fonetica to "KS"' do
13
- 'casa'.fonetica.should == 'KS'
14
- 'kasa'.fonetica.should == 'KS'
13
+ 'casa'.foneticalize.should == 'KS'
14
+ 'kasa'.foneticalize.should == 'KS'
15
15
  end
16
16
 
17
17
  it '"coroar" and "koroar" should fonetica to "KR"' do
18
- 'coroar'.fonetica.should == 'KR'
19
- 'koroar'.fonetica.should == 'KR'
18
+ 'coroar'.foneticalize.should == 'KR'
19
+ 'koroar'.foneticalize.should == 'KR'
20
20
  end
21
21
 
22
22
  it '"cuba" and "kuba" should fonetica to "KB"' do
23
- 'cuba'.fonetica.should == 'KB'
24
- 'kuba'.fonetica.should == 'KB'
23
+ 'cuba'.foneticalize.should == 'KB'
24
+ 'kuba'.foneticalize.should == 'KB'
25
25
  end
26
26
  end
27
27
 
28
28
  context 'CE = CI = Ç = S' do
29
29
  it '"cela" and "sela" should fonetica to "SR"' do
30
- 'cela'.fonetica.should == 'SR'
31
- 'sela'.fonetica.should == 'SR'
30
+ 'cela'.foneticalize.should == 'SR'
31
+ 'sela'.foneticalize.should == 'SR'
32
32
  end
33
33
 
34
34
  it '"circo" and "sirco" should fonetica to "SRK"' do
35
- 'circo'.fonetica.should == 'SRK'
36
- 'sirco'.fonetica.should == 'SRK'
35
+ 'circo'.foneticalize.should == 'SRK'
36
+ 'sirco'.foneticalize.should == 'SRK'
37
37
  end
38
38
 
39
39
  it '"roça" and "rosa" should fonetica to "RS"' do
40
- 'roça'.fonetica.should == 'RS'
41
- 'rosa'.fonetica.should == 'RS'
40
+ 'roça'.foneticalize.should == 'RS'
41
+ 'rosa'.foneticalize.should == 'RS'
42
42
  end
43
43
  end
44
44
 
45
45
  context 'CH = X = S' do
46
46
  it '"ameixa" and "ameicha" should fonetica to "MS"' do
47
- 'ameixa'.fonetica.should == 'MS'
48
- 'ameicha'.fonetica.should == 'MS'
47
+ 'ameixa'.foneticalize.should == 'MS'
48
+ 'ameicha'.foneticalize.should == 'MS'
49
49
  end
50
50
  end
51
51
 
52
52
  context 'CS = S' do
53
53
  it '"toracs" and "torax" should fonetica to "TR"' do
54
- 'toracs'.fonetica.should == 'TR'
55
- 'torax'.fonetica.should == 'TR'
54
+ 'toracs'.foneticalize.should == 'TR'
55
+ 'torax'.foneticalize.should == 'TR'
56
56
  end
57
57
  end
58
58
 
59
59
  context 'CT = T' do
60
60
  it '"compactar" and "compatar" should fonetica to "KMPT"' do
61
- 'compactar'.fonetica.should == 'KMPT'
62
- 'compatar'.fonetica.should == 'KMPT'
61
+ 'compactar'.foneticalize.should == 'KMPT'
62
+ 'compatar'.foneticalize.should == 'KMPT'
63
63
  end
64
64
  end
65
65
 
66
66
  context 'BT = T' do
67
67
  it '"batista" and "baptista" should fonetica to "BT"' do
68
- 'batista'.fonetica.should == 'BT'
69
- 'baptista'.fonetica.should == 'BT'
68
+ 'batista'.foneticalize.should == 'BT'
69
+ 'baptista'.foneticalize.should == 'BT'
70
70
  end
71
71
  end
72
72
 
73
73
  context 'GA = GO = GU = GL = GR = G' do
74
74
  it '"gana" should fonetica to "KMPT"' do
75
- 'gana'.fonetica.should == 'GM'
75
+ 'gana'.foneticalize.should == 'GM'
76
76
  end
77
77
 
78
78
  it '"gostar" should fonetica to "GT"' do
79
- 'gostar'.fonetica.should == 'GT'
79
+ 'gostar'.foneticalize.should == 'GT'
80
80
  end
81
81
 
82
82
  it '"guabiru" should fonetica to "GBR"' do
83
- 'guabiru'.fonetica.should == 'GBR'
83
+ 'guabiru'.foneticalize.should == 'GBR'
84
84
  end
85
85
 
86
86
  it '"negro" and "nego" should fonetica to "MG"' do
87
- 'negro'.fonetica.should == 'MG'
88
- 'nego'.fonetica.should == 'MG'
87
+ 'negro'.foneticalize.should == 'MG'
88
+ 'nego'.foneticalize.should == 'MG'
89
89
  end
90
90
 
91
91
  it '"hieróglifo" and "hierógrifo" should fonetica to "RGF"' do
92
- 'hieróglifo'.fonetica.should == 'RGF'
93
- 'hierógrifo'.fonetica.should == 'RGF'
92
+ 'hieróglifo'.foneticalize.should == 'RGF'
93
+ 'hierógrifo'.foneticalize.should == 'RGF'
94
94
  end
95
95
  end
96
96
 
97
97
  context 'GE = GI = J' do
98
98
  it '"gene" should fonetica to "JM"' do
99
- 'gene'.fonetica.should == 'JM'
99
+ 'gene'.foneticalize.should == 'JM'
100
100
  end
101
101
 
102
102
  it '"gibi" should fonetica to "JB"' do
103
- 'gibi'.fonetica.should == 'JB'
103
+ 'gibi'.foneticalize.should == 'JB'
104
104
  end
105
105
  end
106
106
 
107
107
  context 'GM = M' do
108
108
  it '"fleugma" should fonetica to "FRM"' do
109
- 'fleugma'.fonetica.should == 'FRM'
109
+ 'fleugma'.foneticalize.should == 'FRM'
110
110
  end
111
111
  end
112
112
 
113
113
  context 'L = R' do
114
114
  it '"luminar" and "ruminar" should fonetica to "RM"' do
115
- 'luminar'.fonetica.should == 'RM'
116
- 'ruminar'.fonetica.should == 'RM'
115
+ 'luminar'.foneticalize.should == 'RM'
116
+ 'ruminar'.foneticalize.should == 'RM'
117
117
  end
118
118
  end
119
119
 
120
120
  context 'N = M' do
121
121
  it '"mudez" and "nudez" should fonetica to "MD"' do
122
- 'mudez'.fonetica.should == 'MD'
123
- 'nudez'.fonetica.should == 'MD'
122
+ 'mudez'.foneticalize.should == 'MD'
123
+ 'nudez'.foneticalize.should == 'MD'
124
124
  end
125
125
  end
126
126
 
127
127
  context 'MD = D' do
128
128
  it '"comendo" and "comeno" should fonetica to "KM"' do
129
- 'comendo'.fonetica.should == 'KM'
130
- 'comeno'.fonetica.should == 'KM'
129
+ 'comendo'.foneticalize.should == 'KM'
130
+ 'comeno'.foneticalize.should == 'KM'
131
131
  end
132
132
  end
133
133
 
134
134
  context 'MG = G and MJ = J' do
135
135
  it '"bunginganga" and "bugiganga" should fonetica to "BJG"' do
136
- 'bunginganga'.fonetica.should == 'BJG'
137
- 'bugiganga'.fonetica.should == 'BJG'
136
+ 'bunginganga'.foneticalize.should == 'BJG'
137
+ 'bugiganga'.foneticalize.should == 'BJG'
138
138
  end
139
139
  end
140
140
 
141
141
  context 'PH = F' do
142
142
  it '"philipe" and "felipe" should fonetica to "FRP"' do
143
- 'philipe'.fonetica.should == 'FRP'
144
- 'felipe'.fonetica.should == 'FRP'
143
+ 'philipe'.foneticalize.should == 'FRP'
144
+ 'felipe'.foneticalize.should == 'FRP'
145
145
  end
146
146
  end
147
147
 
148
148
  context 'PR = P' do
149
149
  it '"estupro" and "estrupo" should fonetica to "TP"' do
150
- 'estupro'.fonetica.should == 'TP'
151
- 'estrupo'.fonetica.should == 'TP'
150
+ 'estupro'.foneticalize.should == 'TP'
151
+ 'estrupo'.foneticalize.should == 'TP'
152
152
  end
153
153
  end
154
154
 
155
155
  context 'Q = K' do
156
156
  it '"queijo" and "keijo" should fonetica to "KJ"' do
157
- 'queijo'.fonetica.should == 'KJ'
158
- 'keijo'.fonetica.should == 'KJ'
157
+ 'queijo'.foneticalize.should == 'KJ'
158
+ 'keijo'.foneticalize.should == 'KJ'
159
159
  end
160
160
  end
161
161
 
162
162
  context 'RG = G, RS = S, and RT = T' do
163
163
  it '"lagarto" and "largato" should fonetica to "RGT"' do
164
- 'lagarto'.fonetica.should == 'RGT'
165
- 'largato'.fonetica.should == 'RGT'
164
+ 'lagarto'.foneticalize.should == 'RGT'
165
+ 'largato'.foneticalize.should == 'RGT'
166
166
  end
167
167
 
168
168
  it '"perspectiva" and "pespectiva" should fonetica to "PSPTV"' do
169
- 'perspectiva'.fonetica.should == 'PSPTV'
170
- 'pespectiva'.fonetica.should == 'PSPTV'
169
+ 'perspectiva'.foneticalize.should == 'PSPTV'
170
+ 'pespectiva'.foneticalize.should == 'PSPTV'
171
171
  end
172
172
 
173
173
  it '"lagartixa" and "largatixa" should fonetica to "RGTS"' do
174
- 'lagartixa'.fonetica.should == 'RGTS'
175
- 'largatixa'.fonetica.should == 'RGTS'
174
+ 'lagartixa'.foneticalize.should == 'RGTS'
175
+ 'largatixa'.foneticalize.should == 'RGTS'
176
176
  end
177
177
  end
178
178
 
179
179
  context 'RM = SM' do
180
180
  it '"mesmo" and "mermo" should fonetica to "MSM"' do
181
- 'mesmo'.fonetica.should == 'MSM'
182
- 'mermo'.fonetica.should == 'MSM'
181
+ 'mesmo'.foneticalize.should == 'MSM'
182
+ 'mermo'.foneticalize.should == 'MSM'
183
183
  end
184
184
  end
185
185
 
186
186
  context 'RJ = J' do
187
187
  it '"virgem" and "vige" should fonetica to "VJ"' do
188
- 'virgem'.fonetica.should == 'VJ'
189
- 'vige'.fonetica.should == 'VJ'
188
+ 'virgem'.foneticalize.should == 'VJ'
189
+ 'vige'.foneticalize.should == 'VJ'
190
190
  end
191
191
  end
192
192
 
193
193
  context 'ST = T' do
194
194
  it '"superstição" and "supertição" should fonetica to "SPTS"' do
195
- 'superstição'.fonetica.should == 'SPTS'
196
- 'supertição'.fonetica.should == 'SPTS'
195
+ 'superstição'.foneticalize.should == 'SPTS'
196
+ 'supertição'.foneticalize.should == 'SPTS'
197
197
  end
198
198
  end
199
199
 
200
200
  context 'TR = T, TL = T, and TS = T' do
201
201
  it '"estupro" and "estrupo" should fonetica to "TP"' do
202
- 'estupro'.fonetica.should == 'TP'
203
- 'estrupo'.fonetica.should == 'TP'
202
+ 'estupro'.foneticalize.should == 'TP'
203
+ 'estrupo'.foneticalize.should == 'TP'
204
204
  end
205
205
 
206
206
  it '"contrato" and "contlato" should fonetica to "KMT"' do
207
- 'contrato'.fonetica.should == 'KMT'
208
- 'contlato'.fonetica.should == 'KMT'
207
+ 'contrato'.foneticalize.should == 'KMT'
208
+ 'contlato'.foneticalize.should == 'KMT'
209
209
  end
210
210
 
211
211
  it '"kubitscheck" and "kubixeque" should fonetica to "KBSK"' do
212
- 'kubitscheck'.fonetica.should == 'KBSK'
213
- 'kubixeque'.fonetica.should == 'KBSK'
212
+ 'kubitscheck'.foneticalize.should == 'KBSK'
213
+ 'kubixeque'.foneticalize.should == 'KBSK'
214
214
  end
215
215
  end
216
216
 
217
217
  context 'W = V' do
218
218
  it '"walter" and "valter" should fonetica to "VT"' do
219
- 'walter'.fonetica.should == 'VT'
220
- 'valter'.fonetica.should == 'VT'
219
+ 'walter'.foneticalize.should == 'VT'
220
+ 'valter'.foneticalize.should == 'VT'
221
221
  end
222
222
  end
223
223
 
224
224
  context 'X = S' do
225
225
  it '"exceder" and "esceder" should fonetica to "SD"' do
226
- 'exceder'.fonetica.should == 'SD'
227
- 'esceder'.fonetica.should == 'SD'
226
+ 'exceder'.foneticalize.should == 'SD'
227
+ 'esceder'.foneticalize.should == 'SD'
228
228
  end
229
229
  end
230
230
 
231
231
  context 'Y = I' do
232
232
  it '"yara" and "iara" should fonetica to "R"' do
233
- 'yara'.fonetica.should == 'R'
234
- 'iara'.fonetica.should == 'R'
233
+ 'yara'.foneticalize.should == 'R'
234
+ 'iara'.foneticalize.should == 'R'
235
235
  end
236
236
  end
237
237
 
238
238
  context 'Z = S' do
239
239
  it '"casa" and "caza" should fonetica to "KS"' do
240
- 'casa'.fonetica.should == 'KS'
241
- 'caza'.fonetica.should == 'KS'
240
+ 'casa'.foneticalize.should == 'KS'
241
+ 'caza'.foneticalize.should == 'KS'
242
242
  end
243
243
  end
244
244
  end
@@ -1,22 +1,3 @@
1
1
  require 'rubygems'
2
2
  require 'bundler/setup'
3
- require 'active_record'
4
3
  require 'fonetica'
5
- require 'fonetica/active_record'
6
-
7
- ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:'
8
- ActiveRecord::Migration.verbose = false
9
-
10
- ActiveRecord::Schema.define(:version => 0) do
11
- create_table :people do |t|
12
- t.string :name
13
- t.string :fonetica_name
14
- end
15
-
16
- add_index :people, :fonetica_name
17
- end
18
-
19
- class Person < ActiveRecord::Base
20
- end
21
-
22
- ActiveRecord::Base.send(:include, Fonetica::ActiveRecord)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fonetica
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gabriel Sobrinho
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-18 00:00:00 -02:00
19
+ date: 2010-12-22 00:00:00 -02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -36,41 +36,25 @@ dependencies:
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
39
- name: activerecord
39
+ name: i18n
40
40
  prerelease: false
41
41
  requirement: &id002 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- hash: 7
46
+ hash: 13
47
47
  segments:
48
- - 3
49
- - 0
50
48
  - 0
51
- version: 3.0.0
49
+ - 4
50
+ - 1
51
+ version: 0.4.1
52
52
  type: :runtime
53
53
  version_requirements: *id002
54
- - !ruby/object:Gem::Dependency
55
- name: railties
56
- prerelease: false
57
- requirement: &id003 !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- hash: 7
63
- segments:
64
- - 3
65
- - 0
66
- - 0
67
- version: 3.0.0
68
- type: :development
69
- version_requirements: *id003
70
54
  - !ruby/object:Gem::Dependency
71
55
  name: rspec
72
56
  prerelease: false
73
- requirement: &id004 !ruby/object:Gem::Requirement
57
+ requirement: &id003 !ruby/object:Gem::Requirement
74
58
  none: false
75
59
  requirements:
76
60
  - - ">="
@@ -82,23 +66,7 @@ dependencies:
82
66
  - 0
83
67
  version: 2.0.0
84
68
  type: :development
85
- version_requirements: *id004
86
- - !ruby/object:Gem::Dependency
87
- name: sqlite3-ruby
88
- prerelease: false
89
- requirement: &id005 !ruby/object:Gem::Requirement
90
- none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- hash: 25
95
- segments:
96
- - 1
97
- - 3
98
- - 1
99
- version: 1.3.1
100
- type: :development
101
- version_requirements: *id005
69
+ version_requirements: *id003
102
70
  description:
103
71
  email:
104
72
  - gabriel.sobrinho@gmail.com
@@ -119,11 +87,8 @@ files:
119
87
  - autotest/discover.rb
120
88
  - fonetica.gemspec
121
89
  - lib/fonetica.rb
122
- - lib/fonetica/active_record.rb
123
90
  - lib/fonetica/core_ext/string.rb
124
- - lib/fonetica/railtie.rb
125
91
  - lib/fonetica/version.rb
126
- - spec/active_record_spec.rb
127
92
  - spec/fonetica_spec.rb
128
93
  - spec/spec_helper.rb
129
94
  has_rdoc: true
@@ -161,6 +126,5 @@ signing_key:
161
126
  specification_version: 3
162
127
  summary: Phonetic finder for ActiveRecord using BUSCABR algorithm
163
128
  test_files:
164
- - spec/active_record_spec.rb
165
129
  - spec/fonetica_spec.rb
166
130
  - spec/spec_helper.rb
@@ -1,28 +0,0 @@
1
- module Fonetica
2
- module ActiveRecord
3
- extend ActiveSupport::Concern
4
-
5
- module ClassMethods
6
- def has_fonetica_for(column)
7
- cattr_accessor :fonetica_column, :fonetica_cache_column
8
-
9
- self.fonetica_column = column
10
- self.fonetica_cache_column = :"fonetica_#{column}"
11
-
12
- scope :fonetica, lambda { |fonetica|
13
- {
14
- :conditions => ["#{quoted_table_name}.#{fonetica_cache_column} LIKE ?", "#{fonetica.to_s.fonetica}%"]
15
- }
16
- }
17
-
18
- before_save :update_fonetica
19
- end
20
- end
21
-
22
- module InstanceMethods
23
- def update_fonetica
24
- write_attribute(fonetica_cache_column, read_attribute(fonetica_column).to_s.fonetica)
25
- end
26
- end
27
- end
28
- end
@@ -1,9 +0,0 @@
1
- module Fonetica
2
- class Railtie < Rails::Railtie
3
- initializer 'fonetica.active_record' do
4
- ActiveSupport.on_load(:active_record) do
5
- include Fonetica::ActiveRecord
6
- end
7
- end
8
- end
9
- end
@@ -1,36 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'ActiveRecord' do
4
- it 'should respond to has_fonetica_for' do
5
- Person.should respond_to :has_fonetica_for
6
- end
7
-
8
- context 'with fonetica' do
9
- before do
10
- Person.has_fonetica_for :name
11
- end
12
-
13
- it 'should create a scope named fonetica' do
14
- Person.should respond_to :fonetica
15
- end
16
-
17
- it 'should set fonetica_column and fonetica_cache_column' do
18
- Person.fonetica_column.should == :name
19
- Person.fonetica_cache_column.should == :fonetica_name
20
- end
21
-
22
- it 'should find records using first name' do
23
- Person.create(:name => 'iara santos')
24
- Person.create(:name => 'yara santos')
25
-
26
- Person.fonetica('iara').should have(2).records
27
- end
28
-
29
- it 'should find records using first and last name' do
30
- Person.create(:name => 'joao baptista')
31
- Person.create(:name => 'joao batista')
32
-
33
- Person.fonetica('joao batista').should have(2).records
34
- end
35
- end
36
- end