fonetica 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fonetica (0.1.0)
4
+ fonetica (0.1.1)
5
5
  activerecord (>= 3.0.0)
6
6
  activesupport (>= 3.0.0)
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)
11
22
  activemodel (3.0.1)
12
23
  activesupport (= 3.0.1)
13
24
  builder (~> 2.1.2)
@@ -22,7 +33,20 @@ GEM
22
33
  activesupport (~> 3.0.0)
23
34
  builder (2.1.2)
24
35
  diff-lcs (1.1.2)
36
+ erubis (2.6.6)
37
+ abstract (>= 1.0.0)
25
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)
26
50
  rspec (2.0.0)
27
51
  rspec-core (= 2.0.0)
28
52
  rspec-expectations (= 2.0.0)
@@ -33,6 +57,8 @@ GEM
33
57
  rspec-mocks (2.0.0)
34
58
  rspec-core (= 2.0.0)
35
59
  rspec-expectations (= 2.0.0)
60
+ sqlite3-ruby (1.3.1)
61
+ thor (0.14.3)
36
62
  tzinfo (0.3.23)
37
63
 
38
64
  PLATFORMS
@@ -42,4 +68,6 @@ DEPENDENCIES
42
68
  activerecord (>= 3.0.0)
43
69
  activesupport (>= 3.0.0)
44
70
  fonetica!
45
- rspec (~> 2.0.0)
71
+ railties (>= 3.0.0)
72
+ rspec (>= 2.0.0)
73
+ sqlite3-ruby (>= 1.3.1)
@@ -16,5 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.require_paths = ["lib"]
17
17
  s.add_dependency(%q<activesupport>, [">= 3.0.0"])
18
18
  s.add_dependency(%q<activerecord>, [">= 3.0.0"])
19
- s.add_development_dependency(%q<rspec>, ["~> 2.0.0"])
19
+ s.add_development_dependency(%q<railties>, [">= 3.0.0"])
20
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
21
+ s.add_development_dependency(%q<sqlite3-ruby>, [">= 1.3.1"])
20
22
  end
@@ -1,8 +1,6 @@
1
- require 'fonetica/string'
1
+ require 'fonetica/core_ext/string'
2
+ require 'fonetica/railtie' if defined?(Rails)
2
3
 
3
4
  module Fonetica
4
- end
5
-
6
- if defined?(::Rails::Railtie)
7
- require 'fonetica/railtie'
5
+ autoload :ActiveRecord, 'fonetica/active_record'
8
6
  end
@@ -7,7 +7,7 @@ module Fonetica
7
7
  cattr_accessor :fonetica_column, :fonetica_cache_column
8
8
 
9
9
  self.fonetica_column = column
10
- self.fonetica_cache_column = "#{column}_fonetica"
10
+ self.fonetica_cache_column = :"fonetica_#{column}"
11
11
 
12
12
  scope :fonetica, lambda { |fonetica|
13
13
  {
@@ -1,3 +1,5 @@
1
+ require 'active_support'
2
+
1
3
  class String
2
4
  FONETICA = [
3
5
  [/Y/, 'I'],
@@ -7,7 +9,7 @@ class String
7
9
  [/G[EI]|[RMN]J/, 'J'],
8
10
  [/G[RL]/, 'G'],
9
11
  [/C[EIH]/, 'S'],
10
- [/CT/, 'T'],
12
+ [/[PC]T/, 'T'],
11
13
  [/CS/, 'S'],
12
14
  [/Q|C[AOUK]?/, 'K'],
13
15
  [/LH/, 'L'],
@@ -1,8 +1,7 @@
1
1
  module Fonetica
2
2
  class Railtie < Rails::Railtie
3
3
  initializer 'fonetica.active_record' do
4
- ActiveSupport.on_load :active_record do
5
- require 'fonetica/active_record'
4
+ ActiveSupport.on_load(:active_record) do
6
5
  include Fonetica::ActiveRecord
7
6
  end
8
7
  end
@@ -1,8 +1,8 @@
1
1
  module Fonetica
2
2
  module Version #:nodoc:
3
3
  MAJOR = 0
4
- MINOR = 1
5
- TINY = 1
4
+ MINOR = 2
5
+ TINY = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -0,0 +1,36 @@
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
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe String do
3
+ describe 'Fonetica' do
4
4
  context 'BR = BL = B' do
5
5
  it '"broco" and "bloco" should fonetica to "BK"' do
6
6
  'broco'.fonetica.should == 'BK'
@@ -63,6 +63,13 @@ describe String do
63
63
  end
64
64
  end
65
65
 
66
+ context 'BT = T' do
67
+ it '"batista" and "baptista" should fonetica to "BT"' do
68
+ 'batista'.fonetica.should == 'BT'
69
+ 'baptista'.fonetica.should == 'BT'
70
+ end
71
+ end
72
+
66
73
  context 'GA = GO = GU = GL = GR = G' do
67
74
  it '"gana" should fonetica to "KMPT"' do
68
75
  'gana'.fonetica.should == 'GM'
@@ -131,7 +138,7 @@ describe String do
131
138
  end
132
139
  end
133
140
 
134
- context 'PH = F and PR = P' do
141
+ context 'PH = F' do
135
142
  it '"philipe" and "felipe" should fonetica to "FRP"' do
136
143
  'philipe'.fonetica.should == 'FRP'
137
144
  'felipe'.fonetica.should == 'FRP'
@@ -1,3 +1,22 @@
1
1
  require 'rubygems'
2
- require 'active_support'
3
- require 'fonetica'
2
+ require 'bundler/setup'
3
+ require 'active_record'
4
+ 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: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.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-16 00:00:00 -03:00
19
+ date: 2010-10-18 00:00:00 -02:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -52,12 +52,28 @@ dependencies:
52
52
  type: :runtime
53
53
  version_requirements: *id002
54
54
  - !ruby/object:Gem::Dependency
55
- name: rspec
55
+ name: railties
56
56
  prerelease: false
57
57
  requirement: &id003 !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements:
60
- - - ~>
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
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ prerelease: false
73
+ requirement: &id004 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ">="
61
77
  - !ruby/object:Gem::Version
62
78
  hash: 15
63
79
  segments:
@@ -66,7 +82,23 @@ dependencies:
66
82
  - 0
67
83
  version: 2.0.0
68
84
  type: :development
69
- version_requirements: *id003
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
70
102
  description:
71
103
  email:
72
104
  - gabriel.sobrinho@gmail.com
@@ -88,11 +120,12 @@ files:
88
120
  - fonetica.gemspec
89
121
  - lib/fonetica.rb
90
122
  - lib/fonetica/active_record.rb
123
+ - lib/fonetica/core_ext/string.rb
91
124
  - lib/fonetica/railtie.rb
92
- - lib/fonetica/string.rb
93
125
  - lib/fonetica/version.rb
126
+ - spec/active_record_spec.rb
127
+ - spec/fonetica_spec.rb
94
128
  - spec/spec_helper.rb
95
- - spec/string_spec.rb
96
129
  has_rdoc: true
97
130
  homepage: http://github.com/sobrinho/fonetica
98
131
  licenses: []
@@ -128,5 +161,6 @@ signing_key:
128
161
  specification_version: 3
129
162
  summary: Phonetic finder for ActiveRecord using BUSCABR algorithm
130
163
  test_files:
164
+ - spec/active_record_spec.rb
165
+ - spec/fonetica_spec.rb
131
166
  - spec/spec_helper.rb
132
- - spec/string_spec.rb